{"id":21508082,"url":"https://github.com/wtnm/react-merge","last_synced_at":"2026-03-07T23:01:20.772Z","repository":{"id":57151951,"uuid":"356913165","full_name":"wtnm/react-merge","owner":"wtnm","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-14T20:09:43.000Z","size":107,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-30T10:56:29.840Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wtnm.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-04-11T16:01:36.000Z","updated_at":"2024-02-06T11:47:38.000Z","dependencies_parsed_at":"2024-02-12T12:55:26.237Z","dependency_job_id":null,"html_url":"https://github.com/wtnm/react-merge","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"d3abb9d87c9b9769eb6a9e439f06d0a3d3715aa1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wtnm/react-merge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wtnm%2Freact-merge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wtnm%2Freact-merge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wtnm%2Freact-merge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wtnm%2Freact-merge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wtnm","download_url":"https://codeload.github.com/wtnm/react-merge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wtnm%2Freact-merge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30236042,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T19:01:10.287Z","status":"ssl_error","status_checked_at":"2026-03-07T18:59:58.103Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-23T20:45:42.342Z","updated_at":"2026-03-07T23:01:20.537Z","avatar_url":"https://github.com/wtnm.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n\u003c!-- toc --\u003e\n\n\n\n\u003c!-- tocstop --\u003e\n\n## Overview\n`react-merge` - function that merge 2 (or more) objects in a proper \"react\"-way. I.e. if second object doesn't change first then the result object is strictly equals first object.\n```\nimport { merge } from 'react-merge';\n\nlet firstObject = { \"a\": 1, \"b\": { \"c\": 2, \"d\": 3 } }\nlet result = merge(firstObject, { \"a\": 1 });\nconsole.log(result === firstObject); // true\n\nresult = merge(firstObject, { \"a\": 2, \"b\": { \"c\": 2 } });\nconsole.log(result === firstObject); // false\nconsole.log(result.b === firstObject.b); // true\n```\n\n\n## Installation\n\nTo install the stable version:\n\n```\nnpm install --save react-merge\n```\n## Usage\n```jsx\nimport { merge } from 'react-merge'\n```\n\n## Documentation\n\n#### merge(objectA: any, objectB: any, options: MergeOptions)\nMerges `objectA` with `objectB` in react-way. \n\nIf `objectB` is not mergeable then `objectA` is returned as result. \n\nIf `objectA` is not mergeable then new object deeply equal to `objectB` is returned as result. \n\nIf both are not mergeable then empty object is returned. \n\nIf `objectA` is array and `objectB` is not array then the result is array with props of `objectB`.\n\n`options` - object with following properties:\n  - `path?: string | any[]` - // path in first object that should be merged with second object\n  - `replace?: replaceType` - force replace for mergeable object instead of merge, can be boolean, object with boolean or function props or a function of the following type `(path: any[], objectA: anyObject, objectB: anyObject) =\u003e boolean`\n  - `arrays?: Function` - function to merge arrays of the following type `(path: any[], arrayA: any[], arrayB: any[]) =\u003e any[]`. Example, to concat arrays `(t, a, b) =\u003e a.concat(b)`, to replace `(t, a, b) =\u003e b`\n  - `del?: boolean` - remove props with `MergeOptions.delSymbol`\n  - `delSymbol?: any` - symbol that marks props that should be removed if MergeOptions.del is true, default is `undefined`\n  - `noSymbol?: boolean` - if true, then skips symbol props in objects\n  - `diff?: boolean` - if true then first object is changed in the way to be deeply equal to the second.\n\n#### merge.all(objectA: any, objectsB: any[], options: MergeOptions)\nMerges `objectA` with `objectsB` array.\n\n## Examples: \n\n##### merge array with object\n```jsx\nimport { merge } from 'react-merge';\n\nlet firstObject = { \"a\": [0, 1, 2, 3] }\nlet secondObject = { \"a\": { \"1\": 11, \"length\": 2 } };\nlet result = merge(firstObject, secondObject);\nconsole.log(result); // {\"a\": [0, 11]}\n\n```\n\n##### default array merging\n```jsx\nimport { merge } from 'react-merge';\n\nlet firstObject = { \"a\": [0, 1, 2, 3] }\nlet secondObject = { \"a\": [] };\nsecondObject.a[2] = 22;\nsecondObject.a.length = 5;\nlet result = merge(firstObject, secondObject);\nconsole.log(result); // {\"a\": [0, 1, 22, 3, undefined]}\n```\n\n##### del options\n```jsx\nimport { merge } from 'react-merge';\n\nlet firstObject = { \"a\": 1, \"b\": { \"c\": 2, \"d\": 3 } }\nlet secondObject = { \"a\": undefined };\nlet result = merge(firstObject, secondObject, { del: true });\nconsole.log(result); // {\"b\": {\"c\":2, \"d\":3}}\n\nresult = merge(firstObject, secondObject, { del: false });\nconsole.log(result); // {\"a\": undefined, \"b\": {\"c\":2, \"d\":3}}\n```\n\n##### diff options\n```jsx\nimport { merge } from 'react-merge';\n\nconst firstObject = { \"a\": 1, \"b\": { \"c\": 2, \"d\": 3 } }\nconst secondObject = { \"a\": 1 };\nconst result = merge(firstObject, secondObject, { diff: true });\n\nconsole.log(result === firstObject); // false\nconsole.log(result === secondObject); // false\nconsole.log(result); // {\"a\": 1}\n```\n\n\n  \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwtnm%2Freact-merge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwtnm%2Freact-merge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwtnm%2Freact-merge/lists"}