New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

object-path-set

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-path-set

set values in javascript objects by specifying a path

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

object-path-set

NPM version Build Status Code Climate Coverage Status Dependency Status devDependency Status

NPM

Description

set values in javascript objects by specifying a path.

if the path doesn't exist yet, it will be created.

by using this library, you can help prevent the following error from occurring:

Cannot set property 'foo' of undefined

NOTE: I've re-written / used this function so many different times, I decided to publish it as a module.

Getting Started

Install the module with: npm install --save object-path-set

var setPath = require('object-path-set');
var obj = { foo: { bar: 'baz' } };
obj = setPath(obj, 'foo.bar', 'newValue'); // result: {foo:{bar:'newValue'}}
obj = setPath(obj, 'foo.invalidKey', 'cool'); // result: {foo:{bar:'newValue',invalidKey: 'cool'}}
obj = setPath(obj, 'foo|bar', 'again', '|'); // result: {foo:{bar:'again',invalidKey: 'cool'}}

Contributors

Thanks goes to these wonderful people (emoji key):



💻 📖

This project follows the all-contributors specification. Contributions of any kind welcome!

License

Copyright (c) 2014 skratchdot
Licensed under the MIT license.

Keywords

object

FAQs

Package last updated on 30 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts