{"id":15285466,"url":"https://github.com/dan503/replacevalues","last_synced_at":"2026-06-17T23:31:30.055Z","repository":{"id":57353724,"uuid":"74241869","full_name":"Dan503/replaceValues","owner":"Dan503","description":"A function for surgically replacing values in an object","archived":false,"fork":false,"pushed_at":"2016-12-21T11:37:27.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-06T18:46:29.384Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dan503.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}},"created_at":"2016-11-19T23:31:02.000Z","updated_at":"2016-11-20T01:02:59.000Z","dependencies_parsed_at":"2022-09-19T01:01:43.877Z","dependency_job_id":null,"html_url":"https://github.com/Dan503/replaceValues","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Dan503/replaceValues","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dan503%2FreplaceValues","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dan503%2FreplaceValues/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dan503%2FreplaceValues/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dan503%2FreplaceValues/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dan503","download_url":"https://codeload.github.com/Dan503/replaceValues/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dan503%2FreplaceValues/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269844415,"owners_count":24484193,"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-08-11T02:00:10.019Z","response_time":75,"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-09-30T15:05:19.370Z","updated_at":"2026-06-17T23:31:30.020Z","avatar_url":"https://github.com/Dan503.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# replaceValues\n\nA function for surgically replacing values in an object\n\n`````\nnpm install replace-values --save\n`````\n\nThis function is essentially the opposite of my [defaultTo](https://www.npmjs.com/package/default-to) function.\n\n## JS Usage\n\nThis is how you would use it in a javascript file\n\n### Single level\n\n`````js\nvar replaceValues = require('replace-values');\n\nvar example = {\n    one: 1,\n    two : 2,\n    three: 3\n};\n\nreplaceValues(example, {\n    two: 'two',\n});\n`````\n\nIn this case `example` would now equal this:\n\n`````js\n{\n    one: 1,\n    two: 'two',\n    three: 3\n}\n`````\n\n#### alternate syntax\n\nThis syntax still works since the function returns with the new object:\n\n````````````js\nvar example = {\n    one: 1,\n    two : 2,\n    three: 3\n};\n\nexample = replaceValues(example, {\n    two: 'two',\n});\n\n// example = { one: 1, two: 'two', three: 3 }\n````````````\n\n### Nested\n\nThe function can also replace nested values\n\n`````js\nvar replaceValues = require('replace-values');\n\nvar example = {\n    one: 1,\n    two : {\n        a: 'aaa',\n        b: 'bbb'\n    },\n    three: 3\n};\n\nreplaceValues(example, {\n    two: { a : 'zzz'},\n});\n`````\n\nIn this case `example` would now equal this:\n\n`````js\n{\n    one: 1,\n    two: {\n        a: 'zzz',\n        b: 'bbb'\n    },\n    three: 3\n}\n`````\n\n### Replace parsed values using functions\n\n`````js\nvar replaceValues = require('replace-values');\n\nvar example = {\n    one: 1,\n    two : 2,\n    three: 3\n};\n\nfunction replacementFunction(object){\n    replaceValues(object, {\n        two: 'two',\n    });\n}\n\nreplacementFunction(example);\n\n//example = { one: 1, two : 'two', three: 3 };\n`````\n\n## Pug and Jade usage\n\nThis npm package also comes with [Pug and Jade](https://pugjs.org/api/getting-started.html) versions of the function. To use the function in your pug/jade templates add this to the top of your base pug/jade file:\n\n`````jade\ninclude ../../node_modules/replace-values/replaceValues\n`````\n\nMake sure the path is correct, it will be different depending on your folder structure. It is a relative path from the file it is being included in. Also, note that there is no file extension in the example.\n\nAfter including that line, you can use it in the same ways that I have used it above except you need to make sure you nest the js inside a js block (note the `-` at the top of the code block).\n\n``````jade\n-\n    var example = {\n        one: 1,\n        two : 2,\n        three: 3\n    };\n\n    var example = replaceValues(example, {\n        two: 'two',\n    })\n``````\n\n\n## Developers\n\nIf using any ES6 syntax, use the [babel-it](https://github.com/IonicaBizau/babel-it) npm plugin just before publishing to convert the js files into eES5 syntax for better environment support.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan503%2Freplacevalues","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdan503%2Freplacevalues","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan503%2Freplacevalues/lists"}