{"id":15471883,"url":"https://github.com/thadeu/dry-replacer-js","last_synced_at":"2026-03-03T18:03:42.443Z","repository":{"id":65633329,"uuid":"596155620","full_name":"thadeu/dry-replacer-js","owner":"thadeu","description":"🐍 A simple and lightweight library to replace variables in the JSON template  ","archived":false,"fork":false,"pushed_at":"2025-01-16T02:34:26.000Z","size":412,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-04T00:36:02.618Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/thadeu.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-02-01T15:30:09.000Z","updated_at":"2025-01-16T02:34:27.000Z","dependencies_parsed_at":"2023-02-17T09:15:27.692Z","dependency_job_id":"9f774293-fef1-4f4e-b29a-54efcb9313a9","html_url":"https://github.com/thadeu/dry-replacer-js","commit_stats":{"total_commits":31,"total_committers":1,"mean_commits":31.0,"dds":0.0,"last_synced_commit":"eabcfde20bde0903251fe82dde1c03144557689d"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/thadeu/dry-replacer-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thadeu%2Fdry-replacer-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thadeu%2Fdry-replacer-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thadeu%2Fdry-replacer-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thadeu%2Fdry-replacer-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thadeu","download_url":"https://codeload.github.com/thadeu/dry-replacer-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thadeu%2Fdry-replacer-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30054012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T17:46:22.538Z","status":"ssl_error","status_checked_at":"2026-03-03T17:46:22.036Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-10-02T02:22:07.600Z","updated_at":"2026-03-03T18:03:42.425Z","avatar_url":"https://github.com/thadeu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dry-replacer-js\n\n🐍 A simple and lightweight library to replace variables in the JSON template  \n\n[![ci](https://github.com/thadeu/dry-replacer-js/actions/workflows/ci.yml/badge.svg)](https://github.com/thadeu/dry-replacer-js/actions/workflows/ci.yml)\n[![Npm package version](https://badgen.net/npm/v/dry-replacer-js)](https://www.npmjs.com/package/dry-replacer-js)\n\n## Install\n\nInstall via yarn or npm\n\n```bash\n$ yarn add dry-replacer-js@latest\n```\n\nor\n\n```bash\n$ npm i dry-replacer-js@latest\n```\n\nor directly from Github\n\n```bash\n$ pnpm i thadeu/dry-replacer-js\n```\n\n## Usage\n\n```js\nimport dryreplacer from 'dry-replacer-js'\n```\n\nImage that your json to be this.\n\n```js\nconst data = {\n  id: 1,\n  name: 'test',\n  accepted: true,\n  obj: {\n    id: 1,\n    name: 'obj',\n    list: ['a', 'b', 'c'],\n  },\n  list: ['a', 'b', 'c'],\n  listobjs: [\n    {\n      id: 1,\n      name: 'obj1',\n      list: ['a', 'b', 'c'],\n    },\n    {\n      id: 2,\n      name: 'obj2',\n      list: ['d', 'e', 'f'],\n    },\n    {\n      id: 3,\n      name: 'obj3',\n      list: ['g', 'h', 'i'],\n    },\n  ],\n  complex: [\n    {\n      id: 1,\n      obj: {\n        id: 999,\n        name: 'complex',\n      },\n    },\n  ],\n}\n```\n\nSo, you create a template and `try` replace variables to final data.\n\nFor simple example with fixed value.\n\n```js\nlet template = {\n  code: 'fixedvalue',\n}\n\nconst replacer = new dryreplacer(data, { strict: true })\nlet result = replacer.try(JSON.stringify(template, null, 4))\n```\n\nOthers examples.\n\n```js\nlet template = {\n  name: '{{name}}',\n}\n\nconst replacer = new dryreplacer(data)\nlet result = replacer.try(JSON.stringify(template, null, 4))\n```\n\nYou can also pass get [iteratee](https://lodash.com/docs/4.17.15#get) path to variable, for example.\n\n```js\nlet template = {\n  id: '{{obj.id}}',\n  name: '{{obj.name}}',\n  list: '{{obj.list}}',\n}\n\nconst replacer = new dryreplacer(data)\nlet result = replacer.try(JSON.stringify(template, null, 4))\n```\n\nUse imagination to create a bunch of variables.\n\n```js\nlet template = {\n  id: '{{obj.id}}',\n  name: '{{obj.name}}',\n  url: 'https://test.com/{{obj.id}}?name={{obj.name}}\u0026accepted={{accepted}}',\n}\n\nconst replacer = new dryreplacer(data)\nlet result = replacer.try(JSON.stringify(template, null, 4))\n```\n\n# Contributing\n\nOnce you've made your great commits (include tests, please):\n\n1. Fork this repository\n2. Create a topic branch - `git checkout -b my_branch`\n3. Push to your branch - `git push origin my_branch`\n4. Create a pull request\n\nThat's it!\n\nPlease respect the indentation rules and code style. And use 2 spaces, not tabs. And don't touch the version thing or distribution files; this will be made when a new version is going to be released.\n\n# MIT License\n\nCopyright (c) 2023 Thadeu Esteves\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthadeu%2Fdry-replacer-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthadeu%2Fdry-replacer-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthadeu%2Fdry-replacer-js/lists"}