{"id":21224081,"url":"https://github.com/kodie/replace-once","last_synced_at":"2025-07-10T14:31:17.669Z","repository":{"id":57353773,"uuid":"123350526","full_name":"kodie/replace-once","owner":"kodie","description":"Make multiple replacements in a string without replacing ones that have already been replaced.","archived":false,"fork":false,"pushed_at":"2023-01-06T19:56:52.000Z","size":5,"stargazers_count":9,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-28T15:22:03.474Z","etag":null,"topics":["array","find","once","replace","string","unique"],"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/kodie.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-28T22:35:08.000Z","updated_at":"2022-10-22T17:25:33.000Z","dependencies_parsed_at":"2023-02-06T08:31:21.963Z","dependency_job_id":null,"html_url":"https://github.com/kodie/replace-once","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodie%2Freplace-once","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodie%2Freplace-once/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodie%2Freplace-once/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodie%2Freplace-once/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kodie","download_url":"https://codeload.github.com/kodie/replace-once/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225640771,"owners_count":17501018,"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":["array","find","once","replace","string","unique"],"created_at":"2024-11-20T22:54:56.988Z","updated_at":"2024-11-20T22:54:57.594Z","avatar_url":"https://github.com/kodie.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# replace-once\n\n[![npm package version](https://img.shields.io/npm/v/replace-once.svg?style=flat-square)](https://www.npmjs.com/package/replace-once)\n[![Travis build status](https://img.shields.io/travis/kodie/replace-once.svg?style=flat-square)](https://travis-ci.org/kodie/replace-once)\n[![npm package downloads](https://img.shields.io/npm/dt/replace-once.svg?style=flat-square)](https://www.npmjs.com/package/replace-once)\n[![code style](https://img.shields.io/badge/code_style-standard-yellow.svg?style=flat-square)](https://github.com/standard/standard)\n[![license](https://img.shields.io/github/license/kodie/replace-once.svg?style=flat-square)](license.md)\n\nMake multiple replacements in a string without replacing ones that have already been replaced.\n\n## Installation\n\n```shell\nnpm install --save replace-once\n```\n\n## Usage\n\n### replaceOnce(str, find, replace, [ flags ])\n\n```javascript\nconst replaceOnce = require('replace-once')\n\nvar str = 'abc abcd a ab'\nvar find = ['abcd', 'abc', 'ab', 'a']\nvar replace = ['a', 'ab', 'abc', 'abcd']\nreplaceOnce(str, find, replace, 'gi')\n//=\u003e 'ab a abcd abc'\n```\n\n### Parameters\n\n#### str (string)\n\nThe string to do replacements on.\n\n#### find (array)\n\nAn array of strings to search for when doing replacements. Must be in the same order as their replacement specified inside of the `replace` parameter. Strings may contain [Regular Expressions](https://en.wikipedia.org/wiki/Regular_expression) (regexp).\n\n#### replace (array)\n\nAn array of strings to replace the strings specified inside of the `find` parameter with. Must be in the same order as their counterpart specified inside of the `find` parameter.\n\n\n#### flags (string)\n\n*Optional*\n\nRegExp flags to use when doing replacements. (e.g `g` for global, `i` for case-insensitive)\n\n## License\nMIT. See the [license.md file](license.md) for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkodie%2Freplace-once","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkodie%2Freplace-once","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkodie%2Freplace-once/lists"}