How to use the dot-object.str 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 origami-cms / cms / packages / core-lib / src / configFile.ts View on Github external
let _obj: Partial | boolean = obj;
        // If the variable is a plugin setting that is contained in aliases
        // Then update the config via the filename not the alias
        const res = /plugins\.([\w-]+)/.exec(key);
        if (res && aliases.plugins[res[1]]) {
          _key = key
            .split('.')
            .slice(2)
            .join('.');
          _obj = obj.plugins![aliases.plugins[res[1]]];
        }

        // Try set the key, however current value may be a boolean or undefined
        // meaning that deeper keys may throw error. If that's the case,
        // then set the value to an empty object, and try again
        dot.str(_key, value, _obj);
      });
github DJanoskova / React-validator-demo / src / utils / validator.js View on Github external
const { checked } = target;
    let newValue;

    const index = oldValue.indexOf(value);
    if (checked && index < 0) {
      newValue = [...oldValue, value]
    } else if (!checked && index > -1) {
      newValue = oldValue.filter(v => v !== value);
    }

    // using dot helps us change nested values
    let data;
    const isNested = name.includes('.');
    if (isNested) {
      dot.override = true;
      data = dot.str(name, newValue, { ...formData });
    } else {
      data = { ...formData, [name]: newValue };
    }

    setChecked(checked);
    setFormData(data);
  }, [value, formData, setFormData, name]);
github MitocGroup / recink / src / component / npm / events.js View on Github external
].map(eventPath => {
  dot.str(eventPath, eventPath, events);
  
  return eventPath;
});
github MitocGroup / recink / bin / commands / run / generic.js View on Github external
function setTfParameter(parameter, value, root = '$') {
    dot.str(`${root}.terraform.${parameter}`, value.constructor === String ? trimBoth(value, '"') : value, cfg);
  }
github MitocGroup / recink / src / container.js View on Github external
set(path, value) {
    dot.str(path, value, this._config);
    
    return this;
  }
github MitocGroup / recink / src / events.js View on Github external
].map(eventPath => {
  dot.str(eventPath, eventPath, events);
  
  return eventPath;
});
github MitocGroup / recink / bin / commands / run / generic.js View on Github external
let key = workspaceEnabled ? `available-workspaces.${tfWorkspace}.var-files` : 'var-files';
        setTfParameter(key, tfVarfiles, cfgKey);
      }

      for (let property in tfVars) {
        if (tfVars.hasOwnProperty(property)) {
          let key = workspaceEnabled ? `available-workspaces.${tfWorkspace}.vars` : 'vars';
          setTfParameter(`${key}.${property}`, tfVars[property], cfgKey);
        }
      }
    });

    let customConfig = optionsToObject(options.customConfig);
    for (let property in customConfig) {
      if (customConfig.hasOwnProperty(property)) {
        dot.str(property, customConfig[property], cfg);
      }
    }

    return Promise.resolve(cfg);
  }
github MitocGroup / recink / src / component / coverage / events.js View on Github external
].map(eventPath => {
  dot.str(eventPath, eventPath, events);
  
  return eventPath;
});
github MitocGroup / recink / bin / commands / run / generic.js View on Github external
function transformConfig(config) {
    cfg = config;

    if (options.sync) {
      dot.str('$.cnci.sync', true, cfg);
    }

    let { modules, filtered } = parseModules(cfg);
    let workspaceEnabled = false;
    let tfModules = modules.filter(module => typeof dot.pick(`${module}.terraform`, cfg) !== 'undefined');

    tfModules.forEach(module => {
      let tfVars = optionsToObject(options.tfVars);
      let tfVarfiles = _arr(options.tfVarfiles);
      let tfWorkspace = options.tfWorkspace;
      let cfgKey = filtered ? module : ConfigBasedComponent.MAIN_CONFIG_KEY;

      if (options.tfVersion) {
        setTfParameter('version', options.tfVersion, cfgKey);
      }

dot-object

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

MIT
Latest version published 8 months ago

Package Health Score

63 / 100
Full package analysis