Makeify
Makeify is a utility to create deeply nested objects from paths. Similar to lodash's _.set
. Makeify uses ES6 proxies to enable a convenient syntax.
How to use
// Create a new objectconst value = deeplynested1'a value'; // === { deeply: { nested : [undefined, 'a value '] } } // Mutate an existing objectconst obj = key: 'value' // obj === { key: 'value', key2: 'value 2'}
Browser and server support
ES6 Proxies are currently supported by the latest stable version of Chrome, Firefox and Edge. It is not supported by Node 5.x or Safari yet.
ES6 compatibility table: Proxy
Install
npm install makeify
API
makeify().any.path['here'][3](optionalValue)
The path is any valid javascript property path.
Returns an object matching the path with the final property being set to the optionalValue
makeify(object).any.path['here'][3](optionalValue)
Mutates object
and adds the path to it.
Returns the object
with added properties.