{"id":23507371,"url":"https://github.com/simplyhexagonal/multi-replace","last_synced_at":"2025-05-12T15:51:03.249Z","repository":{"id":57160397,"uuid":"408957468","full_name":"simplyhexagonal/multi-replace","owner":"simplyhexagonal","description":"Functions to easily perform various replace operations on a Javascript/Typescript string","archived":false,"fork":false,"pushed_at":"2023-09-23T20:37:29.000Z","size":175,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-27T04:01:47.787Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@simplyhexagonal/multi-replace","language":"TypeScript","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/simplyhexagonal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-09-21T19:59:13.000Z","updated_at":"2023-09-23T20:06:44.000Z","dependencies_parsed_at":"2022-09-09T10:21:09.796Z","dependency_job_id":null,"html_url":"https://github.com/simplyhexagonal/multi-replace","commit_stats":{"total_commits":28,"total_committers":2,"mean_commits":14.0,"dds":0.25,"last_synced_commit":"5ba2bc90d296d49260dcf93256be3f8ceae4b96c"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplyhexagonal%2Fmulti-replace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplyhexagonal%2Fmulti-replace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplyhexagonal%2Fmulti-replace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplyhexagonal%2Fmulti-replace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simplyhexagonal","download_url":"https://codeload.github.com/simplyhexagonal/multi-replace/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252762989,"owners_count":21800411,"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":[],"created_at":"2024-12-25T10:18:17.450Z","updated_at":"2025-05-12T15:51:03.205Z","avatar_url":"https://github.com/simplyhexagonal.png","language":"TypeScript","funding_links":["https://www.buymeacoffee.com/jeanlescure","https://www.patreon.com/jeanlescure"],"categories":[],"sub_categories":[],"readme":"# Multi Replace\n![Tests](https://github.com/simplyhexagonal/multi-replace/workflows/tests/badge.svg)\n[![Try multi-replace on RunKit](https://badge.runkitcdn.com/@simplyhexagonal/multi-replace.svg)](https://npm.runkit.com/@simplyhexagonal/multi-replace)\n\nOn a single call, perform multiple replace operations on a Javascript/Typescript string.\n\n## Open source notice\n\nThis project is open to updates by its users, I ensure that PRs are relevant to the community.\nIn other words, if you find a bug or want a new feature, please help us by becoming one of the\n[contributors](#contributors-) ✌️ ! See the [contributing section](#contributing).\n\n## Like this module? ❤\n\nPlease consider:\n\n- [Buying me a coffee](https://www.buymeacoffee.com/jeanlescure) ☕\n- Supporting me on [Patreon](https://www.patreon.com/jeanlescure) 🏆\n- Starring this repo on [Github](https://github.com/simplyhexagonal/multi-replace) 🌟\n\n## Usage\n\nImport `multiReplace`:\n\n```tsx\n// Node\nconst { multiReplace } = require('@simplyhexagonal/multi-replace');\n\n// ES6/Typescript\nimport { multiReplace } from '@simplyhexagonal/multi-replace';\n\n// Browser\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/@simplyhexagonal/multi-replace@latest/dist/multi-replace.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  const { multiReplace } = MultiReplace;\n\u003c/script\u003e\n```\n\nDefine one or more replace patterns:\n\n```ts\nconst firstReplacePattern = ['Greetings', async () =\u003e 'hello'];\nconst secondReplacePattern = [/stranger/g, 'friend'];\n\n// A replace pattern is an array where the first item is the \"matcher\"\n// and the second item is the \"replacement\".\n\n// A matcher can be either a string or a regular expression.\n// A replacement can be either a string or a function.\n```\n\nUse `multiReplace` to perform the replacements over your content:\n\n```ts\nconst content = 'Greetings stranger, I am also a stranger';\n\nconst result = await multiReplace(\n  content,\n  [\n    firstReplacePattern,\n    secondReplacePattern,\n  ],\n);\n\nconsole.log(result);\n// Hello friend, I am also a friend\n```\n\n## Synchronous usage\n\nIf you need to perform replacements synchronously simply use `multiReplaceSync`:\n\n```tsx\n// Node\nconst { multiReplaceSync } = require('@simplyhexagonal/multi-replace');\n\n// ES6/Typescript\nimport { multiReplaceSync } from '@simplyhexagonal/multi-replace';\n\n// Browser\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/@simplyhexagonal/multi-replace@latest/dist/multi-replace.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  const { multiReplaceSync } = MultiReplace;\n\u003c/script\u003e\n```\n\n## Contributing\n\nYes, thank you! This plugin is community-driven, most of its features are from different authors.\nPlease update the tests and don't forget to add your name to the `package.json` file.\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://jeanlescure.cr\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/3330339?v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eJean Lescure\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#maintenance-jeanlescure\" title=\"Maintenance\"\u003e🚧\u003c/a\u003e \u003ca href=\"https://github.com/simplyhexagonal/multi-replace/commits?author=jeanlescure\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"#userTesting-jeanlescure\" title=\"User Testing\"\u003e📓\u003c/a\u003e \u003ca href=\"https://github.com/simplyhexagonal/multi-replace/commits?author=jeanlescure\" title=\"Tests\"\u003e⚠️\u003c/a\u003e \u003ca href=\"#example-jeanlescure\" title=\"Examples\"\u003e💡\u003c/a\u003e \u003ca href=\"https://github.com/simplyhexagonal/multi-replace/commits?author=jeanlescure\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-enable --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\n## License\n\nCopyright (c) 2021-Present [MultiReplace Contributors](https://github.com/simplyhexagonal/multi-replace/#contributors-).\u003cbr/\u003e\nLicensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplyhexagonal%2Fmulti-replace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimplyhexagonal%2Fmulti-replace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplyhexagonal%2Fmulti-replace/lists"}