{"id":28411627,"url":"https://github.com/cah4a/immutable-modify","last_synced_at":"2026-04-29T09:33:30.672Z","repository":{"id":57155676,"uuid":"120891337","full_name":"cah4a/immutable-modify","owner":"cah4a","description":"Slim zero dependencies helper functions for modifying redux state or frozen objects","archived":false,"fork":false,"pushed_at":"2018-03-14T11:12:10.000Z","size":35,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-03T05:38:37.711Z","etag":null,"topics":["frozen","immutable","redux"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cah4a.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-09T10:20:49.000Z","updated_at":"2018-03-14T11:28:20.000Z","dependencies_parsed_at":"2022-08-26T09:51:46.423Z","dependency_job_id":null,"html_url":"https://github.com/cah4a/immutable-modify","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cah4a/immutable-modify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cah4a%2Fimmutable-modify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cah4a%2Fimmutable-modify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cah4a%2Fimmutable-modify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cah4a%2Fimmutable-modify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cah4a","download_url":"https://codeload.github.com/cah4a/immutable-modify/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cah4a%2Fimmutable-modify/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261575345,"owners_count":23179500,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["frozen","immutable","redux"],"created_at":"2025-06-02T18:17:14.663Z","updated_at":"2026-04-29T09:33:30.644Z","avatar_url":"https://github.com/cah4a.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# immutable-modify\n\nSlim zero dependencies helper function for modifying redux state or frozen objects\n\nEasily create updated version of your Plain Javascript Object.\nFunction will create new references to objects or arrays when nested data is changed and leave references otherwise.\nThat allows `react` and `react-redux` to fast check your props using reference equality.\n\n## Analogs\n \n- [immutability-helper](https://github.com/kolodny/immutability-helper)\n- [immutable-set](https://github.com/M6Web/immutable-set)\n- [immutable-setter](https://github.com/bormind/immutable-setter)\n- [imset](https://github.com/brigand/imset)\n- [immutability-util](https://github.com/hustcc/immutability-util)\n\n## Install\n\n```\nyarn add immutable-modify\n```\n\nor \n\n```\nnpm install --save immutable-modify\n```\n\n## Api\n\n### set(object, keyPath, value)\n\nArguments:\n\n- **object (Object)**: The object modify\n- **keyPath (string | Array)**: The path of the property to set\n- **value (any | (leaf) =\u003e any)**: The value to set or update function\n\nReturns:\n\n(Object): Returns object\n\n```javascript\nimport {set} from 'immutable-modify'\n\nconst state = {user: {name: 'Skywalker'}}\n\n// same as set(state, ['user', 'name'], 'Dart Vader')\nconst newState = set(state, 'user.name', 'Dart Vader') \n\n// newState is now {user: {name: 'Dart Vader'}}\n\nnewState === state // false\nnewState.user === state.user // false\n```\n\nAlso `value` could be function:\n\n```javascript\nimport {set} from 'immutable-modify'\n\nconst state = {user: {name: 'Skywalker', isJedi: false}, settings: {}}\n\nconst newState = set(state, 'user.isJedi', (isJedi) =\u003e !isJedi)\n// newState is now {user: {name: 'Skywalker', isJedi: true}}\n\nnewState === state // false\nnewState.user === state.user // false\nnewState.settings === state.settings // true\n```\n\n#### Attention!\n\nThat updater function should return *new reference*, otherwise nothing will updated:\n\n```javascript\nimport {set} from 'immutable-modify'\n\nconst state = {user: {name: 'Skywalker', isJedi: false}, settings: {}}\n\nconst newState = set(state, 'user', user =\u003e {\n    user.isJedi = true \n    return user\n})\n// newState is still {user: {name: 'Skywalker', isJedi: false}}\n\nnewState === state // true\nnewState.user === state.user // true\nnewState.settings === state.settings // true\n```\n\n### push(object, path, item)\n\n```javascript\nimport {push} from 'immutable-modify'\n\nconst state = {sequence: [{a: 1}, {a: 2}]}\n\nconst newState = push(state, 'sequence', {a: 3})\n// newState is now {sequence: [{a: 1}, {a: 2}, {a: 3}]}\n\nnewState === state // false\nnewState.sequence === state.sequence // false\nnewState.sequence[0] === state.sequence[0] // true\nnewState.sequence[1] === state.sequence[1] // true\n```\n\n\n### merge(object, path, item)\n\n```javascript\nimport {merge} from 'immutable-modify'\n\nconst state = {product: {name: 'sepulka'}}\n\nconst newState = merge(state, 'product', {description: 'Best with sepulator'})\n// newState is now {product: {name: 'sepulka', description: 'Best with sepulator'}}\n\nnewState === state // false\nnewState.product === state.product // false\nnewState.product.name === state.product.name // true\n```\n\n### remove(object, path)\n\n```javascript\nimport {remove} from 'immutable-modify'\n\nconst state = {product: {name: 'sepulka', isAvailable: true}}\n\nconst newState = remove(state, 'product.isAvailable')\n// newState is now {product: {name: 'sepulka'}}\n\nnewState === state // false\nnewState.product === state.product // false\n```\n\n## Test\n\n```\nyarn test\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcah4a%2Fimmutable-modify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcah4a%2Fimmutable-modify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcah4a%2Fimmutable-modify/lists"}