How to use the dot-prop.set function in dot-prop

To help you get started, we’ve selected a few dot-prop 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 zaaack / ELaunch / app / config / index.js View on Github external
write(key, value) {
    dotDrop.set(rawConfig, key, value)
    writeConfig()
  },
  set(key, value) { // write with emit event
github wordup-dev / wordup-cli / src / lib / project.js View on Github external
if (fs.existsSync(this.getProjectPath('.wordup','config.yml'))) {

      try {
        this.dotWordupYml = YAML.parseDocument(fs.readFileSync(this.getProjectPath('.wordup','config.yml'), 'utf8'))
        this.dotWordupJson = this.dotWordupYml.toJSON()
      } catch (err) {
        this.error('Could not parse wordup config: '+err, {exit:1})
      }

      // Create the slug as a name. Because it could be also a path
      const slug = this.wPkg('slug')
      if(slug){
        if (slug.lastIndexOf('/') !== -1) {
          dotProp.set(this.dotWordupJson, 'slugName', slug.substring(0, slug.lastIndexOf('/')))
        } else {
          dotProp.set(this.dotWordupJson, 'slugName', slug)
        }
      }

      // Get config based on the current path
      this.config = this._wordupConfigstore.get('projects.' + this.projectId)

      //Set docker-compose files
      if (fs.existsSync(this.getProjectPath('docker-compose.yml'))) {
        // If there is a local docker-compose.yml file, extend it
        composerFiles += seperator + this.getProjectPath('docker-compose.yml') 
      }
    }

    //Set env which are the same for each project
    shell.env.COMPOSE_FILE = composerFiles
github Nicklason / tf2-automatic / app / handler / commands.js View on Github external
let value = params[key];

            if (key !== 'sku') {
                if (/^\d+$/.test(value)) {
                    value = parseInt(value);
                } else if (/^\d+(\.\d+)?$/.test(value)) {
                    value = parseFloat(value);
                } else if (value === 'true') {
                    value = true;
                } else if (value === 'false') {
                    value = false;
                }
            }

            dotProp.set(parsed, key.trim(), value);
        }
    }

    return parsed;
}
github sindresorhus / conf / index.js View on Github external
const set = (key, value) => {
			checkValueType(key, value);
			if (this._options.accessPropertiesByDotNotation) {
				dotProp.set(store, key, value);
			} else {
				store[key] = value;
			}
		};
github omenking / swap-n-pop / src / common / store.ts View on Github external
set(key, val) {
		if (typeof key !== 'string' && typeof key !== 'object')
			throw new TypeError(`Expected \`key\` to be of type \`string\` or \`object\`, got ${typeof key}`)

		const data = this.data

		if (typeof key === 'object') {
			for (const k of Object.keys(key)) {
				DotProp.set(data, k, key[k])
			}
    } else {
			DotProp.set(data, key, val)
    }

		this.data = data
	}
	has(key) {
github vadimdemedes / mongorito / lib / model.js View on Github external
Model.prototype.set = function (key, value) {
	if (typeof key !== 'object' && typeof key !== 'string') {
		throw new TypeError(`Expected \`key\` to be string or object, not ${typeof key}`);
	}

	const fields = {};

	if (typeof key === 'object') {
		Object.assign(fields, key);
	} else {
		dotProp.set(fields, key, value);
	}

	this.store.dispatch(set(fields));
};
github sindresorhus / conf / index.js View on Github external
_set(key, value) {
		const {store} = this;
		dotProp.set(store, key, value);

		this.store = store;
	}
github liferay / liferay-js-toolkit / packages / generator-liferay-bundle / src / utils / modifier / features / settings.json.js View on Github external
this.modifyJson(json => {
			prop.set(json, `fields.${id}.type`, type);
			if (name) {
				prop.set(json, `fields.${id}.name`, name);
			}
			if (description) {
				prop.set(json, `fields.${id}.description`, description);
			}
			if (required) {
				prop.set(json, `fields.${id}.required`, required);
			}
			if (defaultValue) {
				prop.set(json, `fields.${id}.default`, defaultValue);
			}
			if (options) {
				prop.set(json, `fields.${id}.options`, options);
			}
		});
	}
github liferay / liferay-js-toolkit / packages / generator-liferay-bundle / src / utils / modifier / features / settings.json.js View on Github external
this.modifyJson(json => {
			prop.set(json, `fields.${id}.type`, type);
			if (name) {
				prop.set(json, `fields.${id}.name`, name);
			}
			if (description) {
				prop.set(json, `fields.${id}.description`, description);
			}
			if (required) {
				prop.set(json, `fields.${id}.required`, required);
			}
			if (defaultValue) {
				prop.set(json, `fields.${id}.default`, defaultValue);
			}
			if (options) {
				prop.set(json, `fields.${id}.options`, options);
			}
		});

dot-prop

Get, set, or delete a property from a nested object using a dot path

MIT
Latest version published 3 months ago

Package Health Score

80 / 100
Full package analysis