{"name":"object-path-immutable","version":"3.1.1","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"},"license":"MIT","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 && mocha test.js","coveralls":"nyc npm test && nyc report --reporter=text-lcov | coveralls","coverage":"nyc npm test","prepublish":"npm run coverage","standard-fix":"standard --fix"},"dependencies":{"is-plain-object":"3.0.0"},"devDependencies":{"chai":"^4.2.0","coveralls":"^3.0.4","nyc":"^14.1.1","mocha":"^6.1.4","mocha-lcov-reporter":"^1.3.0","rollup":"^1.16.2","rollup-plugin-commonjs":"^10.0.1","rollup-plugin-node-resolve":"^5.1.0","standard":"^12.0.1"},"keywords":["deep","path","access","get","property","dot","prop","object","obj","notation","segment","value","nested","key","immutable","immutability","react","redux","state"],"standard":{"ignore":["dist"]},"gitHead":"42102eabbed95cd487b3bc5c46a6393252f58759","bugs":{"url":"https://github.com/mariocasciaro/object-path-immutable/issues"},"_id":"object-path-immutable@3.1.1","_nodeVersion":"10.14.0","_npmVersion":"6.7.0","dist":{"integrity":"sha512-NZDdPo/DEufre4+CyYZ7j6YQnWvKWnnGS+VS7dVd9M6WNcvFfnR4mW1lmakg9eCABAeE+PZW3bN/ZUTL8063IQ==","shasum":"93668def1fd70c82d8fc3aad5caf2d7dd55b97b5","tarball":"http://registry-npm.ywwl.com/object-path-immutable/download/object-path-immutable-3.1.1.tgz","fileCount":10,"unpackedSize":36881,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdFN9SCRA9TVsSAnZWagAAwxMP/1WKg05myKKNfCdaEE23\nbP34kKMsYIUViq7gq/VNwM5Bu39SspLlF6xCkXqcoIaVOYNo+zdhhD2fOyVX\nQNS+q1YDG6EW7DkP1FpyPoRiCWdWEK8BuFAmme5YfE1Pw5Cvmui3I13VHaEQ\ntVOdpcLBR4mGIKumsFfmVa/ir7aRr6AZsXmy8hknBlFgr+iek/w0yF38cGOe\nh3euxi/+WSn2Mp8e65mDr3NFc11QMXr+jLkg8RGHHvaFDytFtI2YVng9pi9h\nA0xbekEQRF+K2kjd4g68whG1b8IscH0TTSRsPzhmYiuZgjo6m8qNSj3y94lp\ney3OU0cVN9/0HKRfmgtLgj2a1lW4pbfzwyZA8V3Amkb1YOdftFyLOEiipfMF\nWlmqnVnuEKhfHR87CPYqT826IsMZ/TaE6VhVhKc+/h7XFAs+hIElV6cZu+cA\nShln7CiWXG02K8rudcwDg7MLmOy+XS6nI+7249TgvPBU6xr8CgAj7ucMMwJi\nPq5NIZlQXa3/WJEXgTo7YRsCh0l2dPrNe4DpFCEX0WPhWaPqQAP+PgkHRNkf\nC3pnvjP1tMe7eMTbHg1Dp2UrbGZhImAJZrFG28iT4Q/Hqi9idqNCmsUHLxBd\nSujVEPw+D07Jj7yg3/1uXHhHQRVp+QwL6V5aK3B5Ecdnu9v0hIJj30H1D38j\nO/lk\r\n=1Vip\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE4D4OEtJkOCL3jRoAk8SnffdPIfsATIHDAI7aYRzv02AiA1o0seAca3rSL1lIdUJcKF06tgP49XwIszfzy7ee/ieg=="}],"size":8785,"noattachment":false,"key":"/object-path-immutable/-/object-path-immutable-3.1.1.tgz"},"maintainers":[{"name":"mariocasciaro","email":"contact@mariocasciaro.me"}],"_npmUser":{"name":"mariocasciaro","email":"m@mario.fyi"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/object-path-immutable_3.1.1_1561648978027_0.8409280327198154"},"_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":1561648978117,"_cnpm_publish_time":1561648978117,"dist-tags":{"latest":"4.1.2"}}