{"name":"object-path-immutable","version":"3.0.0","description":"Modify deep object properties without modifying the original object (immutability). Works great with React and Redux.","author":{"name":"Mario Casciaro","email":"m@mario.fyi"},"homepage":"https://github.com/mariocasciaro/object-path-immutable","repository":{"type":"git","url":"git://github.com/mariocasciaro/object-path-immutable.git"},"types":"./object-path-immutable.d.ts","engines":{"node":">=0.10.0"},"main":"index.js","scripts":{"build":"rollup -c","pretest":"standard","test":"npm run build && istanbul cover _mocha test.js --report html -- -R spec","prepublish":"npm run test"},"dependencies":{"is-plain-object":"^2.0.4"},"devDependencies":{"chai":"^3.5.0","coveralls":"^2.11.14","istanbul":"^0.4.5","mocha":"^3.1.1","mocha-lcov-reporter":"^1.2.0","rollup":"^0.61.1","rollup-plugin-commonjs":"^9.1.3","rollup-plugin-node-resolve":"^3.3.0","standard":"^8.3.0"},"keywords":["deep","path","access","get","property","dot","prop","object","obj","notation","segment","value","nested","key","immutable","immutability","react","redux","state"],"standard":{"ignore":["dist"]},"gitHead":"ed50e9ca8ca69c57ba4f43a5b1d1b3b081f77e21","bugs":{"url":"https://github.com/mariocasciaro/object-path-immutable/issues"},"_id":"object-path-immutable@3.0.0","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"mariocasciaro","email":"contact@mariocasciaro.me"},"dist":{"integrity":"sha512-T/KtAbX2oNH6gjJdkI7kXxEh9W+Zyt/Cie+XXW8HkzpKFO8bKtI+jOldyGHkxJu0FzGWWYlcbPh3zVh2GY0+qg==","shasum":"c242a7e6648c64e37bd9f363bbf2fb91ced69ff5","tarball":"http://registry-npm.ywwl.com/object-path-immutable/download/object-path-immutable-3.0.0.tgz","fileCount":10,"unpackedSize":36211,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbK/ruCRA9TVsSAnZWagAAGAMP/jpXGFEp4Osvwi05Lyyt\nDqLVHEJiORQIeA/JEJRlrIVv/Z2/zHxyJRmoeeNaKH4freDJNasob+PO9VRW\nU4Hi+y6SGEI/Qn9iliYOGBemCl8xpcPD/6SsUWZkVCdyMB9SIkANGKGJpzZH\ndlLBAt4pmATmquWuQzrzFwiiGV8mfiBoonujbrlGIrgGfSD82x8p//QsZTnK\nUAJWWstDdJnvX0N9G/fdf3YX89szVh4Eeraij5YA+D2E4rTC9AgptdESy4aO\nxNo4jh2oyIKgxCRXM7vUX+OGtNJw9MbOP0lm4r/NMgjvtdKqN09/Uu3e2HiD\nZeTXLZug4sLruKV0gTTS1mSOg/71pYg6j0R6jf1YRzr1RZDtG2mIqhueBcQw\nsn9GtD8CjJ7HiojRw4K3SGviWqTe+ipiia9EF6aGV0zjmpIaWxc5NV2kUrQU\nOjzxkfFdeePXyV0uRzQic27FZSYOuwSSDggFYuhfxdNoeUut8spjGbBtvHdA\nZ8NsN/cHl+cb0IbgxuEm13Rgq+Xb7ITVV43UwIK1aEx0wRL4/31Vom0+4bKZ\nWoMsvfgBAkgeSMLmtkSrnzfEkRJV4tvN4yhsTpe3u2Zs170BHFrWq7iZ7Xdo\nlf8EDts8APCY6VwaqFcvpPITgPD5DtXKYIs/9efRR5HqEGifTOPRfvAfv9La\nuNAp\r\n=rZV9\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDcglMXaLtoVGREkp6JVYESj4iRqNfV12gf9kCI9bOG3wIgWSj4NtBMnrAGO1DGRE9eHaxMWKYWa6OjFs5YK1y7/Qs="}],"size":8208,"noattachment":false,"key":"/object-path-immutable/-/object-path-immutable-3.0.0.tgz"},"maintainers":[{"name":"mariocasciaro","email":"contact@mariocasciaro.me"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/object-path-immutable_3.0.0_1529608942200_0.4611579915424875"},"_hasShrinkwrap":false,"readme":"[![build](https://img.shields.io/travis/mariocasciaro/object-path-immutable.svg?style=flat-square)](https://travis-ci.org/mariocasciaro/object-path-immutable)\n[![coverage](https://img.shields.io/coveralls/mariocasciaro/object-path-immutable.svg?style=flat-square)](https://coveralls.io/r/mariocasciaro/object-path-immutable)\n[![downloads](https://img.shields.io/npm/dm/object-path-immutable.svg?style=flat-square)](https://www.npmjs.com/package/object-path-immutable)\n[![version](https://img.shields.io/npm/v/object-path-immutable.svg?style=flat-square)](https://www.npmjs.com/package/object-path-immutable)\n[![deps](https://img.shields.io/david/mariocasciaro/object-path-immutable.svg?style=flat-square)](https://david-dm.org/mariocasciaro/object-path-immutable)\n[![devdeps](https://img.shields.io/david/dev/mariocasciaro/object-path-immutable.svg?style=flat-square)](https://david-dm.org/mariocasciaro/object-path-immutable#info=devDependencies)\n\nobject-path-immutable\n===========\n\nTiny JS library to modify deep object properties without modifying the original object (immutability).\nWorks great with React (especially when using `setState()`) and Redux (inside a reducer).\n\nThis can be seen as a simpler and more intuitive alternative to the *React Immutability Helpers* and *Immutable.js*.\n\n## Changelog\n\n[View Changelog](CHANGELOG.md)\n\n## Install\n\n    npm install object-path-immutable --save\n\n## Quick usage\n\nThe following, sets a property without modifying the original object.\nIt will minimize the number of clones down the line. The resulting object is just a plain JS object literal,\nso be warned that it will not be protected against property mutations (like `Immutable.js`)\n\n```javascript\nconst obj = {\n  a: {\n    b: 'c',\n    c: ['d', 'f']\n  }\n}\n\nconst newObj = immutable.set(obj, 'a.b', 'f')\n// {\n//   a: {\n//     b: 'f',\n//     c: ['d', 'f']\n//   }\n// }\n\n// obj !== newObj\n// obj.a !== newObj.a\n// obj.a.b !== newObj.a.b\n\n// However:\n// obj.a.c === newObj.a.c\n```\n\n### Wrap mode\n\nYou can also chain the api's and call `value()` at the end to retrieve the resulting object.\n\n```javascript\nconst newObj = immutable.wrap(obj).set('a.b', 'f').del('a.c.0').value()\n```\n\n## API\n\n```javascript\n// Premises\n\nconst obj = {\n  a: {\n    b: 'c',\n    c: ['d', 'f']\n  }\n}\n\nimport * as immutable from 'object-path-immutable'\n```\n\n#### set (initialObject, path, value)\n\nChanges an object property.\n\n- Path can be either a string or an array.\n\n```javascript\nconst newObj1 = immutable.set(obj, 'a.b', 'f')\nconst newObj2 = immutable.set(obj, ['a', 'b'], 'f')\n\n// {\n//   a: {\n//     b: 'f',\n//     c: ['d', 'f']\n//   }\n// }\n\n// Note that if the path is specified as a string, numbers are automatically interpreted as array indexes.\n\nconst newObj = immutable.set(obj, 'a.c.1', 'fooo')\n// {\n//   a: {\n//     b: 'f',\n//     c: ['d', 'fooo']\n//   }\n// }\n```\n\n#### update (initialObject, path, updater)\n\nUpdates an object property.\n\n```javascript\nconst obj = {\n  a: {\n    b: 1\n  }\n}\n\nconst newObj = immutable.update(obj, ['a', 'b'], v => v + 1)\n\n// {\n//   a: {\n//     b: 2,\n//   }\n// }\n```\n\n#### push (initialObject, path, value)\n\nPush into a deep array (it will create intermediate objects/arrays if necessary).\n\n```javascript\nconst newObj = immutable.push(obj, 'a.d', 'f')\n// {\n//   a: {\n//     b: 'f',\n//     c: ['d', 'f'],\n//     d: ['f']\n//   }\n// }\n```\n\n#### del (initialObject, path)\n\nDeletes a property.\n\n```javascript\nconst newObj = immutable.del(obj, 'a.c')\n// {\n//   a: {\n//     b: 'f'\n//   }\n// }\n```\n\nCan also delete a deep array item using splice\n\n```javascript\nconst newObj = immutable.del(obj, 'a.c.0')\n// {\n//   a: {\n//     b: 'f',\n//     c: ['f']\n//   }\n// }\n```\n\n#### assign (initialObject, path, payload)\n\nShallow copy properties.\n\n```javascript\nconst newObj = immutable.assign(obj, 'a', { b: 'f', g: 'h' })\n// {\n//   a: {\n//     b: 'f',\n//     c: ['d, 'f'],\n//     g: 'h'\n//   }\n// }\n```\n\n#### insert (initialObject, path, payload, position)\n\nInsert property at the specific array index.\n\n```javascript\nconst newObj = immutable.insert(obj, 'a.c', 'k', 1)\n// var obj = {\n//   a: {\n//     b: 'c',\n//     c: ['d, 'k' 'f'],\n//   }\n// }\n```\n\n\n#### merge (initialObject, path, value)\n\nDeep merge properties.\n\n```javascript\nconst newObj = immutable.merge(obj, 'a.c', {b: 'd'})\n```\n\n### Getters (not available in wrap mode)\n\n#### get (object, path, defaultValue)\n\nRetrieve a deep object property. Imported from [object-path](https://github.com/mariocasciaro/object-path) for convenience.\n\n## Equivalent library with side effects\n\n[object-path](https://github.com/mariocasciaro/object-path)\n\n","publish_time":1529608942300,"_cnpm_publish_time":1529608942300,"dist-tags":{"latest":"4.1.2"}}