{"id":22281341,"url":"https://github.com/hlfshell/controlled-merge","last_synced_at":"2025-07-31T09:37:11.024Z","repository":{"id":34878634,"uuid":"38891274","full_name":"hlfshell/controlled-merge","owner":"hlfshell","description":null,"archived":false,"fork":false,"pushed_at":"2022-11-10T04:31:05.000Z","size":53,"stargazers_count":1,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T19:22:15.650Z","etag":null,"topics":[],"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/hlfshell.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":"2015-07-10T16:44:15.000Z","updated_at":"2025-01-01T20:29:27.000Z","dependencies_parsed_at":"2023-01-15T09:50:40.893Z","dependency_job_id":null,"html_url":"https://github.com/hlfshell/controlled-merge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hlfshell/controlled-merge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hlfshell%2Fcontrolled-merge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hlfshell%2Fcontrolled-merge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hlfshell%2Fcontrolled-merge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hlfshell%2Fcontrolled-merge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hlfshell","download_url":"https://codeload.github.com/hlfshell/controlled-merge/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hlfshell%2Fcontrolled-merge/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268017357,"owners_count":24181669,"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","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-12-03T16:17:20.822Z","updated_at":"2025-07-31T09:37:10.987Z","avatar_url":"https://github.com/hlfshell.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# controlled-merge\n\ncontrolled-merge is a utility function to merge a number of javascript objects into a singular object. It has an optional onConflict functionality that allows you to specify how to handle conflicts of the merge.\n\n__merge([onConflict], [objects]);__\n\n* onConflict(objectOne, objectTwo, attr)\n  * Optional function to define what happens when non objects are detected and conflict. By default, it will assign the later merge object over the earlier one. The name of the conflicting attribute will be present as the third parameter.\n* objects\n  * Either a singular array of all objects passed in, or manually passed in arguments.\n\n##Install\n\n```\nnpm install controlled-merge\n```\n\n## Example\n\n```\nvar merge = require('controlled-merge');\n\n//Input\nvar x =\n  {\n    'test': 'This is a test string'\n  };\nvar y =\n  {\n    'also': 'is a test',\n    'value': 1\n  };\nvar z =\n  {\n    'value': 3\n  };\nvar conflictingKeys = [];\n  \nvar results = merge(\n  function(obj1, obj2, attr){\n    conflictingKeys.push(attr);\n    return obj1 \u003e obj2 ? obj1 : obj2;\n  },\n  x, y, z\n);\n\n//results =\n{\n  'test': 'This is a test string',\n  'also': 'is a test',\n  'value': 3\n}\n\n//conflictingKeys = \n[\n  'value'\n]\n\n```\n\n## Why?\nI needed to combine JSONs that represented role-based permissions for [CanThey](https://github.com/hlfshell/CanThey) - the idea being that a user can have several roles and I needed to calculate resulting permissions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhlfshell%2Fcontrolled-merge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhlfshell%2Fcontrolled-merge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhlfshell%2Fcontrolled-merge/lists"}