How to use the dot-object.copy 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 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 / form.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 / form.js View on Github external
doesDocumentValueExist(fieldName)
  {
    const doc = {};
    Dot.copy(fieldName, fieldName, this.props.doc, doc);

    // If we're updating an existing document and the value exists here
    return this.props.type === 'update' && typeof doc !== 'undefined' && doc !== null;
  }
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 Aluminati / meteor-react-autoform / src / form.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 Aluminati / meteor-react-autoform / src / autoform.js View on Github external
doesDocumentValueExist(fieldName)
  {
    const doc = {};
    Dot.copy(fieldName, fieldName, this.props.doc, doc);

    // If we're updating an existing document and the value exists here
    return this.props.type === 'update' && typeof doc !== 'undefined' && doc !== null;
  }
github Azure / pcs-remote-monitoring-webui / src / utilities / methods.js View on Github external
  return Object.keys(model).reduce((acc, key) => dot.copy(key, model[key], response, acc), {});
};

dot-object

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

MIT
Latest version published 8 days ago

Package Health Score

70 / 100
Full package analysis