{"_id":"simple-update-in","_rev":"69-bce6dcd11b4838e9b7a584eb300bc3e5","name":"simple-update-in","dist-tags":{"master":"2.2.1-master.88426b2","latest":"2.2.0"},"versions":{"1.0.0-master.a992290":{"name":"simple-update-in","version":"1.0.0-master.a992290","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","dependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1"},"devDependencies":{"gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"a9922908a0e652c6771c2f1b8206b997085ce0ce","_id":"simple-update-in@1.0.0-master.a992290","_npmVersion":"5.6.0","_nodeVersion":"9.8.0","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-lpb48WWI4gSOexdgr/f1Yhl7VckBuIUKBCARLp01i98Q8r2SP6zDQWI3rKf7CK0MYASbijYoQ2gMMyVtKDzKYQ==","shasum":"c37791e069bd2f45d6d137963c1b726f9674cdc4","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.0.0-master.a992290.tgz","fileCount":9,"unpackedSize":12450,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIATQq1ldBm2vtedV9lk1ReNq4b8PPQwEogjJ1pVfWn6QAiEA3CgFmqWmX9TunPW20gWMfqOyOeOddXpZKEHXLjTNNCg="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.0.0-master.a992290_1521515115453_0.913531154832258"},"_hasShrinkwrap":false},"1.0.0-master.5a2f0ab":{"name":"simple-update-in","version":"1.0.0-master.5a2f0ab","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","dependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1"},"devDependencies":{"gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"5a2f0ab60462ec462a0ef5a1ad93e1a873ca085f","readme":"# simple-update-in [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nA lightweight `updateIn` for immutable objects.\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the cover, we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn(target: Array|Map, path: (Number|String)[], updater?: (value: any) => any)\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n## How about adding an item in an array?\n\nAdding an item in an array is different than \"upsert\"-ing in a map. As we want to keep the learning curve very low, thus, we don't want to introduce syntax to do the insertion.\n\nYou can use the following code to insert an item with Rest Operator:\n\n```js\nconst from = { numbers: ['zero', 'one'] };\nconst actual = updateIn(from, ['numbers'], array => [...array, 'two']);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.0.0-master.5a2f0ab","_npmVersion":"5.6.0","_nodeVersion":"9.8.0","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-FLs6kJ02ZgZ/7FeUdnEWI3QPvN9cvsbST/S4qvDH01oufKi/v56IiueImYypd7+b+fAK8889K/tJcVR93slTKw==","shasum":"e8875a92ce8f8621ed3d709c0a65350c36987add","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.0.0-master.5a2f0ab.tgz","fileCount":9,"unpackedSize":12584,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHweo+ww8CQsds7Ag47aZlX6VRC8F45zQ1eMX+4h2fYGAiBVC6t+NM1AyxYs5fx+s4s1aE9PdwF9FCQn4H01+6cdgA=="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.0.0-master.5a2f0ab_1521517840449_0.9128537312308631"},"_hasShrinkwrap":false},"1.0.0-master.09af2f4":{"name":"simple-update-in","version":"1.0.0-master.09af2f4","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","dependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1"},"devDependencies":{"gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"09af2f4f3ca5de3f1c5a8140a80b4aab9df653ab","readme":"# simple-update-in [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nA lightweight `updateIn` for immutable objects.\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn(target: Array|Map, path: (Number|String)[], updater?: (value: any) => any)\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n## How about adding an item in an array?\n\nAdding an item in an array is different than \"upsert\"-ing in a map. As we want to keep the learning curve very low, thus, we don't want to introduce syntax to do the insertion.\n\nYou can use the following code to insert an item with Rest Operator:\n\n```js\nconst from = { numbers: ['zero', 'one'] };\nconst actual = updateIn(from, ['numbers'], array => [...array, 'two']);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.0.0-master.09af2f4","_npmVersion":"5.6.0","_nodeVersion":"9.8.0","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-yCMpotP5iDGTOS8VUXn9M1E8sgJWEsRgEm7PUVxNcy+2eLWlxXDki1IEBShsIVaFSWxNQL36/WO0pUpL1yac4w==","shasum":"c27f6b74ae34de9aa2c34a3c040dcf2e9af99062","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.0.0-master.09af2f4.tgz","fileCount":9,"unpackedSize":12600,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDZej2xhlGiV5ZG4axgQeYdzLIxHR/JTx2VhMulFBDo1gIhANNkk5NkJOnNpl1bi/qbDhqzDrzYYJfTEUkSJ6qbGN35"}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.0.0-master.09af2f4_1521518649218_0.21289088286208613"},"_hasShrinkwrap":false},"1.0.0-master.d5e304a":{"name":"simple-update-in","version":"1.0.0-master.d5e304a","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","dependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1"},"devDependencies":{"gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"d5e304a6e2a95e4b20bf04730b7d3a414c99e3c2","readme":"# simple-update-in [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nA lightweight `updateIn` for immutable objects.\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn(\n  target: Array|Map,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n)\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n## How about adding an item in an array?\n\nAdding an item in an array is different than \"upsert\"-ing in a map. As we want to keep the learning curve very low, thus, we don't want to introduce syntax to do the insertion.\n\nYou can use the following code to insert an item with Rest Operator:\n\n```js\nconst from = { numbers: ['zero', 'one'] };\nconst actual = updateIn(from, ['numbers'], array => [...array, 'two']);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.0.0-master.d5e304a","_npmVersion":"5.6.0","_nodeVersion":"9.8.0","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-qKb/2v/DMm+1FbKqNZ4sDbE4SlPk5iXyHoQxkMtCYd1/ZcateRFtapmeLAhLwVLbfrfpJTnWWnw81KPjwGUk5A==","shasum":"ff9f3e88d5bda434a1af5da006a828ae063cfbf9","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.0.0-master.d5e304a.tgz","fileCount":9,"unpackedSize":12608,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC3kLUvX8fV/FviUKFSAO75JJXAAaDguE9yVfmjs5xlqgIgC1j8QNwytGpi9G25ciIGc+qesY5tIuNlvmTsKqP676E="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.0.0-master.d5e304a_1521567948783_0.6002681898532134"},"_hasShrinkwrap":false},"1.0.0-master.5a7d9c3":{"name":"simple-update-in","version":"1.0.0-master.5a7d9c3","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","dependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1"},"devDependencies":{"gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"5a7d9c32a68fbfab7de87e0c058326562455783f","readme":"# simple-update-in [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nA lightweight `updateIn` for immutable objects.\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn(\n  target: Array|Map,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n)\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n## How about adding an item in an array?\n\nAdding an item in an array is different than \"upsert\"-ing in a map. As we want to keep the learning curve very low, thus, we don't want to introduce syntax to do the insertion.\n\nYou can use the following code to insert an item with Rest Operator:\n\n```js\nconst from = { numbers: ['zero', 'one'] };\nconst actual = updateIn(from, ['numbers'], array => [...array, 'two']);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.0.0-master.5a7d9c3","_npmVersion":"5.6.0","_nodeVersion":"9.8.0","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-h+eGaNTzHjhyNnUfW9DFHrNMLJ6fKl60G3afQp2h5X9gBGvMgi9bXgoIRIK4QnxvT8CTu1FOGqhbIwHnQcnHNQ==","shasum":"1576d40cea09a2591dbdbdb0d021eb88340c444d","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.0.0-master.5a7d9c3.tgz","fileCount":9,"unpackedSize":12877,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHIRyPUUslSAJWjACK12WrhjWD3K6C13wjQXM3ashJIDAiBpEa5iI8p9/ZKjOUlV1irk/jR8svRC8dVNHuuZJ9kBtg=="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.0.0-master.5a7d9c3_1521572171779_0.8964722424641682"},"_hasShrinkwrap":false},"1.0.0":{"name":"simple-update-in","version":"1.0.0","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","dependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1"},"devDependencies":{"gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"51d905e0068d9a6c4b8b57f93012a87fcc62f4d7","_id":"simple-update-in@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"9.9.0","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-FoYxJLihMOCDiFBvfTxT+mzzvrP2Ex9nsAt2JyB7F0Raad6sdKLKQWgRsVfTVQwMqPTYIepz0/2grSwnOnTaXg==","shasum":"1a07a54d6e884842bf0df0396ee28e8fb2f7f664","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.0.0.tgz","fileCount":9,"unpackedSize":12862,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCxMp6BAYpjwHEQwEnGz31Kw1HD+bFsarTvCK+W5y7ePQIgZemBJABzlcDSDJ/9b6PMOe2vCuMzHBLBFlN906WLNyU="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.0.0_1521655834175_0.3562823859513202"},"_hasShrinkwrap":false},"1.0.0-master.83a0776":{"name":"simple-update-in","version":"1.0.0-master.83a0776","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","dependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1"},"devDependencies":{"gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"83a0776c7dcab7080c9739bb48caa8c75cb84cd9","readme":"# simple-update-in [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nA lightweight `updateIn` for immutable objects.\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn(\n  target: Array|Map,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n)\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n## How about adding an item in an array?\n\nAdding an item in an array is different than \"upsert\"-ing in a map. As we want to keep the learning curve very low, thus, we don't want to introduce syntax to do the insertion.\n\nYou can use the following code to insert an item with Rest Operator:\n\n```js\nconst from = { numbers: ['zero', 'one'] };\nconst actual = updateIn(from, ['numbers'], array => [...array, 'two']);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.0.0-master.83a0776","_npmVersion":"5.6.0","_nodeVersion":"9.9.0","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-Na3QBlxdA50/BF7p/OuY+6l+EfvN0lF7Pg7bWIwqlB59jga+HPOLOtMp2K1mpZnxMHHKoWWRBrslllgVKpEorw==","shasum":"1dffdb21bd69e9588b96ce00e1819b6c6017bf53","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.0.0-master.83a0776.tgz","fileCount":9,"unpackedSize":12875,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD2D5TeRC68Dki9FbBqIuduYWR6njNrmh37Hlc3GRpCAAIhAMyXUFPjK+VFusV814IRzFyCcJQS/NWzoz+oQS/gDQWi"}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.0.0-master.83a0776_1521656295916_0.5831633017065005"},"_hasShrinkwrap":false},"1.1.0-master.2981381":{"name":"simple-update-in","version":"1.1.0-master.2981381","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","dependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1"},"devDependencies":{"gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"29813819f2880f9be3557eab66b2b7aa6974209a","readme":"# simple-update-in [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nA lightweight `updateIn` for immutable objects.\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn(\n  target: Array|Map,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n)\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n## How about adding an item in an array?\n\nAdding an item in an array is different than \"upsert\"-ing in a map. As we want to keep the learning curve very low, thus, we don't want to introduce syntax to do the insertion.\n\nYou can use the following code to insert an item with Rest Operator:\n\n```js\nconst from = { numbers: ['zero', 'one'] };\nconst actual = updateIn(from, ['numbers'], array => [...array, 'two']);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.1.0-master.2981381","_npmVersion":"5.6.0","_nodeVersion":"9.9.0","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-fdhk79ei4zt6ScRLYImNdV9ULK/NdOAb52hUDZaLNhz5RAc4INcPvU04/hXr40zOzI0ziwnCRdFwk8fQ/9WVTw==","shasum":"8a7f8433cd608faf600d005f78598aec5a946d9e","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.1.0-master.2981381.tgz","fileCount":9,"unpackedSize":16009,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDaNwQcHa+qG9Ukh0N+tERpsVrraCiCMdl71YKKTye6QAIgSmay076LWe8WhBJlVwcQikzvqmSdW951P9Gz4CY1xcs="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.1.0-master.2981381_1522054809580_0.8625004171797457"},"_hasShrinkwrap":false},"1.1.0-master.2195a9f":{"name":"simple-update-in","version":"1.1.0-master.2195a9f","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","dependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1"},"devDependencies":{"gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"2195a9faa53e1dcb40f7961a541d4daf4e66dc77","readme":"# simple-update-in [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nA lightweight `updateIn` for immutable objects.\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn(\n  target: Array|Map,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n)\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.1.0-master.2195a9f","_npmVersion":"5.6.0","_nodeVersion":"9.9.0","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-/y3q7ypr1pFGRkLErpP0IRdolDNXijDaZBOKuHDz31DtDKGYubalsmWdUTFDMGopo0xtFzsnwuYN+qqSzBmn/A==","shasum":"20b5336be88db48ca47dbe9fb2c7d0747dc0053d","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.1.0-master.2195a9f.tgz","fileCount":9,"unpackedSize":16430,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDfGKereLqLHYO60SL3P37G3Tp8D9kAqEFd1rUseEgWeQIgTVyF8G/xktpCvb5P/+njwgppqoG5Zk2+kT3k0CC01uM="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.1.0-master.2195a9f_1522065948644_0.392579299564469"},"_hasShrinkwrap":false},"1.1.0-master.c718f47":{"name":"simple-update-in","version":"1.1.0-master.c718f47","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","dependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1"},"devDependencies":{"gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"c718f477f69feb5a44f0fb1d59bc0f29d8fe36eb","readme":"# simple-update-in [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nA lightweight `updateIn` for immutable objects.\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn(\n  target: Array|Map,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n)\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.1.0-master.c718f47","_npmVersion":"5.6.0","_nodeVersion":"9.9.0","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-zsbMxA/fObnRbZXTNdm0t1L5A49vsomI0wKFGMzmULXft29UoW3e6M/v9DWohu32C45qBfrWxHg+sFp9LJpdeg==","shasum":"b28dd512d1166c53e61c912c4a58c276704a4d65","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.1.0-master.c718f47.tgz","fileCount":10,"unpackedSize":17499,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIERIoJkkaK9lY6tsLzoQTgj84qvrhMqBYHwl5/6IVaO3AiEAmrrVvzlEkyMVjHLCCwBxzbDH5BMkFyrA/WL7qqym2q4="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.1.0-master.c718f47_1522116378790_0.04518996172270806"},"_hasShrinkwrap":false},"1.1.0-master.e4398e5":{"name":"simple-update-in","version":"1.1.0-master.e4398e5","description":"[![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","dependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1"},"devDependencies":{"gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"e4398e5d846b76f64ad61d47cc58cc61aac1afc9","readme":"# simple-update-in\n\n[![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nA lightweight `updateIn` for immutable objects.\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn(\n  target: Array|Map,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n)\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.1.0-master.e4398e5","_npmVersion":"5.6.0","_nodeVersion":"9.9.0","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-IfQMRx1RGGLNzngF3JI1rk8PyRMxCd0Fgh1uQMGdM00XIUxrdPCgjePLnvt3qaH1r4CE6N1FiCFLyASUm5675Q==","shasum":"4bee66b28d65df34356a1aad7c6cd9d1412c4717","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.1.0-master.e4398e5.tgz","fileCount":10,"unpackedSize":17500,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA2+OhFz/ZLeGOZt87oSblAPTwlOpjNauur3DMRlY2CUAiAf3IKtrUZLmsiw1cp9rZ/HgqkF/Y5xa6sObTZPy2tj/Q=="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.1.0-master.e4398e5_1522116440189_0.3674477035570103"},"_hasShrinkwrap":false},"1.1.0-master.247be79":{"name":"simple-update-in","version":"1.1.0-master.247be79","description":"[![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"dependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1"},"devDependencies":{"gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"247be796cb95a0fb23f2f8b751cbe1f263ae9a25","readme":"# simple-update-in\n\n[![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nA lightweight `updateIn` for immutable objects.\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn(\n  target: Array|Map,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n)\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.1.0-master.247be79","_npmVersion":"5.6.0","_nodeVersion":"9.9.0","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-3T+tz+mJNTjcgoxpcRvrpewa2F4LT4fWb1CDwRfn3wITPs4/FQeZltp2zfC6FURIsthqlLD+hE06/WyOHIeGTw==","shasum":"ae8a17414866b85b9d11b1b5384b5d6cd6f2dbcc","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.1.0-master.247be79.tgz","fileCount":10,"unpackedSize":17537,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDpQsM1gPx3fye0bGHPUqGFymgo3Ehz+37LPCYqsuVJWgIgUOsbvJoxeR2nSfbLeeXI5YB2n/HHHvEE/KzFIQ3Fh7s="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.1.0-master.247be79_1522117122807_0.02003994588200908"},"_hasShrinkwrap":false},"1.1.0":{"name":"simple-update-in","version":"1.1.0","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"dependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1"},"devDependencies":{"gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"0a870f855d2ee635eed92a5ed0729dec3d27bac2","_id":"simple-update-in@1.1.0","_npmVersion":"5.6.0","_nodeVersion":"9.10.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-xbun8pduXnLbT95z5cPyHWdQ8z0m8YYhkULa0piH2HiRxPvJXKTIzaV61GK9bHRSRwcAfo2uNaOss8SVGWSGFg==","shasum":"3064488503aeb4d0f5d084da0c450467adba85fc","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.1.0.tgz","fileCount":10,"unpackedSize":17522,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQClK+v44xsrsRo2qmrOeF/KwMmrR0JHJwB5HO2btpgRGAIgPKClKSH1pqZ/6GBHboHtNOtHciwTiyeJS1tmr4JiqaQ="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.1.0_1522539540655_0.7040806807002566"},"_hasShrinkwrap":false},"1.1.0-master.cf3945c":{"name":"simple-update-in","version":"1.1.0-master.cf3945c","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"dependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1"},"devDependencies":{"gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"cf3945cc1dbbe5a1771a24270305c267909120b0","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn(\n  target: Array|Map,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n)\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.1.0-master.cf3945c","_npmVersion":"5.6.0","_nodeVersion":"9.10.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-ikqHHcXEKYr3rEFcVN5VK648r7k9kGZdvGhfTPVSF7bgUL86jfvOwtbo3/7yX7qMZnzg0yQcao8PFicXmkcYJQ==","shasum":"010456ee4d830a74e66d5c6d1b52d0f84d9537ca","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.1.0-master.cf3945c.tgz","fileCount":10,"unpackedSize":17537,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD9M9SGfoxWxufwuExDfEGn4FxtW6AYWTo1VkYTNUYh7gIgHdiwv2HxHnyrcZ+ehcS2Rukvz6B/qDRpb+KD+Rfngsw="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.1.0-master.cf3945c_1522539552336_0.685796615583586"},"_hasShrinkwrap":false},"1.1.1-master.0b89b91":{"name":"simple-update-in","version":"1.1.1-master.0b89b91","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"dependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1"},"devDependencies":{"gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"0b89b9101bb2f557d3e2e3e615767b0658c8c534","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn(\n  target: Array|Map,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n)\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.1.1-master.0b89b91","_npmVersion":"5.6.0","_nodeVersion":"9.10.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-CXwak88UddLIeA/8KFEQxrir5+4xBDdRsiMirNFLQYD2hHNWuQNAttmfH6DUHdf7IP948GP8zxcSSMmN/L44GQ==","shasum":"7833e680b4c14f1514abef470621e705c143d0e7","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.1.1-master.0b89b91.tgz","fileCount":10,"unpackedSize":17537,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCED0W0T33MMx5fm8KGV4pRrfVhcI28XRY1sZOlIYK4hgIhALJn156zc7/S32i0Z0zM3OOLH01xiM/OTTo1ZZNotAqM"}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.1.1-master.0b89b91_1522539566176_0.2343058298817433"},"_hasShrinkwrap":false},"1.1.1":{"name":"simple-update-in","version":"1.1.1","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1","gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"a90003e7cab476364f3de4915fa2d169a47774e1","_id":"simple-update-in@1.1.1","_npmVersion":"5.6.0","_nodeVersion":"9.11.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-4uN3rCteBgRwzrKK1B59x2oGH5DSCl18KXiW5ZuFnby9SvvamV9pDL3SaFu8llBQpokSXhZ49TgJY+NBEBMYkQ==","shasum":"c9e1169f8609b7e7be7a63046e8bcd728afa1089","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.1.1.tgz","fileCount":10,"unpackedSize":17594,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF7Wi1R9dc+8JClAVpPq03wxEUHMEVvxu1j7xFn7G7AQAiEAkRX1o/sMXi3o3etMsFw+kqWVsPYYg1ZYL44o56anvyM="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.1.1_1523080322866_0.5010027969385238"},"_hasShrinkwrap":false},"1.1.2-master.cf20461":{"name":"simple-update-in","version":"1.1.2-master.cf20461","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1","gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"cf20461030575beb4821564613989f4916edd67a","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn(\n  target: Array|Map,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n)\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.1.2-master.cf20461","_npmVersion":"5.6.0","_nodeVersion":"9.11.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-e5NKdrOIdFekYgFKKdPR/vHqUtvWPkY0snFTc6FNg7JfH9ffHL4re9SQqTIlEoUuqoJ/R9aiyBQSMlj5piHkBw==","shasum":"4aede6d0e8c8642239a3d232279f75fd809814e8","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.1.2-master.cf20461.tgz","fileCount":10,"unpackedSize":17609,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBfxQMvFAJcDUXToGuQgQJkPFjywYH1kVLtUwbBxHQOfAiBB7lSMhPq9Hg4/Aailuz+KJPRlGYNdZ67J64M1NpYWVQ=="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.1.2-master.cf20461_1523080360415_0.1404967572521012"},"_hasShrinkwrap":false},"1.1.2-master.6d997fd":{"name":"simple-update-in","version":"1.1.2-master.6d997fd","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1","gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"6d997fd67cb0f6f32f193a961643686c21e60138","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn(\n  target: Array|Map,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n)\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.1.2-master.6d997fd","_npmVersion":"5.6.0","_nodeVersion":"9.11.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-OrfeV8LyISnb7tJj03goBVUZFoISUbpYxMR0fQ+4I4maHBzEoNXIZ4vY86xHQPF2iakcBmVjfwdlYTulW3NlcA==","shasum":"8611a70ed7cd17918cc9f1bb7194a2a001c02600","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.1.2-master.6d997fd.tgz","fileCount":10,"unpackedSize":22299,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCP9iyaeFlk2R2p+zarhOuGqkFmT1CcA1mjbQSJHmv0YgIgCtAZhMzpcySu9zL6PCKV6VeGTWzEzs4z/0DCisnkdLM="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.1.2-master.6d997fd_1523487558058_0.5449997963158835"},"_hasShrinkwrap":false},"1.1.2-master.9dfd73c":{"name":"simple-update-in","version":"1.1.2-master.9dfd73c","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1","gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"9dfd73c54af61d4dfce737a5d274afe61625f7ed","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.1.2-master.9dfd73c","_npmVersion":"5.6.0","_nodeVersion":"9.11.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-McTGiCgWEh4cCn2W5AtUptW9ZKwvXb2TuAgs+pDcetxAH/R2ojwSd7oJURu3imtfrOKd5VrCydMI/uYwyAnspw==","shasum":"e1be6f91584cf1ae2ce93dae02360330cd2025a3","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.1.2-master.9dfd73c.tgz","fileCount":10,"unpackedSize":22522,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGE/teMsNWKWCbwNynvhe2D0rmWq5bF/NZSbaU+s74X2AiA5zLz5bug67EpfoMATtjzcwg4jphUe6SSnimwCrvwCkQ=="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.1.2-master.9dfd73c_1523568184925_0.22073280786268668"},"_hasShrinkwrap":false},"1.1.2-master.a6cb16a":{"name":"simple-update-in","version":"1.1.2-master.a6cb16a","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1","gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"a6cb16a89303cafd6cc0c600ecec593f34e28117","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.1.2-master.a6cb16a","_npmVersion":"5.6.0","_nodeVersion":"9.11.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-N7aAnfiURX1UdX6Qo3NfVGOSetKdSnTKl7H2KeW706Y1aO/M4FqX6p9oKww5o+t5wWIo+XGBuqTch6qUeOb4xg==","shasum":"885c5c0486264b1879e32889f8326a1747456070","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.1.2-master.a6cb16a.tgz","fileCount":10,"unpackedSize":22547,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa0mLbCRA9TVsSAnZWagAAJbEP/RM+5fY0OBWf59051HRf\nX0O8s1+HJWqGu6YxNrEtAmfQe0pHl3KpkrSiIpyt9XV7G8EEbNr4/Pb6PJ81\ntPqv83Y8SFc13D4VvwmjuoCvymbfUGCU1zEKT9MpccH5AUkRag1qtV8qsujH\nGIFNHXu+szGdmJBzkvlMzPAqOJlTZUAnK/SRfbFg7w7j+BfipxO5o7oA1cQm\n+ynlQVsvZc6e8AwNAuJETLjQvNKBgNMQONGsqsViTs+IgGu+wMphzjTGczEy\nBkrPTGbFz1MTwoiqdvjaFCWHMEoHS1Qjaol3gkby3xw0p3d2vgb1YLXL7Pos\n42QDi/nDe2PXBHAV99lHVET7LSHoVEPfjwDQsiIUwpQwLEqDYv84KmHuKmye\nlOp6hoQ3nLVJqvi84xRpLPVBCub5Bkr7AbY76SL50V5UljDXa8FJXCqvL2aR\nHqu7JBVkiVmcN9cywikpuiIrzKHt+FwDlAXIK2d7/M/XriWcLksb3H3oGGs9\nxL4xWuKrGaZNzkx7IvKMGmL2tvC2SDQeaQVLMrlczLJO+/vKJv1ZkS2dVZmC\nRfQn7IqYjuAVr0WACfhCJiJx5gnBSq3FUTU+k1BXHNNRCGy5z+EtHgwjpqqv\nEqj3iuW7eyt+58/ibPKJyC+SdFGEeZcz4evVp+xVnb9x0axQ3Cgb2ktD7J6b\nxrJU\r\n=rPqj\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCrI78cpKiEIWI5xidNmAH8Xh9wiex8gRRxkMImh4xlwgIgKxBSYZxRk1qEuWE2erz/dF+0V6VQISDX5q8f2X0sylI="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.1.2-master.a6cb16a_1523737306951_0.9304829679667157"},"_hasShrinkwrap":false},"1.2.0":{"name":"simple-update-in","version":"1.2.0","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1","gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"c36e845f4fa1856af4dd9a42c44186e26ec04254","_id":"simple-update-in@1.2.0","_npmVersion":"5.6.0","_nodeVersion":"9.11.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-a6s2H/Px+TXHlJG6FvBpVQU4qnz2BFjMzPfuzdqnGabKUntbIeRknTasCwlWKrXhD1QBSPZ9XoiGF8EpRLjpiQ==","shasum":"17e9287a358163b10ea6722fe938e667ae9a423a","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.2.0.tgz","fileCount":10,"unpackedSize":22532,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa0mL0CRA9TVsSAnZWagAAph4P/2xH8fW+0hXLlX9a/te0\n3HnEanfrzyV33JY2k21LvzCs1LWOdAtoJ7+KmG8ISjKrrwx2CYrUYs7DX7xs\nIv+K0NBTbWq4z6TqPdm9Yzfd51u20h/agNlnMzBS73mpZ2+ryIybsFExRum5\ntiMayDMIIGBUHHfSr5pjIsfSjCNJSrjUORTmu/SbTPm5ayeqw6WHqmZQkWLT\nHrXZh0MUiiRbMszt8EsPZgad2FJnp5WCh4q1WL1u1X+c3Vbx893G1yPj5ccL\nbqh1cLAmL85oNgtRPFm2m49fLfScmcMgqxyG7yQc266ebMOOzcqWibCgTtG7\nc6RQoZcoFb9SVJ0zUQOc5Y34fXIfUIRRM+UFQRUhYP27w0bkzB/6vAVCqpPx\n7pPN+vAGkvmxXWlN5Rh85G33UlOlqqbeLDMjUMtgSSnoh7eyUj8vBx+0xt1N\naiRqpR5qXT9ppqEDyPFLMDZw2cRmqNFSGMLpuEY68kltB+gFXi+p6QE8pF5P\nnd1QnNZIj2bWpFVDJu5qj+LP9Sin3ozu4uC2Gn//n9aIskh3W3W7Nt0oL5gn\nUIgl+iaFBDvzNtZLjJ7A8U/+iA1efD9Fxhoel5ZSb3wQadopwkw+TZc1YLNu\nXcnHZIyTLXpRBumzN+R7761epV4ak76S4lkCrjNKQ5x5MzmIzoJvX4XMouLS\nGRFK\r\n=ohBY\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD799xl+fx4kdW59H+ON52cp5Oo2OHr3k3EvXLoXZiWnQIgMeXgaIQElozqzg6J1pE6rl8PpybMkyc33KD9RwDCsr4="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.2.0_1523737331185_0.4523488272682157"},"_hasShrinkwrap":false},"1.2.1-master.f2ba331":{"name":"simple-update-in","version":"1.2.1-master.f2ba331","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1","gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"f2ba33122021a189f596335b5ad1a8e62f72f34e","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.2.1-master.f2ba331","_npmVersion":"5.6.0","_nodeVersion":"9.11.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-MbC41fSekmdil2CF4nRbkOqIHdRiga7/Ojt3Igi6Q6wFIFiVRgfx+G1CzWtq2I/a2dikYfOQYHBFeYgSn/Q7cg==","shasum":"d3256e59186024d7c2d752044b27de8c75865a83","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.2.1-master.f2ba331.tgz","fileCount":10,"unpackedSize":22547,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa0mL8CRA9TVsSAnZWagAAUWsP/39ItFkxDCxhiJwdelB2\n0Iz53+Upz5+YCp9z+KnkNYgGaWCm58TCryJkM/IeKzofufxK/fgy6aw3bkXz\nSYJJliaTxVJQFqann1TD+H7RgFLFNy8LPhnhGyrNRRVZ8NJuiGAUm7/xy/6T\nuNl2P+PhnlKwaIOYMia3emxDlYFZitZ2XGbD7cLnfy0Ph0oGl1yPe9m5dyfq\nrFEllL7ORqmVtf1UJhW9IkDgIiChRwUySdmkMEtjW27xdO+aN6143JrWZwTL\nsbm8mIITQsL5JD3DrdWDBbfAHU9bhh2k7esDTi1WoCyrjiKaBDfRai7f7r9g\ns2K6hjbTOTZ6Pkrth7/KihbgCOr8VrhDFNHjCp/hOW+kbgGQbnqAlCcEQvqj\nrvEq/DkWXW3lwRtQQH1Zwy7t095JVnXbrRdWzX2yodW83m5Q4wPpTdHwyFxn\n+t+pxruYK3xGcvnMFw9vE9HT/J/WC51kkyHIfOOYD9/Ns0F2aGGEZbrg+4ck\nvb+AcPuaKdYdLHmjSoh5jvFu8ozsny67jFzqXP2tcHpYJWU4IwCSPTmn82uq\nxXz+bH7I9pWWXkYrPSRxo+l0rVzqW2eYcd7wgq406+slo4gojH/u31UM5G4d\nIz8rLNVqlQCPW4ZWSwWO0PUQEX8qZkYbHl9P00ZS1j14DG3sYdqadMlZWmhq\n+5Br\r\n=X2WW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC9f+GH+rLIqbyjx+MfcOYeH8CoWkIFE3JIF1RgdKt1AgIhANJvgvOHTen1vwbEqCgN52GNJ4BpFfHmKIX1YV13hWBH"}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.2.1-master.f2ba331_1523737339833_0.32994057823085376"},"_hasShrinkwrap":false},"1.2.0-master.c36e845":{"name":"simple-update-in","version":"1.2.0-master.c36e845","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1","gulp-exec":"^3.0.1","jest":"^22.4.2","last-commit-log":"^1.0.3"},"gitHead":"c36e845f4fa1856af4dd9a42c44186e26ec04254","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.2.0-master.c36e845","_npmVersion":"5.6.0","_nodeVersion":"9.11.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-k64qFGWUmYzbddvl6xWjwGRIp6OcAOynySMU+aA8IJBUnxhhOZhWu9jVJjbSPf7IOFV74DQidx4SpqKPQqdlvg==","shasum":"57c07fe843cdacb61693c1151d47d5fbc810cef0","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.2.0-master.c36e845.tgz","fileCount":10,"unpackedSize":22547,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa0mMFCRA9TVsSAnZWagAAPJsP/j6X2nN3z28fYIWV68/a\nMktNe3Cn/MFWNFRLU66LjnsOwu2bDIFNxqlHZb0vFmT4Zpuj1i4algWqXdKK\nBn2YnYu5ufkUUv+Ooh0BSBrOzl60LuWqtogTonUk48/xMkDnXpLTWjSwhZXn\n2BbBdZA0/yPSnxnwIIdQepWUsONyaKjmXsQ6vn54rGidM4eQxHWCkv0KdZp0\nbDfZH48ZeL6tFkMZkjt+FKIJdiUC8DgN/14hGwhH9Z6wWBkGvZTiJCb7Ul/L\ncA9CDqHAMV9qKJ+KOkAD3vHO5E54yJvs59OWNMQ7i6nf9QdTTxfQrL99R9YD\n5O2ggFpjtBDymkaO5b+Cr9wXhY/fx7bDkIWKVP5F8HFxq7kBqmMyOfCzlQqW\n2stxOa/Bd9JOGHElP2gPEGkm3rYROVddU80dpFU81Sr4Dzck30H48t+IFJrO\n5SLH9ezMScZ9aknuUWZfePq6M6g10ySQx/bBc3GDpmIEOLAOyB6KoKNih6xU\nzGAwTWGNIu+cII+laKnHjjEhju2w1QlOFM41L0GUY5q0CXojfz7vKvONzzxx\nC6ONDyzP0fUwLG52LbH70JkvBK0P+yPLzP5RtxqhHMcAISWEvDTg8NqSj6Oq\nEtRh5/73scdFLL3fCRDhiSdlgPBPz0kkvyo55SHczxTtL6vYjt8vUJK07D/E\ngDXp\r\n=Kiij\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB/7olMQkhAQbzrsEiUKojzkUmhxzl9VTrmT0UpkbWrHAiEA8PffdXKYYEGnGiGMQdbxzK/Ct2quuhRsdRvxjHyAEHI="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.2.0-master.c36e845_1523737349114_0.16753944717612557"},"_hasShrinkwrap":false},"1.2.1-master.897c6d0":{"name":"simple-update-in","version":"1.2.1-master.897c6d0","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.3","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1","gulp-exec":"^3.0.1","jest":"^22.4.3","last-commit-log":"^1.0.3"},"gitHead":"897c6d0cd5a074ae65129352bb6ba23003e9a6bf","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.2.1-master.897c6d0","_npmVersion":"5.6.0","_nodeVersion":"9.11.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-WgjHCQMHCj+/+tFGX6U7uo8c851EG2T+YxHU2qtj+Xvn50UVGQjGbSPflC6rRynic1KR2Be3dXoUl8++9Y8ygQ==","shasum":"9bb137e3b7dbac23b12abe9fc3704aa9475c28ed","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.2.1-master.897c6d0.tgz","fileCount":10,"unpackedSize":22654,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa6h32CRA9TVsSAnZWagAAvrwP/3SFXA0f2qeSnuidED4A\nSWl2gHW274q8mez2o5d+Kt5omeAN1/VOmaXrhmQimemwcWGvtGN1QMkeh0/p\nrNKY2wj2vz5h+YmtngA/rWxLA14r5wCJPBqhdHI2Vnr6hw3TEL7BHAFb1de/\nExQz+SixsNyI8580GmQyBi7zOJZ6UFT13b0KVFCk9lBTxUePrAzKbYEHKtmo\nf+gdg6NgNaRuqjZgyqNWYVZq94f6gHVWB1AYVerlR6mWKzBDDyBxwEpkxrKB\nKyZANvWkr/9AIHlX4KNaSctydlZRCnAG/nwDGdie5Ow9WtxrOI74/YLmQgBX\nGgr7gkk/kotbBshQVjJ487V1GHRWAqhEt86FuSebw5NAFvVBRnVtYniWagrt\nm7jJLvbVww3LJBsGcQ+h5L2EPOV1KpKz1h+quspWX4HPzDU7SuWB+eIdIzpT\n4LqIKdiM9FCDT1ubmVH9xvdyfYOY6dOBTNmbNFcELp5CJG5qQrOFoGt+lDUM\np73qQLESfUVB0/n/qXoPWV1ODQ7yE2pawvQkXsmOxjCBYGvR4EqMNRSD8NDg\n7pdw6v+dwKdV20IeZ9/WgTfoZyHRxeCBzGcAlXgnhIGQjLTu3t06VSeG/1eP\nBm/tR/vytYwS9PdQzFBVuKtmRSCv7chZKyuufLxwuz/3/450beqErntNKxkv\niD3o\r\n=okpa\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEY6FloFftefFjWhFzTwAIjfCpq3anE/zf3/XLL2Li3sAiB6UYIptytfgQGEJwgXAgDXL2aa60OPhq6DlAL4p5p8Mg=="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.2.1-master.897c6d0_1525292533696_0.7228060735693236"},"_hasShrinkwrap":false},"1.2.1-master.dad2747":{"name":"simple-update-in","version":"1.2.1-master.dad2747","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.3","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1","gulp-exec":"^3.0.1","jest":"^22.4.3","last-commit-log":"^1.0.3"},"gitHead":"dad2747e31e0028904c84d6c27e54e7644abdd86","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.2.1-master.dad2747","_npmVersion":"5.6.0","_nodeVersion":"9.11.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-/EQy83zBFb9OQsvgBZ5MkqZE70F4cLCpnpIdzb47gq9e3N74pflMSOMconuDJ3BZjCB1uYZrKLPQNSa3uDV2pg==","shasum":"e49239c931804966440cd7cf9366889f27f4357c","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.2.1-master.dad2747.tgz","fileCount":10,"unpackedSize":22547,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa6h4ICRA9TVsSAnZWagAAQvEQAJJXHIbAR0NXjTwXgk3i\ndm9DqSKPfQAeCCkjmBYVSAWRZNVL9X7UdOkGqEWju0BVai8o4fCuEwMQgUDv\niuJ57q+dVkQTqfepnCvwRg+RQ1yHfGvOfN8OjnR1Yco4PzfBQApXR+cHKlx3\nbTU1ZX0fD8ADK6Ifo+BYEojpadQNyRD0iIv7fgZa8gExq52hjV8s+cPyYMAY\n7Ruow+Jkxv1ERrIOvpGzLpS9UU48unzhQ2uRIrJe7iWRRD3lC0DD+o6Efr0H\nQz3tGNQSvqQcXHDTSP1MIMf6gUQNRcU/bj9CIVSCjptANk+7Y80VQRUMwO8v\nxBpa0JSlTrsUPoIft41xPakDkO7keCQCswW7wyzT2Q7ksz3ALi6QaQaqRMlS\n63SJRBZ/QhULWgG6/sZQGnDk0s264JPyuMGk9Zo9cVIvIKmLPOAqYKNrVhnq\nq2htJZzMp4GXjMlXmQl31p2pPPtj3D/WH//Hb2xyM9xtCEYV+W3KZDWpxKmW\nW5WnAOGqU1vCxTJBiOt5HrjCnrFMK/X025ZD9ymyfs7Y6Jf0fWlHR6gbTkgB\nIDlT2r3YrhjouuyIxRndcdNEYR+XK+94cgME+cePGGsg2K+WcveH7hgONWly\nZ3g8Gr7tcDT22zK7yISSUzJgT0fqNG8tqRAFIsSiTWvQxXaw3tcm6dPjTqmn\n/6A/\r\n=4W97\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD4DSIpIqYwEBtckXt1CZtf8mzbDkEZgU2yJ++mSCgq+QIgZAYyd9393c8QZZVvQ7PWkafeFQaIsIgaQW3UHXvnNO0="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.2.1-master.dad2747_1525292551833_0.6173985842150211"},"_hasShrinkwrap":false},"1.2.1-master.b9b6308":{"name":"simple-update-in","version":"1.2.1-master.b9b6308","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","files":["lib/**/*"],"scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.3","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","gulp":"^3.9.1","gulp-exec":"^3.0.1","jest":"^22.4.3","last-commit-log":"^1.0.3"},"gitHead":"b9b63083278824a7e684fe014ddefc2f7a54a370","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.2.1-master.b9b6308","_npmVersion":"5.6.0","_nodeVersion":"9.11.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-4qqnPs2mLXs6bHnm5dwxlA0iha39YwC6UUVmtiC3Yyodcr8eZCUSI1Psug/RLczTTUgQuSxWxVYbPeLLSlo1xA==","shasum":"718df8b1a5859cbc68b2c5e6fcfa14cf2e235a7f","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.2.1-master.b9b6308.tgz","fileCount":5,"unpackedSize":11063,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa+KawCRA9TVsSAnZWagAADp4QAJir9HzpHhMeM36rvwQ/\nnQw2SkROm5kXjiHgXNNr0jS6pokJl0AxCCI9dndg9dOS9+oIw3Q2a0ZFsrHo\nSmgoRP1QQHNGsiylvbe+LReAbJP/98+FZegeqjhi9O94vwLgTtsxNT2aYpbE\n65G8Ec6VU69LVfZa3dVG0oKfLpu0mzeLCGTilhRgat5bqysDf6lTVfdhVvmD\nTTraMg6nRrvJjloXlLGOJE6H++aqgajiXnI0sVQEU1A//gPK8YIW3vDpsIv2\nvIxoxjg4/NddtPe4NCrv1+yraPsrgRG2l8paFTYS5sOaAev6E0LbYHj/N2Ac\nWQW9TgrG0RzKErrek4uIz0VBveU+f6Puubr8efRroChqCSDPIy+1N+DDj6vZ\nqvwCrF8rnqMGLDEOAwkEmT2cEnFGn69C1CvWLHOE/1iCzJ14QQu4lcxgq8Ae\n4lNvoTeWSYuO//Imle/eKTbHCvw8eaVOlqwuZM3EvhyVa5jCIkhT+4CO7Wdu\nX8Kzj5sXr1TIJZjtg6fSp7X9ImSCndb5yAh0lOs3sUg4y/1cG+Koz95z6jT4\nK5NwQruiM2dEy1jzZbCyzC/qgfo7imY2kYrv/Ep4Y1e1HfUgn2OvX7TZBvOV\nGPaPJ4AxEc4BIDLr5k3ivvHo20kBS7199qqJ8gwVzoxnyVaZt702EZnkk9Cs\nbT5g\r\n=47yO\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDuuJktxktp3YRvNLsTvLRoXWzXmECOvx6IAxjTzgaWxAIgVcMXe2kHSE1Zoo9TPqp8kWGoF06LtVwHCsJLDk0sJN4="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.2.1-master.b9b6308_1526245039340_0.011708394083976614"},"_hasShrinkwrap":false},"1.2.1-master.b143fb6":{"name":"simple-update-in","version":"1.2.1-master.b143fb6","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","files":["lib/**/*"],"scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.3","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","jest":"^22.4.3"},"gitHead":"e58a19a1565a5517ede16f014e0038a0f810a75e","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.2.1-master.b143fb6","_npmVersion":"5.6.0","_nodeVersion":"9.11.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-PhzMLJRkUXSlMDo5KiFSZVcxv9ph+Zz511B/ZYpjN66EOE0KDez4TwDEfqmUruLegYRU/Mz3oI36TAG03+X/CQ==","shasum":"3d9a39ce15c67a0d48a966eff8090ddff15c2a38","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.2.1-master.b143fb6.tgz","fileCount":5,"unpackedSize":10981,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbALp+CRA9TVsSAnZWagAAcxEP/08EI76q7tewgLBEASNU\nEV88Qs/ipjLggkHlJ9WZKQMoRFI8DmGtIPKJAaJQQj7+wLiu3VD8PbPfHpU7\n2bCHhAuIjkfWY1KH5VKMUjHofSbbLBhe3omz6GQjgcb8U7tbI8Q9KjTU0fn6\nbFsU1/6dhPn8wjsuGY6Oht9ItK+Diva/ENkNSKLhJ71y5UV3Al3pHUqXg1r0\nbJw8NvpXHNFk/if8/x2OJ6DOIMet9PXjRaCNkQ5VakcQaCRg14ZelwlIsjGh\nZtBOvwAZGZzK7oSG2OfPJz150R0v4deySPzNYJ5L1unANpVV4BfeHlEmopu6\n/wboqz8kAG5ZxJqx/gidk7hpDH8jwpuDYRndYQ7ofORil9XBvTsP6m0NyDbo\nrQeYhJ8+2TR+qWRiPbIczcNv0zqBlJsBguKWsBmRccEfrx/0+v4x2h7i+ynK\n9ajUV4ootlmlL/hukKiesjBxl7sMCr71s8r3UPg2dB5CRfIfDI07mwIZWu1Y\nNxk1GIZ97y8H/czkDch9lQPsyYyH2r0e5cpHsW2U8Z2KYzqzThqlipkASytH\nxLXoXugTBHI1D3xTuDfaUlXcG7GTWC0Yx+sIEPHLGMpToMZ4KiRbPPgvLq1A\nMI9/A6joBbNE7h+iLzv4Y0Z7u93eItdQUGh3NUjICMukIjzAk8eNXj6iN+Oj\n6F/1\r\n=bNy/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC5RRq/B15UipVmEVwNGcHr5zn2NKYhXktXZvb8VrAOXwIgHw5hYK1q/JCGo3SCDmPpn3UMocSPh+cG3xG4QIE1geE="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.2.1-master.b143fb6_1526774397573_0.8547141625048611"},"_hasShrinkwrap":false},"1.2.1-master.730f2f4":{"name":"simple-update-in","version":"1.2.1-master.730f2f4","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","files":["lib/**/*"],"scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.3","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","jest":"^22.4.3"},"gitHead":"e3b6b24abc2ce5274dc1b53a126246df89f34b9b","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.2.1-master.730f2f4","_npmVersion":"5.6.0","_nodeVersion":"9.11.2","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-EGT155sma3rT94iZ4A+JbI0/WhGvdu4zGccP8dXJVNNpZdiZNygplzRnd/PJq4ADrAIX6yyJfuMhBi58iKhOyw==","shasum":"005686bbcb3a5d146dbafd9e789c2d0f04d72af0","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.2.1-master.730f2f4.tgz","fileCount":5,"unpackedSize":10981,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbURVLCRA9TVsSAnZWagAAY84P/RTMrs6Uut3Gndl/7jI/\nFnyY++6IJHFxTII2cbb16NEkktK0lsAUAfYLAn2fugqLQjAGkZOhHr6aoMFE\nSDG8vpRpY+cAXFKxGH7GQOCpj+X1JYmQs5EgloWIZm2V9DzXD2rwx4FIPHHa\nB0NktBLpSxt7XAylxtl4TAHfapozyTknhVbu33dhVc/T/+dhG/DUKA/kDUuZ\nvpQ82tDuyv8WxpUQz/036j7CTu4OQz1MID88PXsd0UzzrIunfyO1Va6g7L0T\nJAyNLGLnMEDnLxMZQXmYaWZQhnix4z+dqeBx8GnAfMUXquNBq6P+qMUZKSb0\n7dnnE3i3rEbozkKp2lUkopoR9naHepU9QdCBqRhR1mMcD3iSOvdYpgxuBzyT\nVptP86VgEGTwQubcNmOaVDgOByP7teBPJQap96gLjLAuIAGUuHztWDG12XSN\nHSdo9kEKQHOpQJJ6K0nCdutL9vUT8/4f/+vrGTAa7vB8ZspucwYfI6pYwk2o\nTMvS5G7xZc55WYFBWYFQBhJ2eyY22+CSwBKjiwQDSsGg9P3MjAMajRURvMIJ\nVg+BH87qlscykwBN8mGOaOSRyaT/8uibdxUs7gjXrc5EEC2mRUbg1p/PbvWc\ny2b1uMKaw8q94mVkc8tLih37sWTQP5pf/ph3ncdA7E7rqUyTrvVLggq7Nfdh\n4qg2\r\n=63er\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHL6c4sAlwKmYoEwUXNZl/ZjgppdepEkKF3zs7mQC+9dAiEAv/T6PS2IzD10UYSs6ghRbXx+DlcxvSaZ7IqbBJlPKaM="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.2.1-master.730f2f4_1532040523786_0.9400863925660761"},"_hasShrinkwrap":false},"1.3.0":{"name":"simple-update-in","version":"1.3.0","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","files":["lib/**/*"],"scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.3","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","jest":"^22.4.3"},"gitHead":"a9d7af0d4ad4ba113486e08b18eb4ef065e4b6d9","_id":"simple-update-in@1.3.0","_npmVersion":"5.6.0","_nodeVersion":"9.11.2","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-XQdzyPAjHeqcBDJfUBKgfnurtE9Z/PC7Jh73DAiNlS4vMkdVTrtNpg5GJEGSDOtJ5LPQdZ/BWTx5GNzsP89mlA==","shasum":"f1cf7cf83e6c3fae822812a7968f56978f0153a1","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.3.0.tgz","fileCount":5,"unpackedSize":12384,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbdpJ6CRA9TVsSAnZWagAA+IoP/2+gHo9vGIaqD3F77NFd\nWKf1UWCrQliMP853RvMF23U2hnavKsJxLcrQG1Rrjq10QSWQT8me2Hcjb4pS\n+1L/r8JiLfn3gjhJckTkbcMvN43AHBCZoSPKzJN8JJtDe6HBCN6ZQO2j0WwU\njDzMBzd3nYg4q3qq6or3x3A0ifeL5EqGxyFVEFBVJoGYFuyg1bwUoTNdxPZd\nGFJC0nXrwni6Sp7X1DJ4pR0ojB54IId3Wo1qUZOoZBymE3ElEhGpvkNPMgiU\nMhW+BvYXWwu4cs+djUNUyJKxCO3XiruHcNNZ93WigyzaYuLIhxYT/FvRnEzQ\nnBFfF9TTgK6jFCB1KTcNN+9kQy6byLLzJ3pdJrEgbokz2i+vhSyBpzmD3+U/\nKvt/OIBybavaxoHXWnuph0M75uWFwMpTIvxXTSDcVHJO17NLMMqpUYEKNlIb\ny9ULJQEJrbmdyGc3Wm7frewWDZ1zOy9+fBFNzcQt8gEwl+cLGUkhE6euT565\npQif4QwWZB/EBc4j4PeVxpl9+RoJSLn93yK3FejP4+jR7gsnVEdQ2rcGSPsB\nQ8qUuEIEbvShbajHde4scJVQTTL6EJ77KN3sOAfT4afpFjuEoWdeSguoMapp\noHoT7suHwHCh++XFAMAeANadryEZTftLUDAFjk5qxtNZcD5rGJPypfcpzkCr\n4g+7\r\n=qU5O\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICtjx31vkNikD8lXZ/Tx9mRPXgrQzQQNcFRFSIOWTFs5AiA9JqcX2zvMhNOmShbDc8Ut4P7bf1ygwOyJgpWWgeMgmg=="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.3.0_1534497401862_0.38965579307388953"},"_hasShrinkwrap":false},"1.3.1-master.023101b":{"name":"simple-update-in","version":"1.3.1-master.023101b","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","files":["lib/**/*"],"scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.3","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","jest":"^22.4.3"},"gitHead":"a2ba6465782bb3dd7d73b6584498d50e6881872e","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.3.1-master.023101b","_npmVersion":"6.2.0","_nodeVersion":"10.9.0","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-Jpjk+K12XIDsZf7AUHONtrzhGI3rRi+n859D5efc9oiakpM7xqj8zrXEBe85h0LtFEaz75V4F/g5LttatPk69w==","shasum":"61a60032fe7eb8f449349e758d8c8693d0ee1eb5","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.3.1-master.023101b.tgz","fileCount":5,"unpackedSize":12399,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbdpfTCRA9TVsSAnZWagAAEwcP/iuASPWPLgoPwCAcCm2x\nJ9pCoVv8r1IZWjGofd9XZTMceiraCNtHOTDWZ486ESfY2wsHQPEPiMCI8Fv/\nWsJ4h9kmotOPLVn1AOUic8SbEBpvOd/dGsUUL6rq+SnqaDYGMDanvaTU9Ccp\nCGk9dEnRVMfxJxOQVFB9oHJBCiwMedzyrHzjXqopKVSIR0PMSG1gIues3ORk\nwq9a1y6q0NOAvjs6lqGnc/75tG8UvhfzmGMAnvDjrENzHUWEVpipgwlzW0Kh\nbNg8nVRb/YuczKMFyzMG2oTAgAEF/xPuX3Zob9RLa3OQEXqslP61Pymgapvy\nUmB1Cx6NxAi92n0Pb/FnQPNTaJMmeSsjA7Cv82BGk/s2RKOwpKzZJIxqf0Yk\no0f86pxhU0KjDL78z2jH66zPlU/QzB8GYB6svjKkf/qLvefD+8eh+JvGaK0t\nkr2YMKec+uAZ+MFyJSqZtkONHysgWGatIuxRtAqaAgZXYSmHTDSFCAp6AGl6\ntCqXz6cytyafDyxH4Xzw/tfZMQlteOLKnAMXPtHRgw9ZJSWochfinATY7iKM\nqcdesPBmtuaf70HhtAgRnHAHqIXV915PdLXrzLOesYEvFNa9ebCjZFrdsL9s\n7Ta9uelDzx/l2kLWxX88t1Y/3oSw5N+TRTI780F7kMlEajcnHHJJ7OTMCC09\no7P7\r\n=SXTQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBQR+9NY7L8Vr4nN2p0j50TnaX3NJY3Rmxoi6RdvJdKqAiEAxt/BnjvdXG/f5HbdorSWzOuf6UxaW46DnzieuehE4gM="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.3.1-master.023101b_1534498771229_0.3281132045545019"},"_hasShrinkwrap":false},"1.3.1-master.f84f35c":{"name":"simple-update-in","version":"1.3.1-master.f84f35c","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.3","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","jest":"^22.4.3"},"gitHead":"75acbea7b34801705017625e465d5114d90b4459","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.3.1-master.f84f35c","_npmVersion":"5.6.0","_nodeVersion":"9.11.2","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-bu7IkoHvXvEOBDhl8iPqyGcp/k7cNLXEChuKEw3at48gmrnRDZkEa50gRHyir6+inwbkuzehOYP7g/SHXCoIhQ==","shasum":"c8c4ab0bd45135a8a17bf45099b92ead32414937","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.3.1-master.f84f35c.tgz","fileCount":5,"unpackedSize":13305,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbtyDgCRA9TVsSAnZWagAA18EQAJj10OKFKF/eJMK2KWl0\nX/2RFVq7lEWyaoB3zyviZ+eYl0S790TlZjCHJSCxBqQ2bLchXtE4G+xTw4hE\nCvnXXrXW181ZbLZD6zk/DzRBCc4XUgDwNMOo49lM59FaGrboHZ1tjwWB6yFn\n0rLTwLqeen8DLCBn+2+cBXrYfUQMEr7JOS2iHKT4570OhdrO37AZw7KGrT9Z\nXf6iD8/kDxfoMxXsQKZaAG/M7DtbIMin1eXvIIGP27k5XaWBc5V9FO9pqfNH\ns+MWkMcfVabLLVw+CbkrxsiIZ3LSipwnv70qnOrqvvlgKSO0qwrdBoN1iKst\ntvLkVSbUDW2le2iCOqzKlHatyc1myjN8MeIIK3GFtqvGzZqy/oyYHnso2NfK\nxFdqM8KoU68upOiqm9/oYDrTKoM1IJDRuL9vbiDta9tPzQnJoER5l78Nzfzu\npUlkQbjG74XqtdAg15h9cSJKp0ipJY9NPnNCteS7cXJXBus2IcMxsXMdU+rg\nAZ6XmBnDTf9Z4+TA1/WLq535eTEmrRsaxCQ/fzSHOXrD1fGGk/Hg1iEpLALB\nSYDffQOar+En047ZzgmLLRDWJ7V3xCrqBMrym8N4SJNUecFOoOayLPjb14wo\nkduq8kLs8lJtrYpsZy8reR/4I8eCHI09Utcvz2BSv02LS2fLqh6jNaIjBNSW\naMJa\r\n=9mn2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID0QdZ9Ld/zEFOsbFCZmpYUi+iSjAHscHw4xB5rEpSqZAiEA2KK0n/pjsX9RmAA60qZLmiiljdBuuzCVWi7itqFguaY="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.3.1-master.f84f35c_1538728159449_0.6342449599881679"},"_hasShrinkwrap":false},"1.3.1":{"name":"simple-update-in","version":"1.3.1","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.3","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","jest":"^22.4.3"},"gitHead":"b05c1ffc28e7b9d82e38b7ff9e8fe2f773b03ce6","_id":"simple-update-in@1.3.1","_npmVersion":"5.6.0","_nodeVersion":"9.11.2","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-liUwgR6yIHGkazvU8wMZxEfxCvssH9FvzlTnRXPcVgLMU0iFVmMgs7yBxRXHvDfazfylpPfY+7lcvbsIVgMWOg==","shasum":"cc38458049543ac02d3246ea68e15fbd59c38414","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.3.1.tgz","fileCount":5,"unpackedSize":13290,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbtyGaCRA9TVsSAnZWagAAL1cP/i0skBGGSM/1yfU68/Eu\nkDhaBFA9L3/DsCiKt2RdB0KuSsPKFMQ7kpJsfc0fea9rgK+lPfTpIEkNL9eb\nTOiPBshgnpG43sFulMA1X7TyAY5lQtg7SFZbogBybjY4ivtkyJbmjWqQwGQP\nSNgMCCdbtt6YURigrcbKhDtzRhKZqavKlOq4ucN/G3BGhzl7urjEBbtSIhsI\nS56XgvXGenA1hSoEYmlSKVoqy2J9Tl0LWbUch/zgDJBdpRPgxazr8oq1l01k\n5uxC4cY55JOSsfbf9Tl8iwyihxUpIGs3p1F4zXTTZb9R1F01uGQjhtaMj6uJ\nnKZThX9Q/I2pOhWiERZKDxHiI3bLmeLApJEZ3qGToiNsGAZC3FgK+xGykKf8\nBwbeW3k5FnqOwk1ZS4G6sbEv/saqqrSKZNn+Yg7451LpELdtXnz5/K+qka7b\nUJa6A/s0IV6QEIcXXolyr6aElupidvi/zUvmAF5j+79CR9p/BF1wMNnUJIRq\nPwJ0Aoa+d8PQ8CeULM0jlNsJHuFrZmDFPp4hpR7OeuPbSLl1T5wmB5iJ1yiU\nhQno4VbUcD4MAtmUd6AShS3iV6DIJgZ1QhS5Wwdzb6HaDlABhVPaQffM5FzC\nz6f+dTKKW6rUIr0e0S3Ww4JOXQhc2aCPCI8yoMy80LgBYGj85SBlYdxyLlUc\nAk2z\r\n=8JkI\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEKod6tVd/3YHv/S8qGFknSIFF0GlVy3tlwg5DxPbDN+AiBjto2ph1H8Nc+bnFBuJZohm/unU+zjw74/sQfwBKx7Tg=="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.3.1_1538728346053_0.6488515871387668"},"_hasShrinkwrap":false},"1.3.2-master.62c7b4d":{"name":"simple-update-in","version":"1.3.2-master.62c7b4d","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.3","babel-preset-env":"^1.6.1","babel-preset-stage-3":"^6.24.1","jest":"^22.4.3"},"gitHead":"39871b79521c2fa7432f6c8c3db8de42fd1f8ad4","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.3.2-master.62c7b4d","_npmVersion":"5.6.0","_nodeVersion":"9.11.2","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-9hQ8Fx65Q9hSSwNICXyZqmGI1KNNbBogn5UdwaDNhOWfEYCDh46WserSLNbSdb+vbaqoz4y2HFeKouA+zq8znA==","shasum":"cd1b0c9567c329b1acd025b4654f1ce94ac82bcc","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.3.2-master.62c7b4d.tgz","fileCount":5,"unpackedSize":13330,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbtyJ9CRA9TVsSAnZWagAAvuIP/iYMt3C47eVP2z04HfiS\nFGVtgL7zF5VA9Bm6t5fbpT2S4+u6UjVtIhgFMHSB6OxWQLrLYW5SlyRnJNzS\n7w9lgkIJZgmg+M0UYUCwCk2LnGoCn64iiuAYOJcRgCEU9y5grrrNyVdH4XCb\ntUwbh7EM7/cPKzTpvFTyb5ia9t5gYHQOBqSY9esOgZKMLjlSSzRWBE3ImSe4\n9Smx9UAso8J1F5lRF46KW1JZNeD0EpPKgjrN76lpkrrIiziuX81A1BCpiDMv\nG0lztA/HLd7HjutrLi/F3GaMPltSsI6iAI3ZntiU0PaP26Nr2m1dYER/JVGX\n96qb2vTc5+BQOKRMI/6kRJTQaoN5EDA2XhPhtDRJ9wJ1FWbwyS7PqUgu4g7S\nNg5GnpkMYhVeZ8vRlWYVUWwkEtDyi+eQCKFyJAPYlIPm2bVvEHQlb6ur1fIh\nHN5m1zAPYkj1l3QAOiUZweXVTE0CwRW/oH5INyYp5Cho/L0sOKR7QYEFnxhQ\nit6OnBt6ARzKK4/GTfaMKG/F+stZQcMlsL5lt/BCJY+rC2e/G1BsE7nOzdcL\ngQKQboovF0KMv1vktKXrkkJMZx0Ang/po0Bc8wvJ/0bBsfAqEfbNmVo4Rxiw\nOnSXqKhmbU5jHe9i/o2iHuCc8i5UZCQR1LUCqNPiuXyqp+V9t+G0PmS6Av9m\nY1z8\r\n=0ja1\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCz9CZUp/R7FsGf31QVMKVYbAoXCxSItb+vBtGjbQruwAIhANaZOCFy037X6RSoGgmc+qyrvR1syHgX/t0Xam7/s3cW"}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.3.2-master.62c7b4d_1538728573002_0.7104053601095477"},"_hasShrinkwrap":false},"1.4.0-0":{"name":"simple-update-in","version":"1.4.0-0","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","jest":"^23.6.0"},"gitHead":"615065c3cd4810500a75d69e1577ee2c0ab56595","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.4.0-0","_npmVersion":"5.6.0","_nodeVersion":"9.11.2","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-4qPHDudDIsY/hVonEBr3Vhg/1jP6d70gAekoWNMJn8gm7qUbEbh/TREDPm4bwHMr6MQl9y1/VgWQGvRjRoAP0w==","shasum":"5bc3808f1b7262cf9b48b89e1ecce777a4602aeb","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.4.0-0.tgz","fileCount":5,"unpackedSize":14217,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbvAOICRA9TVsSAnZWagAAKYoQAJxWSPwffjvI0pxDsaWt\nns24PuOOFgUUFBWhem9UbmwAji2zfL0nKp/n2WvwVjI9gf0eK4dV+e3fklvp\nqdYLtdK6gv8/5/XpJ/XrTVHpn6kBL0XRhIp+ebDIU3esRpYz7Z/i4B8/e5h/\njpxAX+tWuaVT4uau3gN+lihTU+ULmaTwL6g+KuIH/nKFDhsVowvYi9Wvb78c\nlhxoOrhjeq/Rp2Fu+j2f92cJGeSUkdL6eVzSBcQj4UGrV9txc83XCCYYmR+h\n3/dJOOob4HpN4a0b4HgegtxPwavWNKTovMcdF+7jtfHocsETLq8Q0vLruF2A\nrba8a0nTX5XblySXUXFHsWV8ZANzJ6/z/v2hDeGDhUbT4XFvlSP7V8QtgJJp\nEVZYO5+waBg9977nV/8xzF0fnRfYTJZX3kQpdCUiSYG6IrSBeHr9pYwVs58O\nbD1P2jgtHXndEGiY+bKqdlQnUn+yOgN6Ed5mBQGTwBAsr4T3BpuMZBQxfMq9\nR/x/TZNKggbsudajjmCHDyOWF+tJMobjfBAcrivzk0Fpyi2o1fbCiIeVjAzE\noA1uWgwzE/8Q+XEaMn4c3sSw1RKl74SJmmBIvxijUdYqcTVNuCCBrzQ4urNM\nLbGq8/XCEG97JZLLN4JwrE2XiG1FmkeFwD2DIo/G1IkhuBpr4zORIrZagXza\nwfmf\r\n=5P3D\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFd1PHcU4/MxMTZBrhwvfZqwoO6nB6nyWai4gZ4WzVovAiB+6MMVbeXet90LCX4Ljn+p4oEdjZiiGE+u1guawz9OoQ=="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.4.0-0_1539048327821_0.150991333669646"},"_hasShrinkwrap":false},"1.4.0-master.615065c":{"name":"simple-update-in","version":"1.4.0-master.615065c","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","jest":"^23.6.0"},"gitHead":"e2de51131b9662d2bd957688b6460dc97b020d17","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.4.0-master.615065c","_npmVersion":"6.4.1","_nodeVersion":"10.11.0","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-ZtkM0oymTwJJwMDQc15TkccnlxKdmmYmS3kMMUc55F2gog1rYtuGMTOZM8XNyKSfcNv+IdnuLxZOuNFCmI1HkQ==","shasum":"62f838153ea3e5dff110c6bc66994f25281058f9","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.4.0-master.615065c.tgz","fileCount":5,"unpackedSize":14230,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbvAPbCRA9TVsSAnZWagAA2YsQAIyr8E5GI4FUnTJHx13Y\nCTwAhceZ3LdkmswLuwDNpHcalS9hl8FzazBsOj2hHEN5NRiDx9g3wPmIi6mb\nwR7ljSRMJDAJiytujP2EIQB9iFvlDW0nItG3S7S65VDf1b8W0imLJJJ8/KG+\nHkpzagfCwpJ13Sm9tJU9GhL7jnTnLQ25qZRn7wV14Oiw6Zvfh+InU8bCoVD7\nGJyAXJFc5BiV71A7w/tCFJ8dh6fSUlyLgaowNSch57sblvFYF3f72rmMNvWa\nr1rx+A+MnOe6zVPErdYuKSLfdpe5TkDcZZI0+ImcGl4P79yZU8AXYkd8Rmre\nUL9Qh3s9Z0OT3jiLlJW8j/TT/53JaLFFTvoxdh2L2/RrpFFT3cqClRfoVpVA\nHStlhU4dZNcwcv+zHrTdue7CLnRNkqxdpVOk6Dn+O+ilVq7tfrCOxcOYzi46\nlrK6j1qoU5yJg2nhP5+YSB/j/5F3K90uGB9jDjww5fYhj6+cxePJNNUT16pe\nEH+q7a+mUXqgt4tYjesDUDWH/QcZL174eW4/j6aDTXvPkaO5lA9ygxg+Uj8t\nqjioF2O6Hac5F14H9RP8bg3ReSPOBmm8SU72hJZlnbfaWR9vcvOUxq1Mle7x\nJkLUy7wleFVWBrn0GSsY9jkcsH79W+Euir5XlIQCLD3g8X8xmOPLtr10k95z\nVJ3m\r\n=7Efq\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGC6s5I4rFh8MdP+IvFlRJJRXYfbbizDBJhNmUAqaB6yAiEA3zQbV0UYzly3pYMMQQB5NpUIBX0o01zhHnS8nk6us9Y="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.4.0-master.615065c_1539048410557_0.08711587129392129"},"_hasShrinkwrap":false},"1.4.0":{"name":"simple-update-in","version":"1.4.0","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","jest":"^23.6.0"},"gitHead":"d128e71ccaf43f091a61561f4a1a12ed3987c079","_id":"simple-update-in@1.4.0","_npmVersion":"5.6.0","_nodeVersion":"9.11.2","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-gb8cWM8KxvF0TbBSFagp0Bw13dk5HBjBVLx8N8pXg4CcVyLiEuu3xxYHLfFEZRn+bYjMCkxjEB8upbWmAVOIyQ==","shasum":"3044da2859bf08c1bcb829531a9da96319b97247","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.4.0.tgz","fileCount":5,"unpackedSize":14215,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbvAS5CRA9TVsSAnZWagAALK0QAIrnc/dSktVTQtb+6yYK\n0gfmTE/Ll1cU3ZnPmvnUCBJ2S3YjV85oFNChBWZuLvaaC6do4irTS1CYpFrd\ncFuGa5se1mp+rD7DoFX4DIA0gd5VjWcV1MPxjj+sM0TI4JxVjazhX7r//+YW\nFunxVBnbbX1ttYg2IeAo07c8rufSncikb6Rchhvt3ofLIPLNfBqE8b06cIEE\n7UWAlpi5hJb9dawpDhKsSXAyE/PbKboWIfDHQqidCHYXnSFYdF6ItoD0yUfe\nda3o2CzIdUBPKbrNYZQaxYVGT+Lx66ueO8iCdT0kaB9Ii9M0V8/Ds9N3faOM\nLDpGLQ7gH9BChhvhOak+2qA5+FGV86HmB+QHtu0CF/cVRBnZwIOaBUXlBZ8J\nvfYsEYIgms46o/X1FW77CARR9sLTWAqTHSWiR6tZ5EW7KQ3NPYrY500jSFrf\n6LkcTf8QVwUNbcxoeK+12NZPws4o6YNZ24mK0scwOPNDpbg547c4TCcsfnZ9\nboCbnlCBEdLGrMyVhzUuRmRskhLJAK0upGGjZ1rLxZzepbx6c3sPUqptkHPD\nSTswBwU8O2PaFIS9w3z+yz8vHUWJcW9Kj5vhuYFYgUSg5TmFJpXJ/579FEAc\nrxBzyZWRRA6uDCn8LAW75Dvazj0YyNQ2yJ7J4cC3WUElJK1JOrXTWKG1RZYk\nS5Fp\r\n=GdWK\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBZ8j+HRfyY++reEhUAojmaOx2qqfJP1spRqMVngWw5tAiB8fDeBzS7/zcQRxtPiHsUfsSEve9gR2dHDsNuhrMlu/Q=="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.4.0_1539048632744_0.9568983733889487"},"_hasShrinkwrap":false},"1.4.1-0":{"name":"simple-update-in","version":"1.4.1-0","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","jest":"^23.6.0"},"gitHead":"6eda0605a34649d004b37beedb3b1fac000d29fc","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.4.1-0","_npmVersion":"5.6.0","_nodeVersion":"9.11.2","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-+eLUJzZLIEuQZVpVrm0PDiWqMTXJFMJqqlDQoTY98Nf9oBvL1r/P2FnbY5ItbIYPgQiAfLTXhYRd/xqOzFyZjQ==","shasum":"5ce7514033c81875b09e4bb3ab474550dbc37a84","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.4.1-0.tgz","fileCount":5,"unpackedSize":14217,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbvAWJCRA9TVsSAnZWagAAruEP/2kRySmaIfqSr56ScO8g\nTuoTWjDgXJeDQpYXqmz9fb11zPEsagU/9IC0mCw2QbvGaLzDd8maRUGHat6+\nq637QwyEY+QRmPZZ2QhYAy/M06eypL9Qjdg2OPMKr9mjyjIrmKinKQ+Ly9yc\n7GgG5XiFApDzwXouayFWbC4wAszPQh46m2Rcr11kEeHU7meB8JW1tUZufEtC\nuTxLGbLD3Xt6eFJ1wBj9H57DsMPDPe4p/GN++aAX/mqKGT4ofKgbKepujbm7\n5tlw+ThXTBZZe3JPMS4TXeVZRuI+B8NdqzP1HdOuM/JfOh+G13WUm/bYP9hy\nvys7wxrvvKiudxRMoK33y3ZCawkPxi549lhMaRmui2nigSUJg9IaBVgtBBN7\nKsTiHCiJubRsywfUid60kx9NU98QOokjdo1Ar3I1Va30VQDTl0ychkzpifZw\nl4RCPr65Nq0soGJ5cC/FcnNWcybfev7BrKlZFk2INC266TBlV8igwBsz+u+d\ncjnGXhiPlgmEfN66yj0AvX7CQ756zfXsurt0YaEhuuD8KkgUjde8C+bP0Agu\n+WqgbMCJJTU1PDQ5cDUVm12yMhzF4wbbWUgcHdsCVlYkQ5xIetO2fhJbX+KI\n3zuzcJeZM7o8iIFEL7NUZJREF5aIY0vumh3WQt5Nueeke+zN6PTqcA/mvqIN\ndQJO\r\n=XUwj\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGoYXan+6w2X6rYfVO+yj+BJNW69brppkR4qv31CEuHOAiBqVp9LSigMRxRr4Y7aLcLTJuGgUb7N2/KXb76ZIJrYdw=="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.4.1-0_1539048840851_0.5161423983755689"},"_hasShrinkwrap":false},"1.4.1-master.6eda060":{"name":"simple-update-in","version":"1.4.1-master.6eda060","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","jest":"^23.6.0"},"gitHead":"0ffc1917df211a7266ead883cec163f39afed414","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## Adding an item to array\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.4.1-master.6eda060","_npmVersion":"6.4.1","_nodeVersion":"10.11.0","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-pOAEV9Va0KWDkjXcLZSebbk+KUlOVlF1leMYasBB73wKcP31FWhLB9dykw1tWW8KBr6wRqcbbLNQC70PStehHA==","shasum":"2b92c96b268f827794b7b7da0daf39feddef0b96","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.4.1-master.6eda060.tgz","fileCount":5,"unpackedSize":14230,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbvAXcCRA9TVsSAnZWagAAFSAP/A+pQvBlqIww02kYNqrD\ngaJYo4stfHknS795ZSdrjY11nwZZIaxJx4IUiuamojOav09+OIyuALXa9Ai7\nqIu4dHkdBM9VYDEVQaVkI0UA/bMcY2lMIxckYoDcvIsbnvPYVD2koptCQ4hY\nlnggz0vZTFCwSdOXysjVQQ1+ocfo9aXRGvZTZpfnUG0eo8+6D3IvWWSP+FjW\n+Pkb2l91Ai0FA2wk/B5r+CwqEtG3BaDikaESD7BAoA3WQxb762hCbBZ7BFQW\nIDDnXCfJDD7bMP8ekW5rQ+7/htrsw9FQYrlRfE1dC7JmHAwDOXX2Y3HDUdWh\nd2DKE8qL9bj3dY1tKcP9Y8Z0QDCRL7k23nqnkB59NcBpm5EGD6VqhTo8Xgj+\nrASRpFYVbvLTVwLSDlzz4joq0eWQwY7dUwDkJH9dqmA88UlcfAmpnfRJbuYd\nAcEkzUw1eaSE88er/N0sxMqhLC4me9ZUyZWiaI8dqH4A1OcML4h3VDFn7rLr\n4HV5gYBYANLcGh8dDI+fYJaipfbWEJvDq4gJC989u9UAS/iSpIrrsyPFCnMR\n+6+G4kjOyoP7lYv4GXATyI8gktdkJhIVNzUijQmEYflFnnW/o/c/QD4qnsGk\nlE1IJM5iyznDUhJxuZVJHqG8wIBohiwwSaIS1Lk2eBFPH3KZHUVMmHE0BOgK\nmd35\r\n=oEVZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC9m4CLv5FP2g8Z9N7HtwkhHurN783i2BWCCNi6LzKxlAIhAJ9RvlCr4z0NgMHoILqsNkorI3dZjcCMQmHWBoDwEveA"}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.4.1-master.6eda060_1539048923686_0.9097851841086522"},"_hasShrinkwrap":false},"1.4.1-master.e48b627":{"name":"simple-update-in","version":"1.4.1-master.e48b627","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","jest":"^23.6.0"},"gitHead":"365959e1ca13ea14ea649fa855138d4ec695e5a8","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n### Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.4.1-master.e48b627","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-8eEHbyI6Grn3s/+uPxyxbzyGdGdQRPl3DAQVqL2nMiGtd01931mUqYwdXHkds/ODUuyS1tYrn8Phu43/iXf8tQ==","shasum":"8a14ebe4fbe766a3b19e1ddb7f33121a6c8c97ef","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.4.1-master.e48b627.tgz","fileCount":5,"unpackedSize":24612,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcBRRbCRA9TVsSAnZWagAAuE8P+wV+o6V4NaIH1G/EBRHZ\nvXqlWUC0cchiqch7HrD2aQqTYd74lhLzeMr7edNh1nZ6PzyEozCTC4QIIjeI\nWKeMyUwJ3Mc5+5/cJyEbhryAZkfwgUA76z0NolGglYzoTDmLJ4R1YCQ2nC2D\nDM9cJgdPJBGNNk0idvTT4p1jgwPRjIYBBpopv/f20CkXapBwa/ARzI+eFJS8\nkhT70HytaseSHJ3f7599x1pYVMJjbUuuTykcQ5cy+s99VE8QcV/HkiqVJpr3\nzxp+OhS8rrSKtofH6Am3DFRURI5Y3y8aE0KyK37BoO81HSmVbad/hNETsyWB\n93ranCz9GYtOK4cgThkvLLCgykYPzdpuUUJyWePztF5LA0oxJMNxQUl9YtmS\nB+8X1B5fZFzCYV7o/zfRIJzDN6DA33HIq3cm1GdfNUrW2aR3OG8q4uVdcExB\n84K4/exGvuwoCh2ymE6q/zF7Frgm98yJs4thbwE4DXPyH4vmGVKZUuYTrz0v\ntiwa98LKX4vj+nRoUjr+ZtW8TWF99zUHFRHvFjbehLMMi9LcoXElMquO7VSV\nBZChoK8lWnOphQrR8NHGbWipkxDEVAHGfyaXbABJOBcj2Pok2b6C3EcZoJ+o\nZId9R+3IAggt0w8eZX2f+qWNFNVvtnWyMaqUrEmnFgtmVRrd9PfUs+lpwiQ3\nphAf\r\n=tfJi\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDpvgYjCGxzRAOmUM2yErG+tzWfOQ0jg0OQj2k/hxRrJAIhALrKaTQuMxYB/pHip1TbWEWtmCky7W5iR4+4b9BExxcJ"}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.4.1-master.e48b627_1543836762373_0.45166470906434"},"_hasShrinkwrap":false},"1.4.1-master.ea7196c":{"name":"simple-update-in","version":"1.4.1-master.ea7196c","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","versionCommit":"npx gulp-cli version-commit","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["immutable","update","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","jest":"^23.6.0"},"gitHead":"06b40172bc5aae7561f0cda7272def235b663cf3","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (Number|String)[],\n  updater?: (value: any) => any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n### Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.4.1-master.ea7196c","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-CVwm1oEOr43KAT8TCun8PgPctm7mvC9Nxz/t5d3kgZLarwFrwqE9l1nRc2zhbSVT9LW1kZDSPsXQeLdTGuEnhg==","shasum":"407f2ebb09a08c3904d935bef795a415eaf5e043","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.4.1-master.ea7196c.tgz","fileCount":5,"unpackedSize":24694,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcBRt8CRA9TVsSAnZWagAADKgP/jVRPUGcUqO8HBwl11tm\nv6RHZgrs48beXgJqiv4yOWKN3MhzLuEbG0rVyXBjgZ//Kqi/VLiM1+4SXzY0\n+S1QrHUf015JtUIAQRaA/iNxUXVGJO1YaNNZ7fh/NyiZSiKYzJuTKIrH3zMM\n6fIjN3TdhlFSxa/tG7Gybg2bpiuzMpUJT0RV4iuK6NF8muFFN/Jvy0qUKZYA\n2MgYguS0uBLwxmeciNqmKtX9gST8bmvYnMWqarwWPxhobhGhX1zxRSc+UDr4\nlFemHHmeID5LTIB+nOVZMpf9oRFI5AYJxlKQZjV5l9oCG8YWyWlqnqV/0kgt\naLI819ctm7U1NmnCSQ3fzD+vIQMUN+pHd9Yv0Ani2TRmZSthwXlxlFeyxAAo\nIG5FGdrBbzgrL88YGUJhfg5hT0lRSeYCaAOfuhPZGZdjLlruHKEqbdDQfBSF\nP3RCa8j3qiJUEKZTiRaSMLBnows5dibqNe7v3sgTImTLY780ZnryrX3mxHEc\nRZJNNIN0JN2hS7M4uXW28cCpwXGaMUanDyjionWnEl7fGqht40AEf0V6oOp3\neYvitWbM6x/N96WKBg1XbGUeh3wHUfNI6X7An12aARE3tqdYJgPeDZy0oujf\nKW475q/d2GJit0Hq7UChksdqcp+ZVDBeTkGidpj0znbL0RxRuxOQIBEjCuXl\nEKP7\r\n=dfND\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGinznUsMkiHMdmL8fKcGImi2RV1O4BAncw4tt8meaxEAiAHJ8R1FSurPnwUCBypAnAsBC+XJJl1/tGyHjqzLrJ+/w=="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.4.1-master.ea7196c_1543838588008_0.08948838991465857"},"_hasShrinkwrap":false},"1.4.1-master.f9cbbf0":{"name":"simple-update-in","version":"1.4.1-master.f9cbbf0","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","coveralls":"cat ./coverage/lcov.info | coveralls","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","coveralls":"^3.0.2","jest":"^23.6.0"},"gitHead":"ff6d2b9a7034f224a54ea6dd12352445a5881ea2","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@1.4.1-master.f9cbbf0","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-KnI5iyaIaOY/QpnLyNSsfFehs6QkgBOrB/4KgGvU10oZCR8jJcQoOgdK4PtqfJZ9wI9lt6Ki8g7ewDDaODwHFg==","shasum":"94a7baa6dfec833d927096a9d6f6ce37564319f1","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-1.4.1-master.f9cbbf0.tgz","fileCount":5,"unpackedSize":25062,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcBSSyCRA9TVsSAnZWagAAs+MP/3EZKxrXQ9x99eE2Lfiu\neZvBMQ2IbzMAV9wDkplkuBm9kLSQ089KsexfyFaVVJJDzqyHdZJos8oHrGKV\n/3l70UtJCax3WYu4Fz2sSOfNkGwG7BS8wElOVaNA+gM04ujzSgo7P1tJUvhZ\nwczl/Bu6yr8T8A9HBDBo6VsG2wl/8BvwHsureoq5jjY6NyrUbMHiuIkuAP74\n4w3XxRe73RE+w3w9t6frXrn/dWXYQLyUWzV9LAREeuVLECAC7vKXThDRnB+1\nqBToXo+XDJNVrjlYkdRAYsqmiQHtJ1IxNtBnOkjU/EWA9kf1trqwEbKUvPXS\nMv44tMBKieZkW8tzYYfsadJ4+2oX6dFUI25OxVHrjczmChf2k4L1w1NkmB/T\nHXwJ5ggiOYgvjAxkVp398LROB2mb1RdlZNrDWNDvyfaA1/Bio3lbFjBmUMMO\nXzhrvc5SrKprdAKTdnC68aECrQIVvw4Nb0JSlo1/qGxDO1AcwLiwmt3waVyu\npB34TOipWYmjPh0Q6swA7u5knVILmnsFFtjEugtApNDGVpjrnNEVeeHUvnOJ\nc9eEQEalocPcJPJkz5RU/n/CoBZBj7SfybwS4ghyRGgwtsJh9xeRiT2dRNzU\niDb75RkSV/TFYxKT2dSKd3gtD2W+6niwwqwdPGAkDkZTTcEdT7HNaUrNeG8z\neKmv\r\n=oYwW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDYEy/lyQLG0BPyiKrt3qBZHvKIa4BkLIt0pWrXIsietAiEAxcnUHMRxoimtEBuiAJMWDiG0R0EAvetiKjYyJmnbK/s="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_1.4.1-master.f9cbbf0_1543840945802_0.09325086483318645"},"_hasShrinkwrap":false},"2.0.0":{"name":"simple-update-in","version":"2.0.0","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","coveralls":"cat ./coverage/lcov.info | coveralls","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","coveralls":"^3.0.2","jest":"^23.6.0"},"gitHead":"06c06181507c3f108bed173dbebfda6ace1b6fad","_id":"simple-update-in@2.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-gSu/QCmrFPhr7U3IbtGIhyZuox6EHG9wbwioP/4jE+2uC6HIe+1cn2LShNvekrLTja20krJD6ezlglSvv9i54w==","shasum":"c4861b48027438f88ea49e5712b1aceb358872c8","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.0.0.tgz","fileCount":5,"unpackedSize":25109,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcBSYrCRA9TVsSAnZWagAAdn8P/2eYM0XXMfPLWK5ttbHm\ncBgcue2mwH+l9X1eLcrhdOxTe0dRenRvrOQvm9bHdm0BkkS0t1Uqs4ZYEN7L\nXfPJYtVF6vQfNT9xd0CMGYAQqEpqxRYwpsvpescvSx0Flkcbp5VBG5cosqXH\np5h67yqySowDUJdkPK5Pn3gGINaYDCV8QXaGR1cRx/c3Z04Z5nKQ3adF3IHW\nh6MAMEjB3vXk4ZeFUwoo5HCYdLixfFF4VI+1UVdLqCqLqWdAbH6DSGBzYmHN\nnRwd6vHiNMztKzFt7bJ0nSJdDZ2fuG8b1iug+j7Z227HKoqgZ5OHYKhmEWnM\nJojU4D9i1a02mEe31Ut1QAdvAKigi5qmzItXihZvIa7k/5HLt+MWEYAFykkV\n42CiisVj96wwr61+YTgKuXGuYRAmyhEbxBO6cIQZymaEvMs7sGw2eABVCPjb\nmHiDbPitgjLodqXIK//mQc/MED4PjVCzDGTGK/qY8doW4rAdo81f41VfZpYS\nSTO+guanEBj5EXcUch2GftiKaAykU8B7MhALKyHHHxHWe+aN1aJXte+qEZjP\nPy9UnhvxhPr40AikInAfgofoTNLlLj6sWd7RBo/iZVegTX+/vwJTRQGJ24x4\no7vsWApPo3SE4/cv2+OdRzpyqOkhsEENbqjLCWEQj4875TPdtdpRG+xgXhHj\nPbDr\r\n=MQlw\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFOMulBBHheSTOq95hdxAxBKpg0Jx2YE8Xdf961y5l1BAiA/nVvb0tx3VdlM17HkhtSZOd1h7qAADgXiMSzwW/lUzQ=="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.0.0_1543841322691_0.8459093615086213"},"_hasShrinkwrap":false},"2.0.1-master.49d2769":{"name":"simple-update-in","version":"2.0.1-master.49d2769","description":"A lightweight `updateIn` for immutable objects.","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf lib","coveralls":"cat ./coverage/lcov.info | coveralls","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","coveralls":"^3.0.2","jest":"^23.6.0"},"gitHead":"fdaf4466ae4012630b0ea166222a245ebe0367d1","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.0.1-master.49d2769","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-zny/wUm6TEKsD7Jk3y6ljl2sOy9QaDa5tSvQz4d78BkJzgNK5ojaDWGyA2VpVgqFHpgmnncL3FvtoD/yFBUkog==","shasum":"762bfab45d60d948c6b09bca9ae2742a870f047a","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.0.1-master.49d2769.tgz","fileCount":5,"unpackedSize":25124,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcBSbkCRA9TVsSAnZWagAANxEP/AoUy61DFo67FXFRVvB5\n1b3cbw2HLpIQO4QHuDQso3xVXRfskg/JpcMyI6PN4fTyr6REyqMZpp6Y1UER\nMHXhHFZUEPJVqDXN+9USc8nSk9+Uafkzeqvau+bPaDjg9jQ5HR+FQMca7IwU\ndGbbYBM3anma3YP/aZYEOf9O1dmODQIQFQIASKUhs1YwVK93E8fg1VqCj8qa\neUaxNh6r0CDBPPtuXbsdhtovuvpNFHh3fMewe5++ajNBEWvvKVUUM2kHjbO1\nCsPgNzFFqYiwUrumLcCUQPkiMr6bRB+tDLSUn5QVB+5zvTZuNJ3T7k/Xw0rX\nQl2KlJykyiAzsnebAn+bvR41XO4GZGSvZ+/VHrEMXtDp2rU6p4Mx8MaL7EYS\nUI8RynuK2dx18Owq7OlHfG7ADkzrQHhv66/Ojyv+Kv19+hpX16PZDJ5NnLq1\nih0diS4Gtt5IJTBgs/vhB/5cKVYF3Jzzw5G9QXvQGKbnTgIBBzlOL6/as/nq\n5nUAXm1o0OUY1CHQT8yTq1JtWfiAiHwD00S+ubZPeqYjuzVXYACmetBw495m\nYyDGq1A2loIWqkyGULHQKeA1x6PVbW8O+HgGuN8u16yYm+EMX59l8HN9mY9w\nLdjhcOCcZ4QXtShGoxxkF9cZ0H7b0aJhGKxLZ1ZBJogWYE+ELtZdE7RdzyoZ\ntS9N\r\n=Qi8x\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCgdqLNhmV6OXxycsDWwXSBVEZduQUdDMc6FC+YMsiNRAIhANP2pfeZ+Hterl+KBH7zXKs5vikRm97sgrPvMnYYWa+p"}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.0.1-master.49d2769_1543841508073_0.13567026207756228"},"_hasShrinkwrap":false},"2.0.1-master.e01c112":{"name":"simple-update-in","version":"2.0.1-master.e01c112","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","coveralls":"^3.0.2","jest":"^23.6.0","rollup":"^0.67.4","rollup-plugin-babel":"^4.0.3","rollup-plugin-uglify":"^6.0.0"},"gitHead":"38f4e564a0d8df2d779be69f24253b1c2cc22255","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/latest/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.0.1-master.e01c112","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-Ey8S0hGfbmtIRhxpKAicGE538wcuoIqXBImHvHp0t6UFr9cfWs4HhAeObudc7JjwY1DNyexyMKf6KExImioCcQ==","shasum":"1ce4776f55bd57c736829b9033fde631ef220b83","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.0.1-master.e01c112.tgz","fileCount":6,"unpackedSize":31122,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcBZxeCRA9TVsSAnZWagAAXSkP/2b4wGH8nBrw9HJCTNjX\nmcH4opVjkBTX9Lc8gppuL8eYuKSJqCFQXZLcrdyUol8XaH/HldF8I032ZlPD\nOWLhxle5UFFlB30+6BTUFzx3zCCZWLKnaSvrEFTQYWVv615b2q0KYgQmQkTO\nVHjUF1W+HAe0MIhcm6mzqTyEHcplwgH6uefjJBLl0rDeaOxM6M3jeb1A+1wa\nVKJuhx39UsvfOPBUgcLPJnAIlv/iLIGdQUT6kYDT6dV+4Nn9/+SAkHiwqqj2\nCPDLHd5OFw0x+p7nPdgzK3akv+wdaHVr/fseG/0hs4FYIh9VdSQSXntJB406\nzY3VHRoydHvR07JILekFOi4+SDznaudDnftsyRK6nNZmsJIU3nPlsbNNmqCB\nPTjj8lA4It3KUL4jbZ1ayoGPZfZ/NfYGEiRBWO7/wRdMl9hVYRNaQJEJn01a\nL5Yua+N+JrJlgvCrUkIA8dmg5n8nAS8y2oTuqwEZsd0gJmbujAM/wtLDfPNL\npdBzBS1Goolg73TN2LUNq3jmNpbrIrWD4JRqVpWn4euAA/2X0VhGLXWnjt6E\nMLuo1K0r0tfGq3E+q6/5z4J0SUWAs34FK0onrfjRPtiNOG3aGjWqftaoaZMI\nlF94UF2xGv0q8SlEP3HhKNR6CrbhoFNwSCB7Z4L8jxavvIdGAautLCVWsiJH\n0tuL\r\n=m/Xe\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID8ghcXp9GNWSN61f6o5iKQtIvEx9QiSSkCbujfxNf/SAiEAt4z2pe4D7vOY5BsTuYaV6fiIZTfvdgwYyOkUKtzD2Zk="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.0.1-master.e01c112_1543871581914_0.47754941904007486"},"_hasShrinkwrap":false},"2.0.1-master.caa6667":{"name":"simple-update-in","version":"2.0.1-master.caa6667","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","coveralls":"^3.0.2","jest":"^23.6.0","rollup":"^0.67.4","rollup-plugin-babel":"^4.0.3","rollup-plugin-uglify":"^6.0.0"},"gitHead":"6d2a6d9024787386b020d981e2d03a00b137619c","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/latest/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.0.1-master.caa6667","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-KGDdMCQdSYyn4j6Fo8laH7B2tMXqaJAFmswn06QN8coC90f6HFdlhNp9+EP70p0OOAN3jzZpZyHhmxji1B/OyQ==","shasum":"98a9ce6d9686a4281e9313cf3fb82ce7388b779e","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.0.1-master.caa6667.tgz","fileCount":7,"unpackedSize":45127,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcBarbCRA9TVsSAnZWagAAszUP/jWTz25HQhfppA71HZuX\nU0Qt0Y88ASGS446SZ1YrXSZZjyc5VWAaPQHXOgdgt9W5BVkZcrGm3rQ/7r3d\nebVwPeCidv5luz6ovlbQPwjkG28D2HyGk52r+CsMpMcl//qREQMH1VOTasS+\n/8ySdxzfiklpL37hSd7r88yCFLfk4aVpolU3P9LUhTdYddBnfGEh1udgn/Om\ncQXdoDcA0pvDYrGAzR70rtQpRrDD3uK7WYn//Hk9XFbFTwoBin+tSnYxFhiH\nTe2eXMv/zO9KzPuHD2gtUfmv9l4mRb8dp1rhFskgPKc33c0rNBVrSWbm01vC\nsj1cbV82ZRXe0u+p1pQGuXopTE5gzYh/AGw1CRpAglY4SeUgr1J/xmnLNIob\nsoyDTcognZBJQhw10uoeZluOMNXpdHxL2tL9zk4lFPIw7TRoBxWg5I/G0axL\n5RKBHTJx7qx/+ElpHnJC3a/wqZyKP8yagAOIkP0DOAacEBYxz6Fzfa+0oJ98\nlX83njmFD35y4pEIBs904NphiP001+Vgt6IcSYXE1j1lM5RCZhq1t/VS0ryb\nvbvPFTC8g7cZ8b5ZtKdJrDozv7s0GIJAP22PHKrKJWYLZhYa9xt3Zt11Eu3F\nUF0sPAFxDuatrs4QhUB1ENjoz3cWWmzSi5a1nt+oMtlYPJOvJOlpfnaGClb8\nS1eY\r\n=AhA4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGl8ggDGZrAIOHhNwzSg1avLmV4q8vmYXnh3Tusdbk9LAiEAhkgjQ7+xs3ghu+JZr65WHElg6qnuAzH/BhYa7gytJOI="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.0.1-master.caa6667_1543875290921_0.1588048409891818"},"_hasShrinkwrap":false},"2.0.1":{"name":"simple-update-in","version":"2.0.1","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","coveralls":"^3.0.2","jest":"^23.6.0","rollup":"^0.67.4","rollup-plugin-babel":"^4.0.3","rollup-plugin-uglify":"^6.0.0"},"gitHead":"107cca21bb3b3739de61435c49d2a03b9c1fcec7","_id":"simple-update-in@2.0.1","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-w8TSxcRyyQFtsh3M/zqZnZwms89y9S2j3w1sZa+3z+muYmk5gI3xIS4bAFR+UI3CuybXn+Sg1snwt2zAkP0+Hg==","shasum":"1f30860d5618f0603f410d47e76f9ec7301c8505","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.0.1.tgz","fileCount":7,"unpackedSize":45137,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcBa4YCRA9TVsSAnZWagAAqoIP/jmmqsA9+jDNa8UC54hn\nS6X0RP6mJKefizG0UeLCZzHVXQShHPPJMDodkqq7uNhPteEs3giqX7mMVnP9\n3GCx8MYY4+204NTdTF1KeLhFrhW9akvs8MIt+3sUSZTNyaURhXq+cGCnc3Sy\nFy4Jqqs4OMrJnoWB8kLr7tLVYWv5EvRPgp9T+60s2tlDyRbcAMXda/V5WzKp\noUGbMDikEt0BO5p4bUpPwnLu2a0tdDsZnkFmQY0AkqqUqK/lQBVW2K1w0rBZ\njeY9m508937UBYxG6ifY8YQkGQRdrEP2LAi1+mHbfQZSTqrh930MjYcSo+4J\nXuNMEBsBI5W99AXZ28mpWM8Xr7TODwbdmGc78JAw5pJJ+dYT5kMbfXJ00IyY\nODtdwHSdyBy9an0bVjzqGPd48w2r8mYAsl7PkeAc04MyKlOgoH82UNU4NWbK\nu06exNsh88MspeEs35K/Rdjc+C7ZoK7US4Vd7KKICAo+nWquZul/9Ia0vvQY\n0pE47F4eTTkiktTlhrfXrZy4JCcAm4ocQmP/CXq6tzB40WPPfSbX7PMUnJxM\nOG+vXYR2ixelttnlTagxiPb66Ze9wdxmF7WcniDREwb68qAFXfuk2UHFolGV\nmUhwV8jdEB496xWHj2FXo1ArbQqZ8PvxQX+1V1KGKyT/SrSd66+F7YWwunuj\nSGOA\r\n=j6cq\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFOcj6vKn80FnipO3igV3bH/PlVRG1iVGB6EhALj+VaDAiEA57oqwg3XNLS+ZMXJwbtR1I1WtcDaywRVFrlfBvfQIwM="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.0.1_1543876119935_0.9408618854074864"},"_hasShrinkwrap":false},"2.0.2-0":{"name":"simple-update-in","version":"2.0.2-0","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","coveralls":"^3.0.2","jest":"^23.6.0","rollup":"^0.67.4","rollup-plugin-babel":"^4.0.3","rollup-plugin-uglify":"^6.0.0"},"gitHead":"08233364e148c9cfec49a3aa6281772e76bbf416","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/latest/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.0.2-0","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-zjFIRuYf8+sFWkf4KirL3w/S8lt8vArMe1pbK9e1KA9JWGekGqK7YdmDhDVS40+jp3WpQWuDxuqCPaHSeCBO9g==","shasum":"61a8193ba4f3820363066f41abd87681224a6431","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.0.2-0.tgz","fileCount":7,"unpackedSize":45139,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcBa7rCRA9TVsSAnZWagAAG8UP/A4yzXt3SH670xV+SWM+\nW/YHuBZG+kPfMClh/160wd9BASHuEkPchDxy96qbi8zNduXl5uk0a63zOrLj\nucqpEO1y7Zf7WtwDvsavWK6eBCilpFXqvcy1U7qr22gmuOoOX8sfCa8Yrbi7\n4vQ/iGRbg42YylzNvkBm+4ES/4S2YK8uz4HJwfElM1vUPmoVvv7+aPe1t2+I\n01rz4xlj2SG5dYhE78dEQJq7nhMsSQ+EsyFcn6xSUQjH+FIO30JUg9qGE1gv\nAr4010FC/7yz/GCX4vT1xTBMi09GCMMPP0AwIcCOIvuR0fDooLMAFtQsRYmB\nKD93GJaVqzqbHE2PIel3brCAEf5mUIXqq+6EEZ1xNd204oQx1tVTYEL+TvNL\nr6REa4voMFWJfCfdoV+SB/9CUUvGmBk2KHuPEbUCUl1kJxChIVelzS99jq7J\nt4NG+xMdGYq8BIrXuvKcBeZyePQ4I807EEuWz+mpFkqXMfJe5hvvwAND5Y3q\nktL4IIzZRXX8zMuVwXq6oGNdEAyp8eXqtbnUrOvT+AGUyIYo3RgSt8J096dW\nyxMGGQaDjWe1FDSZUlulm/8aw8qzVEZdMNICW5Ezx+KUqpT2ag4XTX5yBUiK\nYSsQVOq/BdmMbHeXsjtP41YdN5uFVg6j1WEeAlK9OZbRvhTmTFdeQ5XjKQ1l\nCO04\r\n=bWl3\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHdIWPKA/3we1G/2CDMeiY3yAazYpm73mZmjrIFCIsJeAiAleH6E+XDzJWY9IuExKVGd3ICl/KgMWAa/PbDqhlw1pg=="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.0.2-0_1543876330455_0.3645082168678966"},"_hasShrinkwrap":false},"2.0.2-master.73f7cfa":{"name":"simple-update-in","version":"2.0.2-master.73f7cfa","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","coveralls":"^3.0.2","jest":"^23.6.0","rollup":"^0.67.4","rollup-plugin-babel":"^4.0.3","rollup-plugin-uglify":"^6.0.0"},"gitHead":"ec1fe17076b2ace0d1e71521fe16f53d9609323e","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.0.2-master.73f7cfa","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-47DvXL0P4F9g56i55Nfa4bN5yYN17D3e5hvy52wB0vKKct6n8ei1z8wJpUXf5x7MkHFZwhiCfQAyUbk8sx2+MA==","shasum":"1793e3c6bb0df80ed3f06dc1d7f52b3cd2580494","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.0.2-master.73f7cfa.tgz","fileCount":7,"unpackedSize":45145,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcBbB3CRA9TVsSAnZWagAAgGgP/3J0MkhSD+L+o93xLXz2\nNUh2AlVzxxVcSgJjREqga0/jqOGalcsR8IfGsVehObPWdzoes3rx5vrQqVh2\nBnNBg8ZsAb7XARGCT0gjcyegHn/f5EbAoCM9j8KQkUHrIzS885BQhc5lBgLx\nB+gBEqpaXTcyHxwwnzTrGmjz7IKsjv8t1rmwKq0lGBaUsxJPCI0ZDMCOM0c6\nXdtHjCxe5dGt30wbao6RErTK92sxltBcWL7gQfsBEctdTXDN3+BKefNiWBfS\nM9MPX+dIZbBiRYmGAmgfxCeRUUuPhGijU9QrsHaUtcwJW6hb/kagpv5gEo8a\nOKkQSvNpVlxW0OZ2BKhApVlufKaK9cbNPjsRvDtLaaHqem3bdIk7+mNJSS9S\nr0JCcvaVYa/GcRQo9FNH47tB6U8r/3szWX9nlhaIz3/Pk9YtxbFQkCYYX/aI\nVf28OKw6/pWroIp8guz9EXIZgMzpOXSU+wZCd0ydD9G0R3ldi3LHHnHJnwrA\nPunTOWVCRBv+iKpQZitRYAuA2A1UoZuF6VRKTHjLJ+63Cf/nroyif8oiFuk3\nUWyOJfb3elF0u+2pHg009GW0aIZODYpRYqGAdZs0/+ftM6OFwKzKQw2TfwL2\nix0pK9at41XYE49XKdRr7R8TyW111Eku7Zp0KVCQV0Hm9dnjU0e37OKGBgIa\nt54j\r\n=7RoX\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD1TT0C0bm6a/G6MS8bUNoHYXTochVqs5iT5z63fBhkswIgPYlhaMY47+T9Q88tnRiKpBo9WsJKYdtd3AbNt4EeX34="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.0.2-master.73f7cfa_1543876727212_0.9884602046804181"},"_hasShrinkwrap":false},"2.0.2-master.6056ef4":{"name":"simple-update-in","version":"2.0.2-master.6056ef4","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","coveralls":"^3.0.2","jest":"^23.6.0","rollup":"^0.67.4","rollup-plugin-babel":"^4.0.3","rollup-plugin-uglify":"^6.0.0"},"gitHead":"077dc6d0c78fbaf9f4df72d07178b7478d90ce92","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): T\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.0.2-master.6056ef4","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-2IqmADXNmtDFO6uelqPzqcaE4bIT/lMVrc32rmeReJ9NEk26pagNGJRpiGJ2col7IktgTT4Kk7Bk07PfXujp6w==","shasum":"64595c40f4c6480e55bf7c22d70b968b5968df12","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.0.2-master.6056ef4.tgz","fileCount":7,"unpackedSize":45138,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcBbEvCRA9TVsSAnZWagAAPycP+gNbxS/UQRNGGVdw9vhE\nQCuDGt/O1Hr1eRqCXUbSA57E89aJP6i3fIfq7Le9Mc3s865EWloiEKBI+0Ku\nZsGX4OH3lNGC3gnr07t4NYBYWruy7psIPP3DMq8L1W1G8hYbv7KlZ4pvwn+b\ngtk5+DRjhunB3xHBoAzhTGWeOeEOB92kQD+MQYzDdVFBa4TlALqno5T9Py8H\nij/BlErvZKxnjSXuom1ZpX/ivfpjiiAIpIHNeAHQekGioCFT7uYEqYG9nA/c\ncJ+QKg/pdz1D2ZWB6hDsI0rkEyCGQ7/lUGpdmF64+sic7bmbnDQ04QG/fDP7\npkQ4qqXlPd/E6hvgYO3qXTc8Ic+85Qd8+/ZhWaBKo30czV6saxgL/t5jmFZ9\nL4xfqBZS+gKq9AepROG8yi47D2WclbXc1wHNHWJT5/kg2ShOhguXml3mLxQM\nsXbj/m0pQy39v5AScxGepk3IpXuSqb3Rgtb9WlzfH7kA/r3s64k1HWhSJy/E\nFuqBsNxPKu7IIz5F07mtEKgmxWGoHUY/4Gz7VwAprcVaJV5UbvDGAgfmojsa\nNJDys6d6aDkkZuDR3m7PWvQ6Ubp8qcgSwNnbcuxVPu3dbFvByt1tAy137UlD\nZc4v76B0pqzZ6IdF6WSMxfTqaccLMFckfzRqrVAZR1vgYmKgDUNQcnEqVljc\nyC3h\r\n=U5Mt\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE4CnAOKXf0tHDRZvhynK1Lnezyo8+BEZ58BR4IRyJuiAiAN+ckVArsjPtuUuZxWcEqadVXYXZlAExACQGbdWGd+9g=="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.0.2-master.6056ef4_1543876910539_0.22058534760058546"},"_hasShrinkwrap":false},"2.0.2-master.004542e":{"name":"simple-update-in","version":"2.0.2-master.004542e","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","coveralls":"^3.0.2","jest":"^23.6.0","rollup":"^0.67.4","rollup-plugin-babel":"^4.0.3","rollup-plugin-uglify":"^6.0.0"},"gitHead":"b131db0745dea30ecbf8ab19b65b524daf265f5c","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String\n  )[],\n  updater?: (value: any) => any\n): T\n```\n\nOr the asynchronous version, which you can provide an asynchronous predicate or updater:\n\n```js\nupdateInAsync<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): Promise<T>\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.0.2-master.004542e","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-AKf44MVgtadQCg9psWFKdJIel9mLDJnZARfUmN+u7P/K3w6DnmJw+W3fM9LuHD5SH2cmEDiDv63bJkVoXs75XA==","shasum":"43326cb2d47717280b61af01311d4c56cae9df63","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.0.2-master.004542e.tgz","fileCount":7,"unpackedSize":45367,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcCQV/CRA9TVsSAnZWagAAznoP/iViRQDmK+KNQYd1JYlz\n+S3u21OCFwqtK/QuC9BGEUR0kHpPtwdNRbFU5hWNgZRMWOS6IFwuEtR7B9Ed\n/YqVq4a9Da7gaQVT64+01mndhr7faIL2s1F+7nx5AU2ao5nwaGBlCwyTk+V5\nI+vGG/AZIiKlXsAAEgnvoAsKeX0taH8K/4vo/SfGG424MtN73NiVW+ilLLv1\nSxcgwEXM9nKctKbTZ6JjUHVffpS3YtlYHqt8rhn9VCRgfUPzJC73rqjNdtYY\n9wdnx1RxXJeRSHJl5MYD9AhRaPg9oczYlQwoUtpbpbPl4J/spibRTSohUHG9\nCiJ0vgC2+zIint+7U8wRSO7YmqfVjaCpmz+4EF2Ftu5ABh6BrvRIHBZCNXxZ\n+LJwNPX1QnfK1/a5B84zUgmXnEWzFYlkvKtemTF7VbmCpwE/CIAZmZ/UheOG\nWP1OLrxn2FZSb9ejlDNvaOVteTDFsXFRWyI4NY2sJjDvPq0GRkw2Tu9lvtsG\nSIK21pDvjLtGUEDHhvR30hpXdgJMlSkhX5OLt237oNssKbFbgut193mXk2Jl\nL4VsexnOaXxr0FWRB0lpsVPxY+yE4vlRDI3vhfkSe5jpjTrndslbcvDSYR3t\nFHffLiQZOzKeUdwuyllHe79j1FO1Lg3YOCtGUGcTNb+aSYIeX8yD/sPk4zQ7\ndvjj\r\n=70Pg\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDo5F1yF8xg8HmNhk5GcMAVcZkb6BbxxrMpokyIPEU2VwIgSAuEghQBv8cqUz13wpZlZr6k5eamqqDqvpeY1lnkvn4="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.0.2-master.004542e_1544095102405_0.27847365024671467"},"_hasShrinkwrap":false},"2.0.2-master.0861f0c":{"name":"simple-update-in","version":"2.0.2-master.0861f0c","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","coveralls":"^3.0.2","jest":"^23.6.0","rollup":"^0.67.4","rollup-plugin-babel":"^4.0.3","rollup-plugin-uglify":"^6.0.0"},"gitHead":"f92491865daf39fd746f77bf0b2379d063aa938d","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String\n  )[],\n  updater?: (value: any) => any\n): T\n```\n\nOr the asynchronous version, which you can provide an asynchronous predicate or updater:\n\n```js\nupdateInAsync<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): Promise<T>\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.0.2-master.0861f0c","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-YwZeK3iZZ8AJDIuKYkPB7alF2HfknldrdY5bNGSEZxL236tfRSaI206rfIrmGRkYijAzbQ4UilduEhoQ4kNngw==","shasum":"d36a617fc30a8b5dc13a9b7ac11998a3738ba88d","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.0.2-master.0861f0c.tgz","fileCount":7,"unpackedSize":46111,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcCZv5CRA9TVsSAnZWagAAsy8QAIJrsRtTJGXGd5iI81Os\nYfoO9/oeebyFjZGeQUNqJYZ47d/++TR7yDuyIE2STWCPiOXwbzvAofvE+CMD\nhourXGh7qgjBw4PEfBY50DaDRPk356adrHYc841nP5eDRWvYiAGGKZJMlWpY\nSKqVfnphzAZAeM4Cz1cJWmRza39Oh8OHWuSHKn40P9k/NNWFp+NhFg1D88IE\n1EmSj2fISDN5VnffYFqH5ZK4xX/7voS+fBI0McgahFezt4MeWwLNcmMhmxRa\n2j6ERa9GAKoM3w9kooi8JpOg+eGosG76Qs/U8zN71vZyudv7EFIMn2J53xLl\nhwxIDdip8bntOIOKQrunzoPxHRz++YI/zPEHkukD7ewkmq4CTu1hY+aFDZDS\nCAWuDKMuThAbUoh0kg4jyZ9PKfsPziJXJLlKHFLJp+kwkFkFAOCJfvxPuQYY\njLcvEZug9QLg3F5Z2Nz03bB+lt4b5UvVAAeeHZOfgpb2ZbaJakAJ1CHEQoJu\nhQLDoeWGmohKavx4QNbDyhqVQISl1JvsoSBm/6LYbqOJrPMCEi5+Ft9YfPkB\nhbb8xye5/ARFLDTIHf2AA7VaUG5XA9sgaPhOaUJn5/SBGrjajddSRJWx/Lnb\n0SOcVYATDutYArY2SS5inYJe5KQp+qApe3W1Wwxi+t9qDh7VvgjO4kBBI8nn\nVMfF\r\n=E3Yk\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDRD3Q8I9oj2f5WT7BZyPOmhn0BCVZ3CIpHv+yLX/M9zQIgGpgAeDDTu2NRI6C0Lq9WBYUIPH/6RCaOYLziF/X5erM="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.0.2-master.0861f0c_1544133624944_0.14002678993319972"},"_hasShrinkwrap":false},"2.0.2":{"name":"simple-update-in","version":"2.0.2","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","coveralls":"^3.0.2","jest":"^23.6.0","rollup":"^0.67.4","rollup-plugin-babel":"^4.0.3","rollup-plugin-uglify":"^6.0.0"},"gitHead":"4f91342334d07495794ddc30be2fe852d448ec24","_id":"simple-update-in@2.0.2","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-vRuyRMWFiOwou3OfvxEMeWjBhPQGnjA/N0EncDKrpWIwKWtOgoObG8E6PK76RBVWVrNpYoOIdWiyRFlK5CAdbg==","shasum":"7822638ea9074702cc5ae280e5a9609647c718b2","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.0.2.tgz","fileCount":7,"unpackedSize":46121,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcCZzKCRA9TVsSAnZWagAAjowP/0HYEEQJ5HN6gUawyh12\nmTzA0iwv4Y7nSWmW6Z2T7Mwvj9nfPqmaXrdmFHxEGaYj5VjPVUIljFOD0GO2\n6kWB3Dd2rT2WlOjWKRzMi1Hj2Kx6ta0f80tCDGeoFQKZlaNvUBz7Xm/6RGtl\n72DkiuupXNwFxnss3tmFliaCvL6ile/HVmyJ/iC0O0yyGdgV5u9Zova+qXcp\nq9aMYtE7Cng+uYa3WHs/xR1SSEnNnD60b0W2rfVyEYHJ0YbLLcVrsq/Bb9dp\ndKdIaG0jPEudjfy8SLhEOMRgJhsw/2THo7qCMhHi8aZ1y2chz4Qen89duBrY\nYYOHIvHu1+Mou4/latCIvvTAsJNxwrvWzA0MypYST9/dWJ+dJNOcVgWkpFMR\nSgN9DhnfawYSiQ1qMmBNtyQU9G23p2V0/x07hEyd07iBB1Ta/Fe2h8yVs47H\neLPBa4jLAr2OTZXaV7hIA/VF7lHAxL2Ls4P54p92P5YRFJ5gY8KqiptiMssr\nl1axfQr7qjVhbsgXjp+zw3LVbHjDN2Wep8isjFi7ARIoFDTH1e2XdqBxPino\nd3vM3UX9iCA2NhIJDQGa2z1aoQk7unJQPRbXxZ+3repDe1hSht/bk0c5C4Fb\nlTS8rzZ2L6yvJdhXMVuK7ETTtaKdh35nJ5ZA2l0SpOhjqxl8/hkDBFg/Hhj7\nGPp/\r\n=BVlZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDfWqXtklbkAkdYWc23mAmekdD8mcHdUvdZLP1rC/1s7AIgaYIxlfrVYM90ZlfgZ2ljFYNcKyOz+UpT1Y5EDHf8wCY="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.0.2_1544133834163_0.5861525450366081"},"_hasShrinkwrap":false},"2.0.3-master.b9e75e5":{"name":"simple-update-in","version":"2.0.3-master.b9e75e5","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/preset-env":"^7.1.0","babel-core":"^7.0.0-bridge.0","babel-jest":"^23.6.0","babel-plugin-add-module-exports":"^1.0.0","coveralls":"^3.0.2","jest":"^23.6.0","rollup":"^0.67.4","rollup-plugin-babel":"^4.0.3","rollup-plugin-uglify":"^6.0.0"},"gitHead":"787819718edc8e518cd6c8419b62fed6718b8b91","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String\n  )[],\n  updater?: (value: any) => any\n): T\n```\n\nOr the asynchronous version, which you can provide an asynchronous predicate or updater:\n\n```js\nupdateInAsync<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): Promise<T>\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.0.3-master.b9e75e5","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"dist":{"integrity":"sha512-INML+gTTuATqKUVeAgN4UOy6wDrS5YkpB5dmNWw8oh/7qnXvxU+pgomOPjiktw6LeLd9jR2HG0QsJz9BvFmeag==","shasum":"fe816527ef3bc30bb77b0a9645c66cd7a897b56f","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.0.3-master.b9e75e5.tgz","fileCount":7,"unpackedSize":46136,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcCZ4+CRA9TVsSAnZWagAAR7YP+wU6AN/gYh0SRhyOgife\n44YcwG5GZIXpzk/b6s9xc6ob9eIVvzKt/pv+lrEmr0zz3eq8sCfWuWOf6Pnl\nkXiIgdGPKAjXnwbtQy2EUsOOJ0KsZ8+qY6kracsYWCL+cKIS4vLYclMYkv61\nfj9/9fyFSOsIbh0IAK5aT8iTm1KsPAr6TB6kS2KxI29GAKCbF0r874iu1YxL\n4IyMmGvk5QTpI6o+iToJUZGZ1h5lefCniyIO7LpKJ+TFycnbbggUQf3PmWq9\n/tZ7xdt8DSvws0m22PVF5K8p3fhtMeQKfaVzub4Oyuwqb8avKRt111BsuNP3\npiwDbfRVRSfFad1BYSsZS+FXMcFt2ygWby+s/L7+GmUzT05VHcq8mqtA8XWy\n8IRBYJNyAvQRg//nkqYoMx9XP8uoaRDaYiLnlVUFypwjS3nnO0aR+hrAhMuE\nwivkk9IOx2gGPV5EnQcSqbfPp61jA5tozr2bt2+kyt0dPXoDuZ5LEXYKhzzF\nbZp3LqS4ggLa3UvTptLyzrpuNb9XiILKcRaJiAAPUNNvPJiiOY6kWqDIn13A\nYep1k6hJCJup0eIePXYpsDtfp4CW+SrzCZKxD60VnLWpqzdmCEbkvs+t1mBc\nQJySTd3/NX2Ze8K0tewWjNXWW5d/CbdHSoZnj6b3eC2VcVfAqxmqkhag5ZU+\noX9d\r\n=TRzZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCWSzPuHpt3FkMnCvt0PxsyCvEm9r/XBWkJqKur4HQAKAIgWfFJKDmx9+b9hHSc2bfL7P0Ydco7vdBOAecJe71+KhI="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.0.3-master.b9e75e5_1544134206380_0.8347553611058749"},"_hasShrinkwrap":false},"2.0.3-master.804f4eb":{"name":"simple-update-in","version":"2.0.3-master.804f4eb","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.5.5","@babel/plugin-proposal-object-rest-spread":"^7.5.5","@babel/preset-env":"^7.5.5","babel-core":"^7.0.0-bridge.0","babel-jest":"^24.8.0","babel-plugin-add-module-exports":"^1.0.2","coveralls":"^3.0.5","jest":"^24.8.0","regenerator-runtime":"^0.13.2","rollup":"^1.17.0","rollup-plugin-babel":"^4.3.3","rollup-plugin-uglify":"^6.0.2"},"gitHead":"e91308282ffd5e8ae2b78c269f9bf65a6be5431c","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String\n  )[],\n  updater?: (value: any) => any\n): T\n```\n\nOr the asynchronous version, which you can provide an asynchronous predicate or updater:\n\n```js\nupdateInAsync<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): Promise<T>\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.0.3-master.804f4eb","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-2Ifef2N0Uj4dCjEemY7iBz4erEHySJ7Mfilb3CE1e/IA4GfJlF/TYzEDDzhQDi4FFXO1CKZ+TRwx3RHTi8FezQ==","shasum":"dc0f5f4309eff1eaadba43a935d6a934b3f6a507","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.0.3-master.804f4eb.tgz","fileCount":7,"unpackedSize":48359,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdMA/BCRA9TVsSAnZWagAA8isP/Ra+OYhftJYHUCGfEF5j\npqyFyXoUw4akuOp6+t3Te15QBje7rQfYttonASHQnnY2t0ziqs7fZmXWZ24O\nY3NqDWOuN1fRBJLZRoGFDq3nS4br3Rei3invrW51RNN896CSP932qpYD2sU4\n9C9s51XNOMBFn0AydGO/daOUX8yRWftsjtTaBPsp2gnM41GyP+p6LkVTPnWS\nZTwLDM5GNqnLHhZiJOxNe353j7SXTWGItrsb39ppiM1Uz/vKHjE7BUtxpfS6\nnkDEZQqArm2E9x9ODA667ypZERkiYZ6ekrZZw5Z59o89z0/7vZeBEqWSGjee\nqRRDX1r3LPDS52E2hsgHNnUjX5LxNJdQV0jyn+m7QZGS0GzuXPNhfg/hwrcE\nQokXiAkOx4NNjSrTgB44NMC4NGUm96QLt8bZMPl4FECrsT2/mosA1engDs/Z\ne6s8QrVgKkXCZXaerzSTo16mh94m2uicUci0nKmyVDB/6UHFcsn7hx9lnnKv\nAmfParM9zHgLe0vnJLNuveH4zNEroE4LUIFhFOgUO0chryXqWNUC3gN30fHV\nH4bP5pg2wU8CxPHf6oFJfyNcnGTm615SU3ROTQWg9pTAX8gAjiIhcBZpH7L1\n5pp4FaVd/NQOxzD3iY6I6wAIjSoSeBj2vWjmBFnH+T74a2yafqM1J1U0MmuM\ng3gN\r\n=Hh4H\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICc9LucYwXUxRxKrpzTNWBvwFHn2foOneRZZuqqu62DCAiEAgb6msUrA8e225C3n74tfs2+r1t1wyQ9RkwjM/g3Fvew="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.0.3-master.804f4eb_1563430848763_0.9682778408541461"},"_hasShrinkwrap":false},"2.0.3-master.fc7fc52":{"name":"simple-update-in","version":"2.0.3-master.fc7fc52","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.5.5","@babel/plugin-proposal-object-rest-spread":"^7.5.5","@babel/preset-env":"^7.5.5","babel-core":"^7.0.0-bridge.0","babel-jest":"^24.8.0","babel-plugin-add-module-exports":"^1.0.2","coveralls":"^3.0.5","jest":"^24.8.0","regenerator-runtime":"^0.13.2","rollup":"^1.17.0","rollup-plugin-babel":"^4.3.3","rollup-plugin-uglify":"^6.0.2"},"gitHead":"7d091d4e2b7463415ad5099aa02546f111f25db6","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String\n  )[],\n  updater?: (value: any) => any\n): T\n```\n\nOr the asynchronous version, which you can provide an asynchronous predicate or updater:\n\n```js\nupdateInAsync<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): Promise<T>\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n> Note: for security reason, we will skip paths containing `__proto__`, `constructor`, `prototype`. This includes [predicate paths](#using-predicate).\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.0.3-master.fc7fc52","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-spsDMFMh/QNImDaMR7OYB1pzNyaXc+IyZAUPuZdhvxu6+JFY1c2s4VvoL2gm5BoY0FFwnwMd/TiNvcR1izhojA==","shasum":"ab3b930bcacbb8d9829eab23f447351fe8c1b373","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.0.3-master.fc7fc52.tgz","fileCount":7,"unpackedSize":49110,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdMCi4CRA9TVsSAnZWagAASq0P/AvFW/5LUCm0yhzmCS3u\nopcUddvKmkExwV4ijWmeEZCrJKXUKZamfamKVDB0U5n9OAHeM1r+vb05Js28\ntjTu61TW2GhZn6XQDiT7g1pt0EJiUMfr37gDJYFdSic/vhFe2FQlyIQIBmmg\nTSELTAPTctQTrgigdgFqmqwAVjAQwhQ3CHqJzodieUsjvU13q/AHnnGNmClg\nM7ZRls7sfqCWxYgmRrSwELoBSay0ViCtkpWlMpktxUiD+crrjRDhZxgD5hi2\nfYqEtC2vENBeM3FhJwaActGQEpe2AGRs0GtLZFQLU+T9UMLO+0DakEIKB1vR\nENX4EPQVTfJwgjgaQTWai6JAxPA5gSQI+AO0ulc91b8WU8eLxzN9CGcX80Qa\nuuz+8WpKdYWDh6oK+gL7vjmzHZ7X/4/QLSDwDOuxYFw9b42aW4jbWKxeyROv\nWkH8eg7iuMNVcQRW0joy9wzQcDiD1ki0AGUuiZlmUYGc7FBWJI1+Sp0fHQsL\nKX7eDOeTZ5VBYujLZWQIOiWFwMDZZJ5q5KRgSpFqMGNl8NrCdort3F76HYQv\ndgsC/WVTJAoqPJDQ3++UiBQ/EPd92UQgr6Y1+rJQGo0qcxbp9ouYgJKtsMVb\nn15PFCmrYAJIXXHvDX+ZIfcRuZaItHy0B8/maI5qoF3q2ExT9IaQ4WwTjN+f\nwYw/\r\n=Tiut\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFdMbAyIe4seinhH8JVBm+qfXbzNHd1BlM0lvji+ghQaAiEAxf6LbI0QBM33NcrtxoCfGv5tu/d7y5hMkludpMdjxEE="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.0.3-master.fc7fc52_1563437239751_0.2945558746225625"},"_hasShrinkwrap":false},"2.0.3-master.48dc5a9":{"name":"simple-update-in","version":"2.0.3-master.48dc5a9","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.5.5","@babel/plugin-proposal-object-rest-spread":"^7.5.5","@babel/preset-env":"^7.5.5","babel-core":"^7.0.0-bridge.0","babel-jest":"^24.8.0","babel-plugin-add-module-exports":"^1.0.2","coveralls":"^3.0.5","jest":"^24.8.0","regenerator-runtime":"^0.13.2","rollup":"^1.17.0","rollup-plugin-babel":"^4.3.3","rollup-plugin-uglify":"^6.0.2"},"gitHead":"217669c51c7c671ddd4539902706ecb3b358d1ca","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String\n  )[],\n  updater?: (value: any) => any\n): T\n```\n\nOr the asynchronous version, which you can provide an asynchronous predicate or updater:\n\n```js\nupdateInAsync<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): Promise<T>\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n> Note: for security reason, we will skip paths containing `__proto__`, `constructor`, `prototype`. This includes [predicate paths](#using-predicate).\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.0.3-master.48dc5a9","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-Yf5yKplU05y5sCDkf8khjw3SaWad6KEPao37WGYBAzkLz0OrbVq8iFxDQ/i08q/6MfJz7tpO62hmbGPA4Cu5uQ==","shasum":"af49a37782ebb7e1e8964bb4084e87d1be00da7c","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.0.3-master.48dc5a9.tgz","fileCount":7,"unpackedSize":49408,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdMCvKCRA9TVsSAnZWagAAUMQP/0RpJSCzQ9O1ne98ySmf\nzk4UH+u9G9QW6DZjvWjLHc7nDR6oDMDUM2ja8Xt7aMaA4YpFyIgPf/q+MUK6\ndIzpTuzYIVwPsiTunjcjI+Xq+dXrM8l2XA+xTfF6Wk7me051bheE10vAI5jN\ntRiWiJ5TONDOayoAiN1hY70Y+G8KoocXfKyszsgD9TnzyN3g7r1LNVXvO6Xy\nhXaV+Hw/rPbo+PHp4nSFepiNJe7dmtKKsrHiIV+gUAFIHksoSZsgDBzTvZRN\njg/MWupL5U18N9h3aFas5RJ0dn0thAqyzMJzuI1WtylUeeil8/2xPCIZE8Gh\nQModZytJF7tlkcrlD3CGxshCNVtUFj2GnQiEiroo9rmz5/+iv2aV5OmhfPxx\nHWRVMREjLyAI5nWaUvIl0FvCeDaUqURN/zwRTLiO8lTHCj/9MH6Wz1weok2K\ndAhjSw0O08w3O2q4SlfePbxsJe+4wgDs0c4DETtdO16xGnmjsvZYFZKw6F5M\nvC1hbf2fcT4/KSoBxTfOErM/P7UG0vSd7mjnDeDEIG15VSqTTE0dxmMbA4Nr\nb+p/62F1A4EZZ2Co6V0R9axlN5MqXgLvHlMNopdm1bw5O4o5LDQKQHsRfNx2\nfXmifHwT9sv7F/5AlOZK0jOc67ClYPnzocyoQMJg0nAr4yGA5EmjppL6uY/9\ncfoG\r\n=lCTb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDkJR/RxWSm5tM+tssiUW1Rmn5yBFi+59ucNjdt7fjGNAIhAJZRcgaBYVi0K+dKnotGxKhJeaMlvMFiTNOp09gIdvkz"}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.0.3-master.48dc5a9_1563438026146_0.12166219669681233"},"_hasShrinkwrap":false},"2.1.0":{"name":"simple-update-in","version":"2.1.0","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.5.5","@babel/plugin-proposal-object-rest-spread":"^7.5.5","@babel/preset-env":"^7.5.5","babel-core":"^7.0.0-bridge.0","babel-jest":"^24.8.0","babel-plugin-add-module-exports":"^1.0.2","coveralls":"^3.0.5","jest":"^24.8.0","regenerator-runtime":"^0.13.2","rollup":"^1.17.0","rollup-plugin-babel":"^4.3.3","rollup-plugin-uglify":"^6.0.2"},"gitHead":"a7bc03c23a4dc7ab713192944cbaa2dc20ed2d12","_id":"simple-update-in@2.1.0","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-rdBChoQh4CERbQhWFbnMOG0P8VYx3vhrY4Gy4//wj8x12cydKnjzpJBpOO7QQGSssuc04jgz9zsrxczjQkEtZw==","shasum":"3dfce99344efa5d8e59ed63e63dbd4fb9f7cd98a","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.1.0.tgz","fileCount":7,"unpackedSize":49417,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdMCzfCRA9TVsSAnZWagAADUIP/2m0CHnKihEtT/PbXLh8\nQ7VUrba8T6DvbzcBuvs7yDhbunVjBP7fU1Tv4lMO2Ygu5WIxJv1Kt9PudYzo\nEgcIm43eIxaaH4l4Qd0W5y5GCkavPHYCu3y95f8vms/mvdfy3il6rf6NRgah\n8+rWHzU0et2lt5yu1X0+a5pA2wq4DM6dBWfkiDEizhbUVXCIrvi2j/VpELax\nPhrGbeo7j546O93IhOkcP1CFRSh7PfVyCP11gLDSoUj8cS8vSYXYIc/c9CSp\n4Ky920ayvcEqvOmYbd9UKGHfPYmNrUJIjVE5Gryk5/LCstOqITgW2pL35/Ik\nZlkGvGzULQxjv0rhjpYgpkhWQhIoHk4SErTF3ClAZVDnCHXqHxO7ZGDzVTUl\neb4kuqSC9QQ3euh5RLxutwZ9RYpvEBP5Se6sSSw1LoBD6ihgNI9rScyO6mDT\nqGh2ah3UOefnJdPr7mJ3Neux8lTqN6mIr7K6bWA4SUP49oPi1dGn1/Lq/Byx\n7QwJUup0JHM3Xp9LWaVKrWa709tn0zTak4JYEYUgiMA98eN1iGOioyVAkQFZ\nrervIXOSzK5WKujf+9xq8qJqZ5bk86X2raEBLEpFT4eukTc18AHMRSQHettu\nkKJ12bYLYhjYTweVMQfnkfi5S5F2mKtpNWpQGB++9U2OcWKOVJ5iW+hP8zdY\n+CZ8\r\n=H6On\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBmFz8olJ60dB6ojzbu//C3D2Cyjx37UJvq//hzrVkRcAiAisMeNEm/ESlNtU4zEdpTVVzGvQMtDWWhjpmR56NXCQA=="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.1.0_1563438303070_0.77852030664938"},"_hasShrinkwrap":false},"2.1.1-master.f1f8c14":{"name":"simple-update-in","version":"2.1.1-master.f1f8c14","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.5.5","@babel/plugin-proposal-object-rest-spread":"^7.5.5","@babel/preset-env":"^7.5.5","babel-core":"^7.0.0-bridge.0","babel-jest":"^24.8.0","babel-plugin-add-module-exports":"^1.0.2","coveralls":"^3.0.5","jest":"^24.8.0","regenerator-runtime":"^0.13.2","rollup":"^1.17.0","rollup-plugin-babel":"^4.3.3","rollup-plugin-uglify":"^6.0.2"},"gitHead":"baa803ae74960371a668e59896c7d898a0d0319f","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String\n  )[],\n  updater?: (value: any) => any\n): T\n```\n\nOr the asynchronous version, which you can provide an asynchronous predicate or updater:\n\n```js\nupdateInAsync<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): Promise<T>\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (triple-equal `===`), then, the original object is returned.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n> Note: for security reason, we will skip paths containing `__proto__`, `constructor`, `prototype`. This includes [predicate paths](#using-predicate).\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.1.1-master.f1f8c14","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-Ha9HMuSRX9XAFyvIEPltxvyTEzZZ/odXLnx0Gay7yIwUINLLR66FqLPTGozqY2XPQ9Xv3oc/MalO+Hw1Gl2N/A==","shasum":"b7fe7f35a9dccd7ea8ca0bb12906e40db442552d","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.1.1-master.f1f8c14.tgz","fileCount":7,"unpackedSize":49432,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdMDEGCRA9TVsSAnZWagAApYgQAJXNwWHJe8E6nPoCucTi\n1zBI0CINljNbkFGiFR3N6QQnNtXhpDrzQa2SgBHMOP9neZIrXd93HzIzh9TU\npqKe7ak9jHuG1fZO5mpLguAkMZC/dZVDFaaIOu2rwwyvrjrCusOypxE4Wozo\nYu8qo4N0itHN2HccBnhArpqFl22NOZpw4j9uVEODUJegy7ZwPlkUlMvNNXxs\nL8HT0j4/zijtfMsh2h0YUW65X7CeXUh8PnwGNCycg70LKDzmEMxqy+3mfmup\nsGdfUXxXQ+CT6KEgTpYJzwLC/+ivi4cSDai9aVNmgM4EgGQcU/rRZJVhiUax\no7dBgTT5LcFMm0k38hRbO8Qd0wV3GevyuTuzjh5p5Y48z23mdu3AIB1e08uH\nkv8mVbxEmueoUJoxzYPz3rBqGK2FhHAWTeXpD0lfE+4UnG9EXU8cCc/Q8NHi\nW3udQP8svRTTE4wsC6D4YnJ6z+3YXAK+ceq4OzvSPu+4cQFMhmN0Tl/CVCgt\nSr93ZlikwTjJa6noYeX7X1gsa5qJ68nU0UnL0tHbb9FOnwk3JzC7krWbi3YR\n6ko9PMS32ApXoDkI/TsioffYsVCKHrfEnR24mhDsRaehwx3QurZ+sZgLXMkb\nZGhP3OONXBlPz88spg3gL5Bx1tdDkwi5khucY7e6G4yKdk6rnyuAkF20ETGJ\nkI7S\r\n=0pJ/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAXI/o8ah42Xq8+8hfBPfIBv/mShBaROdKJm5SdPgfzjAiEAmlD1ayrHdsptWye1MUYnjWz/f9su+PQahgP2aW0r65Q="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.1.1-master.f1f8c14_1563439366057_0.14796281120292032"},"_hasShrinkwrap":false},"2.1.1-master.8661c10":{"name":"simple-update-in","version":"2.1.1-master.8661c10","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.5.5","@babel/plugin-proposal-object-rest-spread":"^7.5.5","@babel/preset-env":"^7.5.5","babel-core":"^7.0.0-bridge.0","babel-jest":"^24.8.0","babel-plugin-add-module-exports":"^1.0.2","coveralls":"^3.0.5","jest":"^24.8.0","regenerator-runtime":"^0.13.2","rollup":"^1.17.0","rollup-plugin-babel":"^4.3.3","rollup-plugin-uglify":"^6.0.2"},"gitHead":"c299ce41fec17cf032d7517e0de044ee8b2add6b","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String\n  )[],\n  updater?: (value: any) => any\n): T\n```\n\nOr the asynchronous version, which you can provide an asynchronous predicate or updater:\n\n```js\nupdateInAsync<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): Promise<T>\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (via [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)), then, the original object is returned.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n> Note: for security reason, we will skip paths containing `__proto__`, `constructor`, `prototype`. This includes [predicate paths](#using-predicate).\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.1.1-master.8661c10","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-do1ntUw2iBoFHoSTwTDv9RWb9U6Npf1KCypMYA5mlgIA3AxRncSbR4jbeEPaMoSc6473TzVoZUZX1ry4oUam+A==","shasum":"f639082d16b9ea6c9d4cc0d5879ec27da2a6c9a2","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.1.1-master.8661c10.tgz","fileCount":7,"unpackedSize":49523,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdMDPmCRA9TVsSAnZWagAAqaUP/2x6PHkaugniJYZnIohP\n+7xBJN/ncV9IU7ww00lW6jjeeLbhbSW0wp40HEJ65cmWw4trthM2c11A6fSg\nw7SGrF/gkyPS+FT6/7FUouR1oEUrJSzWs2Q6GZ//LRm/wgVqxMTpzFzUBnRA\nf2JgfqxTHntOUbb6kAcAdoCUpE0UxdAN5t2+R8L3El48rEEpk8mZpw4GpM1Y\nQNrabFrNXpzkGs+lgYKPAgokqePn8RIP33krJG4jhAOKFCtoL5SaA7maAkBt\nMFvfPsXuIwyD2O/Ar1XGFHvIYHDfAtH5YsXUXRj4oIb1MwQRjhjQCSJTyiUV\nYL8RrUh/UZeFBRXyaJ+L99XBATQzNiayza2zWr78K7Iw6/n1JLeRkrPoBDcn\nKy5X1yFjVzjvsqH4BETjTEjUGIeFQ1xTm9vGzNpz2e+6lJOmqnnv7lDiq8TD\nCb/Iulbr5vQibr93zCc7sSHARetjh7D0eLoB2YYkZmIJaJSutG4qFx5CFehb\nZfmSarsLloOu6aS7bFBZUHVf6vrG6awWPcUxhCAsnsd0fMEhGl0Pqmc0p+O0\neoPEjb93R3wMidUiDjRIKgz59u/YOODxuRrPEpSNkhTVyAmgQWiJ/xmvbwG7\nuLV/9b0X2bRGxBmm6FqVCREujd97LNxkrvNYgi6Fp6JAedMQFhh9w/sE0OUp\nU1yA\r\n=mys2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDFDHzdfi2S5Lo0e9ewx/Z+jmu/xEWYR0qFEj/i+nqOzAiEAmHkiJ3xeuT14AD78r+NlwT7onygcWkeR0NoYEDFh26A="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.1.1-master.8661c10_1563440101816_0.305088853194893"},"_hasShrinkwrap":false},"2.1.1-master.99f56bd":{"name":"simple-update-in","version":"2.1.1-master.99f56bd","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.5.5","@babel/plugin-proposal-object-rest-spread":"^7.5.5","@babel/preset-env":"^7.5.5","babel-core":"^7.0.0-bridge.0","babel-jest":"^24.8.0","babel-plugin-add-module-exports":"^1.0.2","coveralls":"^3.0.5","jest":"^24.8.0","regenerator-runtime":"^0.13.2","rollup":"^1.17.0","rollup-plugin-babel":"^4.3.3","rollup-plugin-uglify":"^6.0.2"},"gitHead":"61bce2bf98af763870bd9355b71c06f99a498746","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String\n  )[],\n  updater?: (value: any) => any\n): T\n```\n\nOr the asynchronous version, which you can provide an asynchronous predicate or updater:\n\n```js\nupdateInAsync<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): Promise<T>\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (via [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)), then, the original object is returned.\n\n> Polyfill for `Object.is` is adopted from [`core-js`](https://npmjs.com/package/core-js) to maintain zero dependency.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n> Note: for security reason, we will skip paths containing `__proto__`, `constructor`, `prototype`. This includes [predicate paths](#using-predicate).\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.1.1-master.99f56bd","_nodeVersion":"10.16.1","_npmVersion":"6.9.0","dist":{"integrity":"sha512-k1XoaeQu66R7tZiedc/HsLcqLKcupZxzZOuCuu1MMLJbL93Cjl2ftkwRDtYVs4dxfn/b6ciP7MDEUfhkaWNLew==","shasum":"17679cdc02e48bc7c75ef67511a405db5a4691e5","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.1.1-master.99f56bd.tgz","fileCount":8,"unpackedSize":50659,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdQ6PKCRA9TVsSAnZWagAAmk0QAIaF3TEu+TcBz7XnzgbH\neaVNJkib/idAD4zzkHPcp51227c3fi9keikl3qHeE2BYvNCVOGbD7qANpz/n\n3XvlO2PmP2LIWs3wvUa+Yk4FWlRfffrF1r1FcsGjkP/J2UqyLTukolUjbnwc\np/wpMhS1MVtmfgaOCKtgvoiHC52vq2EDTYzf+d594GcFVripBHBIqXWcj6NO\ncFJGCg9QgTzwru2vAPX6/XT12m3EFpWavsnvL2MME89ezL3uTzVWuNUuhK1E\nHdMiLU7lRNep/tROvU8gZINnZcUuuOXDx66C+XMwG0pMTHp5gK3UkUYfG8tl\n0yJTXvPPiddzhItJ5DPP2pRG5kyYaiHjm6MCMTbpsy6CeUaeJPenvMNiC2lU\nTOgR89GnKh/UAUb59PXmtcVkeE9VYR8iOCEa68AfO+2NeVcCzUygyi7xhst2\ntYJG7vZobmcFnkUZV/NOFotqwbQlouzkuuxGviAjNh5Ye963NE9aN8IheIDG\nuGKSorjxK/AKjTJSstJc2aHockvYj+lxm/Et2QQ0pfs03aTwA/umfkWp24UZ\nG/bTIx2FKzLUOoNvkNxhM1uuLYI8ybT2XsFg6GwQ2I3bDmaErb81YviHNmge\n5njt+BJm4f85SRWF4DulThLs3s8fv9UuX28l1YSBb710CUAgMe8KQmyLvrSP\nFSUi\r\n=h2Ic\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEqTPt09MqQ10kJHS+ieB4mdm1CAkMnQ458uyQADfRNGAiAAgS/X4LnxErfVG9yM4kOo6koN1lSicRBDEpvVhe6feg=="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.1.1-master.99f56bd_1564713929791_0.717840044137052"},"_hasShrinkwrap":false},"2.1.1":{"name":"simple-update-in","version":"2.1.1","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.5.5","@babel/plugin-proposal-object-rest-spread":"^7.5.5","@babel/preset-env":"^7.5.5","babel-core":"^7.0.0-bridge.0","babel-jest":"^24.8.0","babel-plugin-add-module-exports":"^1.0.2","coveralls":"^3.0.5","jest":"^24.8.0","regenerator-runtime":"^0.13.2","rollup":"^1.17.0","rollup-plugin-babel":"^4.3.3","rollup-plugin-uglify":"^6.0.2"},"gitHead":"f756a6161d1da321ac7010f30a40d1f46712b954","_id":"simple-update-in@2.1.1","_nodeVersion":"10.16.1","_npmVersion":"6.9.0","dist":{"integrity":"sha512-Iw4tMvOoibV6XqOqKgKgpMnFdgEtafhZv2KxNhHPAgXBtKrCTY6QFxMpvmSSuRHMK5uJ9hb6X+zniiTHVD7Sig==","shasum":"f53d75b3fd035913d79e100b2f36bb81058ee5e5","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.1.1.tgz","fileCount":8,"unpackedSize":50669,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdQ7LVCRA9TVsSAnZWagAAdS8P/1BsalPtTJbSxFkz7aan\nh/o9QLa5A626MieeAmn7s39SiD+N2Wf6a7QltaQVtZiPlurfrGIH6nL/DD3J\nC9pessGlLKIGJ1ScKF/fJyo31zoTd3DFNhrzkdmXsJORi7MhrluXJQl3XSTH\n3qFVUWvqq/Df9zQqeD5kicArQoRGa5nuJUhiaBi1+OCkvPfewQRlR4igMrXE\nvAiA47ZviUFQcsl0ZxgmCQiTlUuWnHn5khl2xYGZVRrFzHRDVTeTaCk3GwTE\nktd8BCAAkzH/Uy5qwwH1VrlONvpdYkvZcKxLEkwCyuI7pZDMHevKowWYqrbx\nLA1k05lBQW61zEiYr8IkvsMgBkTkQPk48hA+VS1ztZDnmvRmSdPRi0YS92jV\nJl7E+tjf5NREFv5M5ePesBo+aMykFdcm5OpTBIFmUrNKXlvYdYEcrGa+cSWq\njNmSVV5+xJlqrQuA9i4+zJEljzXGVnx4G+y9ZDJ5kcyxtRKHry9rO4E7ZdKK\nkYs4WPzV+F4lf/t5SQAzQO8A5B92xTd0GpN/nrkqlXeqvwJAWnm3AR1k2t2/\n0Qw8Krj7fvWTdBS2dpWQfIvxmaTOIIgYRbf7lMikQVk/qT3CgQsr0gTe2aom\nWoA1lqcApzTgSVdySH8a88QQa5XTvN1PJ6TkqHlps8pmw5t31KeFYd7fNCzm\n0mmC\r\n=qWpc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBNHgOP4jtLYeBEsXj1j2hfmh7so0YwGh/r0h4EeJTxpAiEAuexoeyyKjbF2XbvMcSwLykRuIRHGIa6OnfMNeT6mlwk="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.1.1_1564717780431_0.9178113024769954"},"_hasShrinkwrap":false},"2.1.2-master.954b348":{"name":"simple-update-in","version":"2.1.2-master.954b348","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","clean":"npx rimraf coverage dist lib","coveralls":"cat ./coverage/lcov.info | coveralls","prepublishOnly":"rollup -c","test":"jest","watch":"npm run build -- --watch"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","jest":{"collectCoverage":true,"testEnvironment":"node"},"devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.5.5","@babel/plugin-proposal-object-rest-spread":"^7.5.5","@babel/preset-env":"^7.5.5","babel-core":"^7.0.0-bridge.0","babel-jest":"^24.8.0","babel-plugin-add-module-exports":"^1.0.2","coveralls":"^3.0.5","jest":"^24.8.0","regenerator-runtime":"^0.13.2","rollup":"^1.17.0","rollup-plugin-babel":"^4.3.3","rollup-plugin-uglify":"^6.0.2"},"gitHead":"de249e121951fba57f2ea0d768bb14a6d334e08b","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String\n  )[],\n  updater?: (value: any) => any\n): T\n```\n\nOr the asynchronous version, which you can provide an asynchronous predicate or updater:\n\n```js\nupdateInAsync<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): Promise<T>\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (via [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)), then, the original object is returned.\n\n> Polyfill for `Object.is` is adopted from [`core-js`](https://npmjs.com/package/core-js) to maintain zero dependency.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n> Note: for security reason, we will skip paths containing `__proto__`, `constructor`, `prototype`. This includes [predicate paths](#using-predicate).\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.1.2-master.954b348","_nodeVersion":"10.16.1","_npmVersion":"6.9.0","dist":{"integrity":"sha512-cN+928ANV+aobw+wEWUKhgYo6jTLIumPMlojjylOiMrXcT0A0tzncJxXnr5rOYnXlb45lvsJeGgbBJqNhxHmSQ==","shasum":"8041951dbd670548b96712e1e4f97c888919ee26","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.1.2-master.954b348.tgz","fileCount":8,"unpackedSize":50684,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdQ7aACRA9TVsSAnZWagAAyeoQAJn2ghFyGADY28FVTZPb\njNQusn6dQYohAjOUqlgxCPgxeXFcO0f1Lt9qp/O3bhd8D9a8vG0cKfziBqke\nD9GcriJxjprbDQXY3B9ojeL7bn3BIqiJxv5jOl1NuCkApxNvBwIW3dDpJ9eo\nBz2kvMf9yle0YM8AnoU2JcK4ZbuWjcMN6gFlVQ8mzsiOhtFPBqb5Sa4X7bmF\nN4g4m6Wai2437skDTN7R7rQQ40Kd8XOan6/gM/1KcHyAqXAhaIvYizGY4ZCm\n61sY1iJirCaysxUu+whMmdV3stApI/7nfSXz4Sp48SNPgA8oriHhQqPQWhu2\njBJHPAxfUOs43IDiq5ox4q4Uhp+uAAzZcbgLrfh8MJ9BLbOW4WghANrTVqAu\nC3mA7zoFGuHk+TgJhSRw1V5IdTBomJSiYiAzH7lDA9fGNGePRlrEo8hIzK7G\nNLiHYoRdO2UoxjSBPl4yO7he+THaccM3R/P4dk8MFWwixkoAHpPnrbvsdjem\n8SqPGdVycYEv3Yn7/HpYMc2f6GosEjwMr2VC42VrvwV/65eE/yNnQo0ogFI4\nxX6JG8rkaaAmuty7kpUtLykttL/QRZBUzh5wGZ1FbkPQXgjjd2JQy46dh/aG\nHUwHLEHcmCIblu4mBCDJx6ykfHVVKHFJ/eBasHO+h/EIspUDqfshE7sJDnv7\nJ5Xd\r\n=NkX2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDsQRPNC+jm/Q+kTY03fgSiVTuqjsGK1JGY8hmSuF/KBwIhANrD2TwaUZBVCFjfr4tfbcGHu7lPZaRaTe4FO133t2vi"}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.1.2-master.954b348_1564718720073_0.7910885411429609"},"_hasShrinkwrap":false},"2.1.2-master.e25f669":{"name":"simple-update-in","version":"2.1.2-master.e25f669","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"npm run build:babel && npm run build:rollup","build:babel":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","build:rollup":"rollup --config","coveralls":"cat ./coverage/lcov.info | coveralls","prestart":"npm run build:babel","start":"concurrently --kill-others --names \"babel,rollup\" \"npm run start:babel\" \"npm run start:rollup\"","start:babel":"npm run build:babel -- --skip-initial-build --watch","start:rollup":"npm run build:rollup -- --watch","test":"jest --collectCoverage true"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","devDependencies":{"@babel/cli":"^7.8.4","@babel/core":"^7.9.6","@babel/plugin-proposal-object-rest-spread":"^7.9.6","@babel/preset-env":"^7.9.6","babel-jest":"^26.0.1","babel-plugin-add-module-exports":"^1.0.2","concurrently":"^5.2.0","coveralls":"^3.1.0","jest":"^26.0.1","regenerator-runtime":"^0.13.5","rollup":"^2.10.9","rollup-plugin-babel":"^4.4.0","rollup-plugin-uglify":"^6.0.4"},"_resolved":"","_integrity":"","_from":"file:simple-update-in-2.1.2-master.e25f669.tgz","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String\n  )[],\n  updater?: (value: any) => any\n): T\n```\n\nOr the asynchronous version, which you can provide an asynchronous predicate or updater:\n\n```js\nupdateInAsync<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): Promise<T>\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (via [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)), then, the original object is returned.\n\n> Polyfill for `Object.is` is adopted from [`core-js`](https://npmjs.com/package/core-js) to maintain zero dependency.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n> Note: for security reason, we will skip paths containing `__proto__`, `constructor`, `prototype`. This includes [predicate paths](#using-predicate).\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.1.2-master.e25f669","_nodeVersion":"12.16.3","_npmVersion":"6.14.5","dist":{"integrity":"sha512-az6a5vzV0McAI6ekgvqB73pAcZTeadzSwgZ3ZVh43Lzv8pJWYpGQC0+JsTw8202TNa3qnjrnHMENSNwzDhWw1g==","shasum":"3ef6457d628db92eb8d3d1e0310d1a3c44f20525","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.1.2-master.e25f669.tgz","fileCount":8,"unpackedSize":54279,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezKZPCRA9TVsSAnZWagAAERgP/iH/JP+NpfKKTCrTt0zI\nZALYGJaRcjtuu8oCbocJJMUMtGLoRlBaeegud5WqrhDc+N0YuEXfG1mtVX0X\nnKibFE8dn/5A1L5E4Y3ZW/+0FKd5FExnRyGNyH1tYuhs3RdBR5mP9lJHGUMV\nm+FVh8LtauUvx+dVFcSrJrCJ1T3cBobsyo0qmrs1Y3niZxvsG07NIkkreRrY\novD1LsBkIcWFoXQT6DwMTEcWNO4XbGy1aPbC0IiRaBNu0sHRRJPHbqvAzt7n\nbU20ZT+0auVYWnVal8lSAum5yAS5fN48XBouYNX1mcAKOeNYuLD8B43OKyoz\ni+me1H2bVWjmBvABcCVSJEMB0kVy8t77zkTYiRkgvUPMrDFge+/LLB4IIGxZ\n4OGNDUamLrWrpSbvtUOCEbP3e1D4DoqAo4vezwGDhuDZfKUXSylX8HMUjQxz\nBdP8buH0GCw/aDqegz3ibEBwmjN8PjGUSEsb2DnChuA8MNdYJIA40y4zwC+H\nfPWKZrmTvjNbl2F1GXjOBg6JTXMUMcnL2lXN4ndPlIMeX8dcxlzZNHlyjarT\nkDhwCe4VlJqpMRqRuqhxMzRxW4XYHnhzIa6xEipviwG4WR2CzrK5tIN/MQps\n02PUeolD7t6Gq87wOUyqR8Mdf9QZ1LxnEkQQrhfjDBHppQeFQwwYZ/4SrKGV\ntFLX\r\n=uZj0\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCWvfynnQxrslSe8EcCEA5wgItyrASKX5+qJa+KV/vdlgIgTRmBTb0CAJwzhe0n/Bhj+8A64TMYCuvucLtnJ/47JO4="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.1.2-master.e25f669_1590470222699_0.11439094781494319"},"_hasShrinkwrap":false},"2.1.2-master.1334b62":{"name":"simple-update-in","version":"2.1.2-master.1334b62","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"npm run build:babel && npm run build:rollup","build:babel":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","build:rollup":"rollup --config","coveralls":"cat ./coverage/lcov.info | coveralls","prestart":"npm run build:babel","start":"concurrently --kill-others --names \"babel,rollup\" \"npm run start:babel\" \"npm run start:rollup\"","start:babel":"npm run build:babel -- --skip-initial-build --watch","start:rollup":"npm run build:rollup -- --watch","test":"jest --collectCoverage true"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","devDependencies":{"@babel/cli":"^7.8.4","@babel/core":"^7.9.6","@babel/plugin-proposal-object-rest-spread":"^7.9.6","@babel/preset-env":"^7.9.6","babel-jest":"^26.0.1","babel-plugin-add-module-exports":"^1.0.2","concurrently":"^5.2.0","coveralls":"^3.1.0","jest":"^26.0.1","regenerator-runtime":"^0.13.5","rollup":"^2.10.9","rollup-plugin-babel":"^4.4.0","rollup-plugin-uglify":"^6.0.4"},"_resolved":"","_integrity":"","_from":"file:simple-update-in-2.1.2-master.1334b62.tgz","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String\n  )[],\n  updater?: (value: any) => any\n): T\n```\n\nOr the asynchronous version, which you can provide an asynchronous predicate or updater:\n\n```js\nupdateInAsync<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): Promise<T>\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (via [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)), then, the original object is returned.\n\n> Polyfill for `Object.is` is adopted from [`core-js`](https://npmjs.com/package/core-js) to maintain zero dependency.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n> Note: for security reason, we will skip paths containing `__proto__`, `constructor`, `prototype`. This includes [predicate paths](#using-predicate).\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.1.2-master.1334b62","_nodeVersion":"12.16.3","_npmVersion":"6.14.5","dist":{"integrity":"sha512-2MqIerOPKVk+ZnSsWneE4zSH6Tk7VAkgwXNAjVnkpNUF3EBu9WoaCZSx7KISL8Qqpsjv6g9mn21EKSo0cG+FiQ==","shasum":"ef8e19e98a0e5b2927b71a6d0b615d10b0967632","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.1.2-master.1334b62.tgz","fileCount":8,"unpackedSize":54279,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezMIYCRA9TVsSAnZWagAAI6IP/13LEIX1TFE5/RGUQgjg\n9S3CqJF8IvKp3fVuNhFXkxyaVuu7gP6Ehpp95o6U98oZv7R1bNZ3mfbh61VI\nW9Wv/z2Zv0o/0r7xmEtNo76zR7Nxpx3G2ZkOU7g6TW9PbjBsWzxH50lPOA4k\n02ALGZuV06UtAS9Bn0B9Dkobccv07JbmtsyOvzTNUcPF2cTDAyJWZEaWKnH0\n69LjHUh9ihunxChSyKUT40w/0ZI/0SxgpNacumbCIiYvc6gceNw13DY0OLOY\ndbz9ydxOec/Yvpp6x5rqcCfVKvs25uC4+0MpifFR5tcq/9GU7KYnppUNf+uJ\nN3DxTn82CyvOoIq2w9HIzQSSDGhcZ1ARMnkm4wLGt+uh13iaK9WIb+pz/2Uf\njz3T5PjpCWb+ZgiXq+wAiRAaccm82FzgKf/iDrDM/ZMrCkFfein6p+ZzNKQr\niTJedXP97knblqyeot6XeSqLVTuQYv1IVcpBpNxZNQMx3yXANd0ZDhNCqkmD\nN4DdHTlIEI9SuPR0eE6MOw3Q0a0LV++YqDgNjsSxHguqZ/1/oOFruVnMqwqW\n/gmdICwjx+0XU27wwwx3g6M+hjvyO4KYozWsYqao827czbm7bceIBF4Ve02x\nax620/34qPbiXWVsI+qOs25dqqcj6SIbv3dcwedTKYs/0UmteG+QJ+RdGRA5\nZhjI\r\n=eBQt\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCbMNzNUx9qUd4dQYksVZLcl8ZZQtdw9oSsHFmAyRTSswIga1cG91cNI/ka30T+ctnswfbyqy6dEsVNy/zRyAI/STc="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.1.2-master.1334b62_1590477336319_0.12775255360029392"},"_hasShrinkwrap":false},"2.2.0":{"name":"simple-update-in","version":"2.2.0","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"npm run build:babel && npm run build:rollup","build:babel":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","build:rollup":"rollup --config","coveralls":"cat ./coverage/lcov.info | coveralls","prestart":"npm run build:babel","start":"concurrently --kill-others --names \"babel,rollup\" \"npm run start:babel\" \"npm run start:rollup\"","start:babel":"npm run build:babel -- --skip-initial-build --watch","start:rollup":"npm run build:rollup -- --watch","test":"jest --collectCoverage true"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","devDependencies":{"@babel/cli":"^7.8.4","@babel/core":"^7.9.6","@babel/plugin-proposal-object-rest-spread":"^7.9.6","@babel/preset-env":"^7.9.6","babel-jest":"^26.0.1","babel-plugin-add-module-exports":"^1.0.2","concurrently":"^5.2.0","coveralls":"^3.1.0","jest":"^26.0.1","regenerator-runtime":"^0.13.5","rollup":"^2.10.9","rollup-plugin-babel":"^4.4.0","rollup-plugin-uglify":"^6.0.4"},"_resolved":"","_integrity":"","_from":"file:simple-update-in-2.2.0.tgz","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String\n  )[],\n  updater?: (value: any) => any\n): T\n```\n\nOr the asynchronous version, which you can provide an asynchronous predicate or updater:\n\n```js\nupdateInAsync<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): Promise<T>\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (via [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)), then, the original object is returned.\n\n> Polyfill for `Object.is` is adopted from [`core-js`](https://npmjs.com/package/core-js) to maintain zero dependency.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n> Note: for security reason, we will skip paths containing `__proto__`, `constructor`, `prototype`. This includes [predicate paths](#using-predicate).\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.2.0","_nodeVersion":"12.16.3","_npmVersion":"6.14.5","dist":{"integrity":"sha512-FrW41lLiOs82jKxwq39UrE1HDAHOvirKWk4Nv8tqnFFFknVbTxcHZzDS4vt02qqdU/5+KNsQHWzhKHznDBmrww==","shasum":"86607662635ea12e59b5341044244902aa7db1c8","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.2.0.tgz","fileCount":8,"unpackedSize":54289,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezMh8CRA9TVsSAnZWagAAhKcP/0tfdy5kVZ64OIiEiUR3\nD3FjCMb+lOTaVXStwJnX/xdyMj7OcIr+oh2MSBF0EStrp2u498qlIgklg2sU\n3HFNSFIK/OBDaQfhrYvrxw5u3qJn1IBKLNpCZwptXQw9TmxAKJ1HTxiGvSdA\nbc/TZWZX4vXofS2SKh6bnpU4QVpZf2Y+CpIkkbU4F6GXWArL7LspPrQFG0sC\nysQ/Sg/JhcWIoUkHnlPRDwNeD0weNhf3KeEQkePaAwkQbU1ckfgbt6hyB7Zb\nQmLyADG4c9fOE90MiC5VldQ6seBTnBpJh9p/cYhSBnzxuua5DNg2gecl/4G8\nsK5Uqb/WsgLMheT0nSIm1N/qBHFndW9S8Wp3gn9H4du5No20eHbqf23E9dUl\nVI7OGKz+OtVhPSMtOl/uIaSH5U7G0FNzMNXeIoAQ3Fp79pUjpqaBARjx/bWq\n8CgeFFGfbmxD0APOeseq60iakB8tuuWnGWQ7X5qOzC3Hla6kksGnMuqIKyhj\n9HcDry797gDwgUjlRHTUET8ChNh9qK7bJQ6tpIBiA0N9D25YuKmBidj0MpJE\nr+7Xmn/5itvcJLRap10Yj9hP8yrODFJHimnksXbNIrvhDNaggZwd5n78slim\n/3dQVYgS8rZBAJopNvUMQlN4Z2PUobYTNt4fa4B12d5d1Mb/tbYhQ5BSi4pI\naMyv\r\n=Xfb6\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGTO5RxIrGQyCVY+4Qb7kiKXvBzLHQCjgsxazWB+2ydHAiEAwRjY7Z0N+Gs3j9bsXzekAKUjJrFdnkFOr4c/Ar1WtQ0="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.2.0_1590478966383_0.13422914407614384"},"_hasShrinkwrap":false},"2.2.1-master.88426b2":{"name":"simple-update-in","version":"2.2.1-master.88426b2","description":"A lightweight `updateIn` for immutable objects.","browser":"dist/simple-update-in.production.min.js","main":"lib/index.js","scripts":{"build":"npm run build:babel && npm run build:rollup","build:babel":"babel --out-dir lib src --ignore **/*.spec.js,**/*.test.js","build:rollup":"rollup --config","coveralls":"cat ./coverage/lcov.info | coveralls","prestart":"npm run build:babel","start":"concurrently --kill-others --names \"babel,rollup\" \"npm run start:babel\" \"npm run start:rollup\"","start:babel":"npm run build:babel -- --skip-initial-build --watch","start:rollup":"npm run build:rollup -- --watch","test":"jest --collectCoverage true"},"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"license":"MIT","bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"homepage":"https://github.com/compulim/simple-update-in#readme","devDependencies":{"@babel/cli":"^7.8.4","@babel/core":"^7.9.6","@babel/plugin-proposal-object-rest-spread":"^7.9.6","@babel/preset-env":"^7.9.6","babel-jest":"^26.0.1","babel-plugin-add-module-exports":"^1.0.2","concurrently":"^5.2.0","coveralls":"^3.1.0","jest":"^26.0.1","regenerator-runtime":"^0.13.5","rollup":"^2.10.9","rollup-plugin-babel":"^4.4.0","rollup-plugin-uglify":"^6.0.4"},"_resolved":"","_integrity":"","_from":"file:simple-update-in-2.2.1-master.88426b2.tgz","readme":"# simple-update-in\n\nA lightweight `updateIn` for immutable objects.\n\n[![npm version](https://badge.fury.io/js/simple-update-in.svg)](https://badge.fury.io/js/simple-update-in) [![Build Status](https://travis-ci.org/compulim/simple-update-in.svg?branch=master)](https://travis-ci.org/compulim/simple-update-in) [![Coverage Status](https://coveralls.io/repos/github/compulim/simple-update-in/badge.svg?branch=feat-coveralls)](https://coveralls.io/github/compulim/simple-update-in?branch=feat-coveralls)\n\nWe love [ImmutableJS](https://facebook.github.io/immutable-js). But sometimes, we want to start something from small. Thus, we created this package with zero dependencies.\n\nUnder the [cover](src/index.js), we use Rest Operator to do most of the heavylifting.\n\n# Install\n\nFor latest stable, run `npm install simple-update-in`.\n\nFor active development (`master` branch), run `npm install simple-update-in@master`.\n\n# How to use\n\nFor example, `obj.one.two = 1.2`, call `updateIn(obj, ['one', 'two'], () => 1.2)`. It will return a new object with changes in deep clone.\n\nWe share similar signature as [ImmutableJS.updateIn](https://facebook.github.io/immutable-js/docs/#/Map/updateIn):\n\n```js\nupdateIn<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String\n  )[],\n  updater?: (value: any) => any\n): T\n```\n\nOr the asynchronous version, which you can provide an asynchronous predicate or updater:\n\n```js\nupdateInAsync<T: Array|Map>(\n  target: T,\n  path: (\n    Number|\n    String|\n    (key: (Number|String), value: any) => Promise<Boolean>|Boolean\n  )[],\n  updater?: (value: any) => Promise<any>|any\n): Promise<T>\n```\n\nTo make `updateIn` efficient, especially, when paired with React. It will return a mixed deep/shallow clone of the `target`. It only deep clone on objects that it modified along the `path`, and shallow clone objects that it did not modify.\n\nLike other immutable framework, `updater` is expected to return a new object if there is a change. If the update do not result in a change (via [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)), then, the original object is returned.\n\n> Polyfill for `Object.is` is adopted from [`core-js`](https://npmjs.com/package/core-js) to maintain zero dependency.\n\n### Browser only\n\nYou can also use in the browser via unpkg.com:\n\n```html\n<script src=\"https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js\"></script>\n<script>\n  window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);\n</script>\n```\n\n## Example\n\nJust like ImmutableJS, we want to make both `Array` and `Map` a first-class citizen. To work on a map, use a `string` as key. For arrays, use a `number` as key.\n\n### Map\n\n```js\nimport updateIn from 'simple-update-in';\n\nconst from = { one: 1, two: { number: 2 }, thirty: 3 };\nconst actual = updateIn(from, ['thirty'], three => three * 10);\n\nexpect(actual).toEqual({ one: 1, two: { number: 2 }, thirty: 30 });\n\nexpect(actual).not.toBe(from);   // Something under this tree has changed\nexpect(actual.two).toBe(to.two); // Nothing under this tree has changed\nexpect(actual.thirty).toBe(30);  // We multiplied it by 10\n```\n\n> This is in fact an \"upsert\" operation.\n\n> Note: for security reason, we will skip paths containing `__proto__`, `constructor`, `prototype`. This includes [predicate paths](#using-predicate).\n\n### Array in map\n\n```js\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = updateIn(from, ['one', 1], value => 'one point two');\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Remove a key\n\nYou can also use `updateIn` to remove a key by passing a falsy value to the `updater` argument, or return `undefined`.\n\n```js\nconst from = { one: 1, two: 2 };\nconst actual = updateIn(from, ['two']);\n\nexpect(actual).toEqual({ one: 1 });\n\nexpect(actual).not.toBe(from);\nexpect(actual).not.toHaveProperty('two');\n```\n\n> When removing a non-existing key, the original object will be returned.\n\nThe sample code above also works with `updater` returning `undefined`, for example, `updateIn(from, ['two'], () => undefined)`.\n\n## Remove an item in array\n\n```js\nconst from = ['zero', 'one', 'two'];\nconst actual = updateIn(from, [1]);\n\nexpect(actual).toEqual(['zero', 'two']);\n```\n\n> Also for `updater` returning `undefined`\n\n## Asynchronous update\n\nYou can also use an asynchronous updater to update the content. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = { one: [1.1, 1.2, 1.3], two: [2] };\nconst actual = await updateInAsync(from, ['one', 1], value => Promise.resolve('one point two'));\n\nexpect(actual).toEqual({ one: [1.1, 'one point two', 1.3], two: [2] });\n```\n\n## Automatic expansion\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n> If the `updater` return `undefined`, the object will be untouched.\n\n## Replace incompatible types\n\nIf incompatible types is found along the walk, they will be replaced. For example, in the following example, an `Array` is replaced by a `Map`.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one'], 1);\n\nexpect(actual).toEqual({ one: 1 });\n```\n\n> In the path, `'one'` is a string, it implies that user want a `Map` instead of `Array`\n\nIt will also replace `number` with `Map`.\n\n```js\nconst from = { one: 1 };\nconst actual = updateIn(from, ['one', 'two'], 1.2);\n\nexpect(actual).toEqual({ one: { two: 1.2 } });\n```\n\n### Corner case\n\nIf the target value is of incompatible type, we will convert it to correct type before setting it. In the following sample, the actual value is an empty map instead of the original array.\n\n```js\nconst from = [0, 1, 2];\nconst actual = updateIn(from, ['one']);\n\nexpect(actual).toEqual({});\n```\n\n## ~~Adding an item to array~~\n\nThis feature has been removed due to inconformity of the API. `-1` could means append, prepend, or it could means last value (item at `length - 1`).\n\nFor append, you can use the following code\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [], array => [...array, 2]);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n### Removed documentation\n\nYou can use special index value `-1` to indicate an append to the array.\n\n```js\nconst from = [0, 1];\nconst actual = updateIn(from, [-1], () => 2);\n\nexpect(actual).toEqual([0, 1, 2]);\n```\n\n> If `updater` returned `undefined`, the value will not be appended.\n\nThere is no support on prepend or insertion, however, you can use Rest Operator for array manipulation.\n\n```js\nconst from = { numbers: ['one', 'two'] };\nconst actual = updateIn(from, ['numbers'], array => ['zero', ...array]);\n\nexpect(actual).toEqual({ numbers: ['zero', 'one', 'two'] });\n```\n\n## Using predicate\n\nFor path accessor, instead of `number` and `string`, you can also use `function`.\n\nPredicate for array has signature of `(value, index) => truthy/falsy`. And for map, `(value, key) => truthy/falsy`.\n\n```js\nconst from = [1, 2, 3, 4, 5];\nconst actual = updateIn(from, [value => value % 2], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n### Branching with predicate\n\nYou can also use predicate to update multiple subsets at the same time.\n\n```js\nconst from = [{ v: 1 }, { v: 2 }, { v: 3 }];\nconst actual = updateIn(from, [() => true, 'v'], v => v * 10);\n\nexpect(actual).toEqual([{ v: 10 }, { v: 20 }, { v: 30 }]);\n```\n\n### Non-existing key/index with predicate\n\nSince it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change.\n\n```js\nconst from = {};\nconst actual = updateIn(from, ['Hello', () => true], () => 'World!']);\n\nexpect(actual).toBe(from);\n```\n\n```js\nconst from = [];\nconst actual = updateIn(from, [0, () => true], () => 'Aloha']);\n\nexpect(actual).toBe(from);\n```\n\n### Asynchronous predicate\n\nYou can also use asynchronous predicate. Instead of using the exported `default` function, you will need to use the `updateInAsync` function instead.\n\n```js\nimport { updateInAsync } from 'simple-update-in';\n\nconst from = [1, 2, 3, 4, 5];\nconst actual = await updateInAsync(from, [value => Promise.resolve(value % 2)], value => value * 10);\n\nexpect(actual).toEqual([10, 2, 30, 4, 50]);\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/simple-update-in/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/simple-update-in/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/simple-update-in/pulls) a pull request.\n","readmeFilename":"README.md","_id":"simple-update-in@2.2.1-master.88426b2","_nodeVersion":"12.16.3","_npmVersion":"6.14.5","dist":{"integrity":"sha512-Ky+Ip4s7OS571PpdXb5TdxHJ1Mf34T/WB2VTvq6Llv6IFO9hcPOeoVPZls/lfAoAW93nETPIErWCVoI4EbULJQ==","shasum":"d90aaffffa0a28f74aa2d2d08662420c83da56ae","tarball":"https://registry.npmjs.org/simple-update-in/-/simple-update-in-2.2.1-master.88426b2.tgz","fileCount":8,"unpackedSize":54304,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezMqECRA9TVsSAnZWagAAPrIQAKAJFpnS6nCD67KdlJKG\n0v9T5TcpO020nOC2I0/AXvNuhZr1/p/XTkac7HNwJu48W/j4OvL1c00Omc97\nqYX8mhOolV5NT1xXnPzXbEnZnYUE5nZAVLscaynnCgUspdGzPGqXKyNJWKE+\ndx5W1WNFmCxiRBi6CNbVK05x4bNt/R4+YfiBZvCUEPLKI+Q4dPG0iwACcDiO\nOkMJt4xOwz2/UX8ax2rgYQTL9FhuWSkibW8J3yMeiejRr/HhMAKW23UcFwhO\nb30jBIE8FQH9KcoZsXRtov4+wiZtrbbH0RVV/IiaCKgDsD/gUOzAUDBK72g2\nYrzXD4hUJylNYmICCzeMVHCfCTLPL1Sn1amTckq+9QKQkEVItgH41Fu/F5My\nHAeqMT8G4nQyIrRK8WuPRQZ4XO5fzJTjTbaaRl6qSMP7+dXttCNwNB5MAPVL\nvmfcBRNu3IPb+jxYgDC4QeFTAwIkpBLRlX4a7EnO7SnNRQQhokKSJoG1MdkD\ncvm7JdumZFMeo1xxI8xwstvNOb5Tp2im/vRQRXsfTOl1a6y8vjp6SVOs+L1+\nmfQVoOfwRRNf7N/rbxSbsVw1bhbB7mVfzMEuzhV4UeAXFk4ICVS1rLaf3tu7\nnaw8VtD/sqt33d1nmjai9TXLFp8H70aos7QyKDPUpnBqRi+IqxWPIiwxmu8o\nQTLb\r\n=Z08S\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDz6mhS58T2vH4nUsqcDGI74kdEBlBW5pNwVwnswZw38wIgKrv6/5OfC/VlBri3jN6wa0Q6FGuvYb5AhT4WdLgTlz0="}]},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"_npmUser":{"name":"compulim","email":"compulim@hotmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-update-in_2.2.1-master.88426b2_1590479491889_0.7378035701049799"},"_hasShrinkwrap":false}},"time":{"created":"2018-03-20T03:05:15.452Z","1.0.0-master.a992290":"2018-03-20T03:05:15.497Z","modified":"2022-05-17T22:10:15.821Z","1.0.0-master.5a2f0ab":"2018-03-20T03:50:40.495Z","1.0.0-master.09af2f4":"2018-03-20T04:04:09.287Z","1.0.0-master.d5e304a":"2018-03-20T17:45:48.963Z","1.0.0-master.5a7d9c3":"2018-03-20T18:56:11.929Z","1.0.0":"2018-03-21T18:10:34.232Z","1.0.0-master.83a0776":"2018-03-21T18:18:16.026Z","1.1.0-master.2981381":"2018-03-26T09:00:09.639Z","1.1.0-master.2195a9f":"2018-03-26T12:05:48.736Z","1.1.0-master.c718f47":"2018-03-27T02:06:18.835Z","1.1.0-master.e4398e5":"2018-03-27T02:07:20.546Z","1.1.0-master.247be79":"2018-03-27T02:18:43.060Z","1.1.0":"2018-03-31T23:39:00.744Z","1.1.0-master.cf3945c":"2018-03-31T23:39:12.388Z","1.1.1-master.0b89b91":"2018-03-31T23:39:26.240Z","1.1.1":"2018-04-07T05:52:02.957Z","1.1.2-master.cf20461":"2018-04-07T05:52:40.487Z","1.1.2-master.6d997fd":"2018-04-11T22:59:18.149Z","1.1.2-master.9dfd73c":"2018-04-12T21:23:05.643Z","1.1.2-master.a6cb16a":"2018-04-14T20:21:47.011Z","1.2.0":"2018-04-14T20:22:11.256Z","1.2.1-master.f2ba331":"2018-04-14T20:22:19.990Z","1.2.0-master.c36e845":"2018-04-14T20:22:29.241Z","1.2.1-master.897c6d0":"2018-05-02T20:22:13.784Z","1.2.1-master.dad2747":"2018-05-02T20:22:31.904Z","1.2.1-master.b9b6308":"2018-05-13T20:57:19.423Z","1.2.1-master.b143fb6":"2018-05-19T23:59:57.640Z","1.2.1-master.730f2f4":"2018-07-19T22:48:43.861Z","1.3.0":"2018-08-17T09:16:41.983Z","1.3.1-master.023101b":"2018-08-17T09:39:31.365Z","1.3.1-master.f84f35c":"2018-10-05T08:29:19.661Z","1.3.1":"2018-10-05T08:32:26.216Z","1.3.2-master.62c7b4d":"2018-10-05T08:36:13.189Z","1.4.0-0":"2018-10-09T01:25:27.962Z","1.4.0-master.615065c":"2018-10-09T01:26:50.675Z","1.4.0":"2018-10-09T01:30:32.907Z","1.4.1-0":"2018-10-09T01:34:00.971Z","1.4.1-master.6eda060":"2018-10-09T01:35:23.843Z","1.4.1-master.e48b627":"2018-12-03T11:32:42.517Z","1.4.1-master.ea7196c":"2018-12-03T12:03:08.092Z","1.4.1-master.f9cbbf0":"2018-12-03T12:42:25.923Z","2.0.0":"2018-12-03T12:48:42.841Z","2.0.1-master.49d2769":"2018-12-03T12:51:48.227Z","2.0.1-master.e01c112":"2018-12-03T21:13:02.086Z","2.0.1-master.caa6667":"2018-12-03T22:14:51.036Z","2.0.1":"2018-12-03T22:28:40.178Z","2.0.2-0":"2018-12-03T22:32:10.719Z","2.0.2-master.73f7cfa":"2018-12-03T22:38:47.377Z","2.0.2-master.6056ef4":"2018-12-03T22:41:50.685Z","2.0.2-master.004542e":"2018-12-06T11:18:22.598Z","2.0.2-master.0861f0c":"2018-12-06T22:00:25.092Z","2.0.2":"2018-12-06T22:03:54.376Z","2.0.3-master.b9e75e5":"2018-12-06T22:10:06.471Z","2.0.3-master.804f4eb":"2019-07-18T06:20:48.912Z","2.0.3-master.fc7fc52":"2019-07-18T08:07:19.857Z","2.0.3-master.48dc5a9":"2019-07-18T08:20:26.279Z","2.1.0":"2019-07-18T08:25:03.246Z","2.1.1-master.f1f8c14":"2019-07-18T08:42:46.252Z","2.1.1-master.8661c10":"2019-07-18T08:55:01.968Z","2.1.1-master.99f56bd":"2019-08-02T02:45:29.933Z","2.1.1":"2019-08-02T03:49:40.647Z","2.1.2-master.954b348":"2019-08-02T04:05:20.325Z","2.1.2-master.e25f669":"2020-05-26T05:17:02.924Z","2.1.2-master.1334b62":"2020-05-26T07:15:36.422Z","2.2.0":"2020-05-26T07:42:52.461Z","2.2.1-master.88426b2":"2020-05-26T07:51:32.083Z"},"maintainers":[{"name":"compulim","email":"compulim@hotmail.com"}],"description":"A lightweight `updateIn` for immutable objects.","homepage":"https://github.com/compulim/simple-update-in#readme","keywords":["asynchronous","immutable","predicate","update","updater","update-in"],"repository":{"type":"git","url":"git+https://github.com/compulim/simple-update-in.git"},"author":{"name":"William Wong","email":"compulim@hotmail.com","url":"http://compulim.info/"},"bugs":{"url":"https://github.com/compulim/simple-update-in/issues"},"license":"MIT","readme":"","readmeFilename":""}