{"id":17448322,"url":"https://github.com/mesqueeb/find-and-replace-anything","last_synced_at":"2026-03-10T03:34:05.379Z","repository":{"id":32971213,"uuid":"148239996","full_name":"mesqueeb/find-and-replace-anything","owner":"mesqueeb","description":"Replace one val with another or all occurrences in an object recursively. A simple \u0026 small integration.","archived":false,"fork":false,"pushed_at":"2025-02-19T18:47:36.000Z","size":2192,"stargazers_count":21,"open_issues_count":7,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-01T10:34:03.059Z","etag":null,"topics":["find-and-replace","find-and-replace-if","find-prop","find-replace","has-prop","javascript","recursively","replace-if","replace-prop-value","replace-value","search-object-prop","search-prop"],"latest_commit_sha":null,"homepage":"https://npmjs.com/find-and-replace-anything","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/mesqueeb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"mesqueeb","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2018-09-11T01:05:11.000Z","updated_at":"2025-02-19T18:47:39.000Z","dependencies_parsed_at":"2024-06-05T02:28:27.593Z","dependency_job_id":"173ea4d1-4796-4092-895c-9459bf15111e","html_url":"https://github.com/mesqueeb/find-and-replace-anything","commit_stats":{"total_commits":51,"total_committers":3,"mean_commits":17.0,"dds":0.3921568627450981,"last_synced_commit":"edea9f71059cb3b84e6d21cdee98e7c3a53dbe1a"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/mesqueeb/find-and-replace-anything","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesqueeb%2Ffind-and-replace-anything","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesqueeb%2Ffind-and-replace-anything/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesqueeb%2Ffind-and-replace-anything/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesqueeb%2Ffind-and-replace-anything/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mesqueeb","download_url":"https://codeload.github.com/mesqueeb/find-and-replace-anything/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesqueeb%2Ffind-and-replace-anything/sbom","scorecard":{"id":637321,"data":{"date":"2025-08-11","repo":{"name":"github.com/mesqueeb/find-and-replace-anything","commit":"4a21c316ce0772e6652a534b8e948ea2b93b247f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.8,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":3,"reason":"dependency not pinned by hash detected -- score normalized to 3","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/mesqueeb/find-and-replace-anything/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/mesqueeb/find-and-replace-anything/test.yml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   1 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":1,"reason":"9 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-xffm-g5w8-qvg7","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-67mh-4wv8-2f99","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-x574-m823-4x7w","Warn: Project is vulnerable to: GHSA-4r4m-qw57-chr8","Warn: Project is vulnerable to: GHSA-xcj6-pq6g-qj4x","Warn: Project is vulnerable to: GHSA-356w-63v5-8wf4","Warn: Project is vulnerable to: GHSA-859w-5945-r5v3"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T09:35:20.617Z","repository_id":32971213,"created_at":"2025-08-21T09:35:20.617Z","updated_at":"2025-08-21T09:35:20.617Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30323219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T01:36:58.598Z","status":"online","status_checked_at":"2026-03-10T02:00:06.579Z","response_time":106,"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":["find-and-replace","find-and-replace-if","find-prop","find-replace","has-prop","javascript","recursively","replace-if","replace-prop-value","replace-value","search-object-prop","search-prop"],"created_at":"2024-10-17T20:06:59.697Z","updated_at":"2026-03-10T03:34:05.359Z","avatar_url":"https://github.com/mesqueeb.png","language":"TypeScript","funding_links":["https://github.com/sponsors/mesqueeb"],"categories":[],"sub_categories":[],"readme":"# Find and replace anything 🎣\n\n\u003ca href=\"https://www.npmjs.com/package/find-and-replace-anything\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/find-and-replace-anything.svg\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/find-and-replace-anything\"\u003e\u003cimg src=\"https://img.shields.io/npm/dw/find-and-replace-anything.svg\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\n```\nnpm i find-and-replace-anything\n```\n\nReplace one val with another or all occurrences in an object recursively. A simple \u0026 small integration.\n\nThere are two methods you can import and use:\n\n- **findAndReplace** find `a` replace with `b` (recursively on an object)\n- **findAndReplaceIf** execute a function on every prop in an object recursively, and replace the prop with what the function returns\n\n## Meet the family (more tiny utils with TS support)\n\n- [is-what 🙉](https://github.com/mesqueeb/is-what)\n- [is-where 🙈](https://github.com/mesqueeb/is-where)\n- [merge-anything 🥡](https://github.com/mesqueeb/merge-anything)\n- [check-anything 👁](https://github.com/mesqueeb/check-anything)\n- [remove-anything ✂️](https://github.com/mesqueeb/remove-anything)\n- [getorset-anything 🐊](https://github.com/mesqueeb/getorset-anything)\n- [map-anything 🗺](https://github.com/mesqueeb/map-anything)\n- [filter-anything ⚔️](https://github.com/mesqueeb/filter-anything)\n- [copy-anything 🎭](https://github.com/mesqueeb/copy-anything)\n- [case-anything 🐫](https://github.com/mesqueeb/case-anything)\n- [flatten-anything 🏏](https://github.com/mesqueeb/flatten-anything)\n- [nestify-anything 🧅](https://github.com/mesqueeb/nestify-anything)\n\n## find and replace\n\nThis will find a value inside an object and replace it with another:\n\n- `findAndReplace(object, find, replace)`\n\n```js\nimport { findAndReplace } from 'find-and-replace-anything'\n\nfindAndReplace({deep: {nested: {prop: 'a'}}}, 'a', 'b')\n  // returns\n  {deep: {nested: {prop: 'b'}}}\n\nfindAndReplace('works on \"exact\" strings as well', 'a', 'b')\n  // returns\n  'works on \"exact\" strings as well'\n\nfindAndReplace('a', 'a', 'b')\n  // returns\n  'b'\n\n// works with other types as well:\nfindAndReplace({nr: 1}, 1, 100)\n  // returns\n  {nr: 100}\n```\n\n## find and replace IF\n\nThis will execute a provided function to every prop in the object recursively. The \"check\" function provided will receive the prop's value as param:\n\n- `findAndReplaceIf(object, checkFn)` checkFn receives each `propVal` of the object recursively\n\n```js\nimport { findAndReplaceIf } from 'find-and-replace-anything'\n\n// function that replaces 'a' with 'b'\nfunction checkFn (foundVal) {\n  if (foundVal === 'a') return 'b'\n  return foundVal\n  // always return original foundVal when no replacement occurs\n}\n\nfindAndReplaceIf({deep: {nested: {prop: 'a'}}}, checkFn)\n  // returns\n  {deep: {nested: {prop: 'b'}}}\n\n  // this is what gets executed in order:\n  checkFn({deep: {nested: {prop: 'a'}}})\n  checkFn({nested: {prop: 'a'}})\n  checkFn({prop: 'a'})\n  checkFn('a')\n  // the final execution replaces 'a' with 'b'\n  // and then returns the entire object\n\n// also works on non-objects\nfindAndReplace('a', checkFn)\n  // returns\n  'b'\n```\n\n## A note on plain objects vs classes\n\n\u003e only for `findAndReplace()`\n\nPlease note that it will also recursively look inside special objects like JavaScript classes etc. So make sure you test the behaviour properly in those cases! (especially when your classes have read-only properties etc.)\n\n```js\nclass MyClass {\n  constructor () {\n    this.prop = 1\n  }\n}\nconst target = {\n  prop: 1,\n  class: new MyClass()\n}\nfindAndReplace(target, 1, 2)\n  // this will replace 1 with 2 in the class as well and returns:\n  {prop: 2, class: {prop: 2}}\n```\n\nIf you need it to only recursively go through plain JavaScript object and avoid going in custom classes etc. you can pass a 4th parameter like so:\n\n```js\nfindAndReplace(target, 1, 2, {onlyPlainObjects: true})\n  // this will replace 1 with 2 only in the plain object and returns:\n  {prop: 2, class: {prop: 1}}\n```\n\n\u003e Also be careful with circular references! It will cause this library to crash.\n\n## Source code\n\nIt's literally just this:\n\n```js\n/**\n * @param {*} target Target can be anything\n * @param {*} find val to find\n * @param {*} replaceWith val to replace\n * @returns the target with replaced values\n */\nfunction findAndReplaceRecursively (target, find, replaceWith) {\n  if (!isObject(target)) {\n    if (target === find) return replaceWith\n    return target\n  }\n  return Object.keys(target)\n    .reduce((carry, key) =\u003e {\n      const val = target[key]\n      carry[key] = findAndReplaceRecursively(val, find, replaceWith)\n      return carry\n    }, {})\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmesqueeb%2Ffind-and-replace-anything","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmesqueeb%2Ffind-and-replace-anything","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmesqueeb%2Ffind-and-replace-anything/lists"}