{"id":16159809,"url":"https://github.com/robertherber/find-and-replace-immutable","last_synced_at":"2025-03-18T21:31:59.061Z","repository":{"id":57236172,"uuid":"94852260","full_name":"robertherber/find-and-replace-immutable","owner":"robertherber","description":"Exposes immutable findAndReplace and replaceAt functions on top of lodash/fp","archived":false,"fork":false,"pushed_at":"2017-06-20T05:44:03.000Z","size":48,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-09T13:35:56.020Z","etag":null,"topics":["immutable","javascript","node","utility"],"latest_commit_sha":null,"homepage":null,"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/robertherber.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":"2017-06-20T05:15:26.000Z","updated_at":"2017-09-08T16:29:43.000Z","dependencies_parsed_at":"2022-08-23T16:20:18.476Z","dependency_job_id":null,"html_url":"https://github.com/robertherber/find-and-replace-immutable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertherber%2Ffind-and-replace-immutable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertherber%2Ffind-and-replace-immutable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertherber%2Ffind-and-replace-immutable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertherber%2Ffind-and-replace-immutable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertherber","download_url":"https://codeload.github.com/robertherber/find-and-replace-immutable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243950813,"owners_count":20373664,"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":["immutable","javascript","node","utility"],"created_at":"2024-10-10T01:59:51.554Z","updated_at":"2025-03-18T21:31:57.074Z","avatar_url":"https://github.com/robertherber.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# find-and-replace-immutable\n\nExposes two simple but essential helper immutable methods:\n* replaceAt (index, objectOrMapFunction, array)\n* findAndReplace (findPredicateFunction, objectOrMapFunction, array)\n\nUses [lodash/fp](https://github.com/lodash/lodash/wiki/FP-Guide) under the hood, which is great for it's immutability.\n\nI always end up using this in my React projects - so I thought I'd share it! ;)\n\n## Examples\n\nUsing *replaceAt*:\n~~~~\nimport { replaceAt } from 'find-and-replace-immutable';\n\nconst initialArray = [\"original\"];\n\nconst newArray = replaceAt(0, \"new value\", initialArray);\n\n// expect(newArray).toEqual([\"new value\"]);\n// expect(initialArray).toEqual([\"original\"]);\n~~~~\n\n\nUsing *findAndReplace* with mapping function:\n~~~~\nimport { findAndReplace } from 'find-and-replace-immutable';\n\nconst initialArray = [1, 2, 3, 3, 4, 5];\n\nconst newArray = findAndReplace(\n  e =\u003e e === 3,\n  oldValue =\u003e 33 * oldValue,\n  initialArray\n);\n\n// expect(newArray).toEqual([1, 2, 99, 3, 4, 5]);\n~~~~\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertherber%2Ffind-and-replace-immutable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertherber%2Ffind-and-replace-immutable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertherber%2Ffind-and-replace-immutable/lists"}