{"id":18998720,"url":"https://github.com/foxxmd/redact-string","last_synced_at":"2026-05-13T20:31:57.164Z","repository":{"id":180451429,"uuid":"665156857","full_name":"FoxxMD/redact-string","owner":"FoxxMD","description":"Redact part or all of a string","archived":false,"fork":false,"pushed_at":"2023-07-11T15:42:08.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-14T06:36:00.751Z","etag":null,"topics":["javascript","redact","redaction","replace-text","string","string-manipulation","typescript"],"latest_commit_sha":null,"homepage":"https://foxxmd.github.io/redact-string","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/FoxxMD.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}},"created_at":"2023-07-11T14:59:57.000Z","updated_at":"2023-07-11T15:29:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"fb7f17c9-dc50-4760-9a03-94391c4b3a10","html_url":"https://github.com/FoxxMD/redact-string","commit_stats":null,"previous_names":["foxxmd/redact-string"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoxxMD%2Fredact-string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoxxMD%2Fredact-string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoxxMD%2Fredact-string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoxxMD%2Fredact-string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FoxxMD","download_url":"https://codeload.github.com/FoxxMD/redact-string/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240018686,"owners_count":19734872,"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":["javascript","redact","redaction","replace-text","string","string-manipulation","typescript"],"created_at":"2024-11-08T17:47:43.948Z","updated_at":"2026-04-18T10:30:18.560Z","avatar_url":"https://github.com/FoxxMD.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# redact-string\n\nRedact (replace) part or all of a string with a character.\n\n## Why another redact package?\n\nThe other popular packages seem to be restricted to a certain behavior:\n\n* Redaction of objects/json (instead of plain variables/values you control)\n* Redaction **entirely** replaces value leaving no structure or hint of what it was\n\nThis didn't fit my needs. I wanted to be able to control how many characters were replaced as well as leave part of the structure intact for hinting in logging. A prime example being replacing _part_ of an IP address so users can view/post logs which confirm correct settings but don't give away full addresses IE `192.168.1.105` -\u003e `**********105`\n\n# Install/Usage\n\n```\nnpm install @foxxmd/react-string\n```\n\n```js\nimport {reactString} from '@foxxmd/redact-string';\n\nconsole.log(reactString('192.168.1.105', 3)); // 3 is the number of character to leave visible\n// *********105\n```\n\n# Options\n\nAn optional, third argument can be passed that defines how the redact occurs:\n\n```ts\nexport interface RedactOptions {\n    /**\n     * Replace characters starting at the start or end of string (default start)\n     * */\n    replaceFrom?: 'start' | 'end'\n    /**\n     * The character/string that characters are replaced with (default '*')\n     * */\n    replaceWith?: string\n    /**\n     * Which type of characters to replace in the string (default any)\n     * */\n    replace?: 'any' | 'alphanumeric' | 'alpha' | 'numeric'\n}\n```\n\n# Examples\n\n```js\n\n// replace all but last 3 characters\nconsole.log(reactString('192.168.1.105', 3));\n// *********105\n\n// replace all but first 3 characters\nconsole.log(reactString('192.168.1.105', 3, {replaceFrom: 'end'}));\n// 192**********\n\n// replace all but last 3 characters, numeric only\nconsole.log(reactString('192.168.1.105', 3, {replace: 'numeric'}));\n// ***.***.*.105\n\n// replace all but last 5 characters with 'X'\nconsole.log(reactString('superSecretPassword', 5, {replaceWith: 'X'}));\n// XXXXXXXXXXXXXXsword\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxxmd%2Fredact-string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoxxmd%2Fredact-string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxxmd%2Fredact-string/lists"}