makeify

0.1.0 • Public • Published

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.

NPM Version Build Status Dependency Status devDependency Status

How to use

import makeify from 'makeify'
 
// Create a new object
const value = makeify().deeply.nested[1]('a value'); //  === { deeply: { nested : [undefined, 'a value '] } }
 
// Mutate an existing object
const obj = { key: 'value' }
makeify(obj).key2('value 2') // 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.

Package Sidebar

Install

npm i makeify

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • johnste