{"id":21236384,"url":"https://github.com/fireblinkltd/object-collider","last_synced_at":"2025-07-13T19:07:45.209Z","repository":{"id":44977710,"uuid":"165713554","full_name":"FireBlinkLTD/object-collider","owner":"FireBlinkLTD","description":"Merge plain old objects without source modifications and optionally provide custom merge behavior per specific child path.","archived":false,"fork":false,"pushed_at":"2024-06-16T09:57:33.000Z","size":702,"stargazers_count":3,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-30T20:03:20.604Z","etag":null,"topics":["collider","deepmerge","fireblink","merge","object"],"latest_commit_sha":null,"homepage":"http://npmjs.com/package/object-collider","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/FireBlinkLTD.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-14T18:32:47.000Z","updated_at":"2023-12-07T07:54:28.000Z","dependencies_parsed_at":"2024-06-21T14:07:01.381Z","dependency_job_id":"0ad3d9c7-4194-49cd-b14c-33235d585c9c","html_url":"https://github.com/FireBlinkLTD/object-collider","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"4c9e0c3394b4d54855f3dae9825cdd93ea238d1b"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/FireBlinkLTD/object-collider","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FireBlinkLTD%2Fobject-collider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FireBlinkLTD%2Fobject-collider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FireBlinkLTD%2Fobject-collider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FireBlinkLTD%2Fobject-collider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FireBlinkLTD","download_url":"https://codeload.github.com/FireBlinkLTD/object-collider/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FireBlinkLTD%2Fobject-collider/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264631211,"owners_count":23640940,"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":["collider","deepmerge","fireblink","merge","object"],"created_at":"2024-11-21T00:10:04.070Z","updated_at":"2025-07-13T19:07:45.169Z","avatar_url":"https://github.com/FireBlinkLTD.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Object Collider\n\n[![Known Vulnerabilities](https://snyk.io/test/github/FireBlinkLTD/object-collider/badge.svg)](https://snyk.io/test/github/FireBlinkLTD/object-collider)\n[![codecov](https://codecov.io/gh/FireBlinkLTD/object-collider/branch/master/graph/badge.svg)](https://codecov.io/gh/FireBlinkLTD/object-collider)\n\n\nMerge plain old objects without source modifications and optionally provide custom merge behavior per specific child path.\n\n## Why yet another object merge library?\n\nThe main reason is to have flexible way of overriding default merge behavior for any object property branches individually, originally as a part of [fbl](https://fbl.fireblink.com) rutine automation tool.\n\nBest way to understand what that means is to review the example below.\n\nLet's assume we need to merge following objects.\n\n```typescript\nconst obj1 = {\n    parent: {\n        child: {\n            field: [1, 2, 3]\n        }\n    }\n};\n```\n\n```typescript\nconst obj2 = {\n    parent: {\n        child: {\n            field: [4, 5, 6]\n        }\n    }\n};\n```\nThe default behaviour of this library is to concatenate array items at the same path, so following script ...\n\n```typescript\nimport { collide } from 'object-collider';\n\nconst result = collide(obj1, obj2);\n```\n\n... will produce `result` with the following structure:\n\n```yaml\n{\n    parent:\n        child: {\n            field: [1, 2, 3, 4, 5, 6]\n        }\n}\n```\n\nHowever this might not be what app needs. Modifiers are here for the rescue:\n\n```typescript\nimport { collide } from 'object-collider';\n\nconst result = collide(obj1, obj2, {\n    '$.parent.child.field': (arr1, arr2) =\u003e {\n        // just return second array to override all values\n        return arr2;\n    }\n});\n```\n\n## Merge Behaviour\n\n`collide` function creates cloned values of passed arguments to avoid any unexpected modifications.\n\n### Objects\n\nLibrary will recurcivelly travel over the object fields tree till and will merge each leaf individually.\n\nApp will stop recursion on basic types (limited set of primitive JS types), `null`, `undefined` or array.\n\n### Basic Types\n\nIf value has type of `string`, `number` or `boolean` it will be merged directly into first merge argument object.\n\n### Arrays\n\nBy default arrays will be concatenated. Note, if array contains objects, these object will not be merged. If you need to merge objects provide custom modifier function for array path and call `collide` per each set of object you need to merge.\n\n### Other Types\n\nLibrary is not designed to merge non-plain objects, so any other types will probably cause merge to fail.\n\n## Paths\n\nLibrary is using dot separated sytax to identify merge path, starting with `$` that identifies root of the path.\n\nNote: you're allowed to replace the prefix (`$`) with any other by providing it as a 4th argument of `collide` function.\n\n## Unsafe Merge\n\nIn some cases you may need to modify the existing object, so you can do that with `collideUnsafe` function:\n\n```typescript\nimport { collideUnsafe } from 'object-collider';\n\n// obj1 will get modified directly\ncollideUnsafe(obj1, obj2);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffireblinkltd%2Fobject-collider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffireblinkltd%2Fobject-collider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffireblinkltd%2Fobject-collider/lists"}