How to use the dot-object.dot function in dot-object

To help you get started, we’ve selected a few dot-object 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 cult-of-coders / grapher / lib / query / reducers / lib / createReducers.js View on Github external
export function handleAddField(fieldName, body, root) {
    if (_.contains(specialFields, fieldName)) {
        root.addProp(fieldName, body);

        return;
    }

    if (_.isObject(body)) {
        // if reducer specifies a nested field
        // if it's a prop
        const dots = dot.dot({
            [fieldName]: body
        });

        _.each(dots, (value, key) => {
            addFieldIfRequired(root, key, value);
        });
    } else {
        // if reducer does not specify a nested field, and the field does not exist.
        addFieldIfRequired(root, fieldName, body);
    }
}
github Aluminati / meteor-react-autoform / src / autoform.js View on Github external
getDocumentValue(fieldName)
  {
    if(this.doesDocumentValueExist(fieldName))
    {
      let doc = {};
      Dot.copy(fieldName, fieldName, this.props.doc, doc);
      doc = Dot.dot(doc);

      // If it's a number
      if(!isNaN(parseFloat(doc[fieldName])) && isFinite(doc[fieldName]))
      {
        // Return it as a String
        return doc[fieldName].toString();
      }

      return doc[fieldName];
    }

    return false;
  }
github Aluminati / meteor-react-autoform / src / autoform.js View on Github external
Object.keys(this.props.schema).map(fieldName =>
    {
      if(typeof state[`${fieldName}_fieldValue`] !== 'undefined' &&
        !(this.props.type === 'insert' && state[`${fieldName}_fieldValue`] === '') &&
        this.getDocumentValue(fieldName) !== this.getStateOrDefaultSchemaValue(fieldName, null, null, state))
      {
        formFields[fieldName] = this.getStateOrDefaultSchemaValue(fieldName, null, null, state); // Gets the state value

        if(fieldName.indexOf('.') > 0) // If this fieldName belongs to object
        {
          let fieldNameObj = Dot.object(Object.assign({}, {[fieldName]: formFields[fieldName]})), // Get the entire object
            // schemaKey = fieldName.substr(0, fieldName.lastIndexOf('.')); // Get the parent object key
            schemaKey = fieldName.substr(0, fieldName.indexOf('.')); // Get the parent object key

          Dot.copy(schemaKey, schemaKey, this.props.doc, fieldNameObj); // Copy the original object
          formFields = {...Dot.dot(fieldNameObj), ...formFields}; // Turn the original object into dotted object and then merge it with the new fieldName value
        }
      }
    });
github orionjs / orionjs / packages / schema / src / getValidationErrors / getValidationErrorsObject.js View on Github external
export default function(validationErrors) {
  if (validationErrors.length === 0) return null

  const errors = {}

  for (const validationError of validationErrors) {
    errors[validationError.key] = validationError.code
  }

  return dot.dot(errors)
}
github pixari / vue-i18n-extract / src / library / file-operations-language.ts View on Github external
return languageFiles.reduce((accumulator, file) => {
    const language = file.fileName.substring(file.fileName.lastIndexOf('/') + 1, file.fileName.lastIndexOf('.'));

    const flattenedObject = dot.dot(file.content);
    const i18nInFile = Object.keys(flattenedObject).map((key, index) => {
      return {
        line: index,
        path: key,
        file: file.fileName,
      };
    });

    accumulator[language] = i18nInFile;
    return accumulator;
  }, {});
}
github streamplace / streamplace / packages / sp-configuration / src / sk-config-server.js View on Github external
config.loadValuesFile = function(valuesPath) {
  const doc = yaml.safeLoad(fs.readFileSync(valuesPath, "utf8"));
  const flat = dot.dot(doc);
  Object.keys(flat).forEach(key => {
    const capitalKey = key
      .replace(/([A-Z])/g, "_$1")
      .toUpperCase()
      .replace(/\./g, "_")
      .replace(/^GLOBAL_/, "");
    this[capitalKey] = flat[key];
  });
};
github cult-of-coders / grapher / lib / query / lib / intersectDeep.js View on Github external
export default function (allowedBody, clientBody) {
    const allowedBodyDot = _.keys(dot.dot(allowedBody));
    const clientBodyDot = _.keys(dot.dot(clientBody));

    const intersection = _.intersection(allowedBodyDot, clientBodyDot);

    const build = {};
    intersection.forEach(intersectedField => {
        build[intersectedField] = 1;
    });

    return dot.object(build);
}

dot-object

dot-object makes it possible to transform and read (JSON) objects using dot notation.

MIT
Latest version published 9 days ago

Package Health Score

70 / 100
Full package analysis