{"id":19605121,"url":"https://github.com/a7ul/replace-object-content","last_synced_at":"2026-07-03T06:06:01.556Z","repository":{"id":57353781,"uuid":"89511873","full_name":"a7ul/replace-object-content","owner":"a7ul","description":"mutates the source js object and replaces the contents with properties from the passed js object while retaining the source js object reference.","archived":false,"fork":false,"pushed_at":"2017-04-26T18:33:32.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-18T17:53:41.468Z","etag":null,"topics":["javascript","js","mutate","openlibrary"],"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/a7ul.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-04-26T18:05:32.000Z","updated_at":"2021-11-05T23:35:05.000Z","dependencies_parsed_at":"2022-08-31T22:00:59.839Z","dependency_job_id":null,"html_url":"https://github.com/a7ul/replace-object-content","commit_stats":null,"previous_names":["master-atul/replace-object-content"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a7ul%2Freplace-object-content","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a7ul%2Freplace-object-content/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a7ul%2Freplace-object-content/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a7ul%2Freplace-object-content/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a7ul","download_url":"https://codeload.github.com/a7ul/replace-object-content/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240888506,"owners_count":19873667,"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":["javascript","js","mutate","openlibrary"],"created_at":"2024-11-11T09:41:15.399Z","updated_at":"2025-10-30T06:14:52.431Z","avatar_url":"https://github.com/a7ul.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# replace-object-content\n\nThe module mutates the contents of an object to match the contents of another object.\n\nThe references of the source and the object from which properties are copied remains untouched.\n\nSee `Usage` to understand more.\n\n## Installation\n\n`yarn add replace-object-content`\n\nor\n\n`npm install replace-object-content --save`\n\n## Usage\n\n```js\n\nconst original = {a:1,b:2,c:3};\n\nconst toCopyFromObject = {d:4,e:5,f:6};\n\nconst replaceObjectContent = require('replace-object-content');\n\nconst afterReplace = replaceObjectContent(original, toCopyFromObject);\n\nconsole.log('original',original);\n// original {d:4,e:5,f:6}   ----- notice the contents of the original object has been mutated to match the contents of the toCopyFromObject  object\n\nconsole.log('toCopyFromObject',toCopyFromObject);\n// toCopyFromObject {d:4,e:5,f:6}\n\nconsole.log('afterReplace',afterReplace);\n// afterReplace {d:4,e:5,f:6}\n\n```\n\nIn short, the references of the `original` and `toCopyFromObject` remain as they were before.\nOnly the contents of `original` becomes exactly same as contents of `toCopyFromObject`\n\n```js\n// All of the bellow test cases pass\n\nexpect(original).toEqual(toCopyFrom); // content deep equal\nexpect(afterReplace).toEqual(toCopyFrom); // content deep equal\nexpect(afterReplace === original).toEqual(true); //making sure reference is equal\nexpect(original === toCopyFrom).toEqual(false); //making sure original and toCopyFrom references are not equal\nexpect(afterReplace === toCopyFrom).toEqual(false); //making sure afterReplace and toCopyFrom references are not equal\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa7ul%2Freplace-object-content","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa7ul%2Freplace-object-content","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa7ul%2Freplace-object-content/lists"}