How to use the mout/object/forOwn function in mout

To help you get started, we’ve selected a few mout examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cam-inc / viron / src / components / viron-parameters / index.js View on Github external
this.handleValSubmit = (key, newVal) => {
    if (!this.opts.onsubmit) {
      return;
    }
    const ret = this.opts.val;
    ret[key] = newVal;
    // Delete the key if it's undefined.
    forOwn(ret, (val, key) => {
      if (isUndefined(val)) {
        delete ret[key];
      }
    });
    this.opts.onsubmit(ret);
  };
github cam-inc / viron / src / components / organisms / viron-operation / schema.js View on Github external
this.handleChange = (name, value) => {
    const values = ObjectAssign({}, this.opts.parametervalues, {
      [name]: value
    });
    forOwn(values, (v, k) => {
      // TODO: deleteするためのもっと良い方法を模索すること。
      if (typeof v === 'string' && !v.length) {
        delete values[k];
      }
    });
    this.opts.onchange(this.opts.name, values);
  };
}
github cam-inc / viron / src / core / swagger.js View on Github external
case 'null':
      ret._type = 'null';
      ret._value = null;
      ret._rawValue = null;
      break;
    case 'boolean':
      ret._type = 'boolean';
      ret._value = response;
      ret._rawValue = response;
      break;
    case 'object':
      ret._type = 'object';
      ret._value = {};
      ret._rawValue = response;
      ret._keys = [];
      forOwn(response, (v, k) => {
        ret._keys.push(k);
        let nextSchema;
        if (!!schema.properties) {
          nextSchema = schema.properties[k];
        } else if (schema.additionalProperties) {
          nextSchema = {};
        } else {
          // TODO: swagger定義が間違っているので警告を出す。
        }
        ret._value[k] = this.mergeSchemaAndResponse(nextSchema, v);
        ret._value[k]._key = k;
      });
      break;
    case 'array':
      ret._type = 'array';
      ret._value = [];
github cam-inc / viron / src / store / getters / endpoints.js View on Github external
allWithoutToken: state => {
    const version = state.application.version;
    const endpoints = deepClone(state.endpoints[version]);
    // 認証用トークンはexport対象外とする。
    forOwn(endpoints, endpoint => {
      delete endpoint.token;
    });
    return endpoints;
  },
github cam-inc / viron / src / pages / viron-components / card / table / index.js View on Github external
}).on('updated', () => {
    const newCrossSearchQueries = this.opts.crosssearchqueries;
    let isCrossSearchQueriesChanged = false;
    // 値が一つでも違ったらtrue。
    forOwn(newCrossSearchQueries, (value, key) => {
      if (value !== prevCrossSearchQueries[key]) {
        isCrossSearchQueriesChanged = true;
      }
    });
    // 長さが違ってもtrue。
    if (size(newCrossSearchQueries) !== size(prevCrossSearchQueries)) {
      isCrossSearchQueriesChanged = true;
    }
    // 変更があればデータ更新。
    if (isCrossSearchQueriesChanged) {
      forOwn(newCrossSearchQueries, (value, key) => {
        if (!isUndefined(value)) {
          this.searchQueries[key] = value;
        } else {
          delete this.searchQueries[key];
        }
      });
      this.hasSearchQueries = !!size(this.searchQueries);
      // 検索クエリ変更時は強制的にページ番号を1に戻す。
      if (!this.hasPagination) {
        getData();
      } else {
        const pagination = {};
        const size = this.pagination.size;
        const current = 1;
        pagination.limit = size;
        pagination.offset = (current - 1) * size;
github cam-inc / viron / src / core / swagger.js View on Github external
apisFlatObject() {
    if (!this.client) {
      return {};
    }
    const apis = {};
    forOwn(this.client.apis, (v) => {
      forOwn(v, (v1, k1) => {
        apis[k1] = v1;
      });
    });

    return apis;
  }
github cam-inc / viron / src / components / viron-parameters / util.js View on Github external
const generateDefaultProperties = (schemaObject, val = {}) => {
  const properties = schemaObject.properties;
  const required = schemaObject.required || [];
  forOwn(properties, (property, key) => {
    if (contains(['boolean', 'integer', 'number', 'null', 'string'], property.type)) {
      if (!isUndefined(val[key])) {
        return;
      }
      if (isUndefined(property.default)) {
        return;
      }
      val[key] = property.default;
    }
    if (property.type === 'object') {
      if (!contains(required, key)) {
        return;
      }
      val[key] = {};
      generateDefaultProperties(property, val[key]);
    }
github js-data / js-data-schema / lib / utils.js View on Github external
parallel(tasks, cb) {
    var results = {};
    var completed = 0;
    var length = 0;

    forOwn(tasks, () => {
      length += 1;
    });


    forOwn(tasks, function (task, key) {
      task(function (err) {
        var args = Array.prototype.slice.call(arguments, 1);
        if (args.length <= 1) {
          args = args[0];
        }
        results[key] = args;
        done(err);
      });
    });

    function done(err) {
      completed += 1;
      if (err || completed >= length) {
        cb(err, results);
      }
    }
github cam-inc / viron / src / components / organisms / viron-component / table.js View on Github external
forEach(parameterObjects, parameterObject => {
      const name = parameterObject.name;
      if (parameterObject.in === 'body') {
        queries[name] = {};
        forOwn(parameterObject.schema.properties, (v, k) => {
          if (rowData[k]) {
            queries[name][k] = rowData[k];
          }
        });
      } else {
        if (!rowData[name]) {
          return;
        }
        queries[name] = rowData[name];
      }
    });
github cam-inc / viron / src / store / mutations / endpoints.js View on Github external
mergeAll: (state, endpoints) => {
    const version = state.application.version;
    let modifiedEndpoints = ObjectAssign({}, state.endpoints[version]);

    forOwn(endpoints, endpoint => {
      let duplicatedEndpoint = find(modifiedEndpoints, val => {
        return endpoint.url === val.url;
      });

      if (!duplicatedEndpoint) {
        const key = shortid.generate();
        endpoint.key = key;
        modifiedEndpoints[key] = endpoint;
      } else {
        ObjectAssign(duplicatedEndpoint, endpoint);
      }
    });

    modifiedEndpoints = putEndpointsInOrder(modifiedEndpoints);
    state.endpoints[version] = modifiedEndpoints;
    storage.set('endpoints', state.endpoints);