{"id":26134022,"url":"https://github.com/rodgeraraujo/profanity","last_synced_at":"2025-04-13T21:30:21.173Z","repository":{"id":49142366,"uuid":"302952544","full_name":"rodgeraraujo/profanity","owner":"rodgeraraujo","description":"A filter of swear words. 🤬","archived":false,"fork":false,"pushed_at":"2023-04-26T19:52:34.000Z","size":124,"stargazers_count":24,"open_issues_count":2,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-27T11:50:27.541Z","etag":null,"topics":["badwords","nodejs","profanity","profanity-detection","profanity-filter","swear-filter","typescript"],"latest_commit_sha":null,"homepage":"","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/rodgeraraujo.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-10T17:15:11.000Z","updated_at":"2025-03-26T16:29:01.000Z","dependencies_parsed_at":"2024-06-19T17:34:42.314Z","dependency_job_id":"4986790d-4241-49d6-9997-12d0e6e132cd","html_url":"https://github.com/rodgeraraujo/profanity","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodgeraraujo%2Fprofanity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodgeraraujo%2Fprofanity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodgeraraujo%2Fprofanity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodgeraraujo%2Fprofanity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rodgeraraujo","download_url":"https://codeload.github.com/rodgeraraujo/profanity/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248785732,"owners_count":21161341,"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":["badwords","nodejs","profanity","profanity-detection","profanity-filter","swear-filter","typescript"],"created_at":"2025-03-10T23:03:48.219Z","updated_at":"2025-04-13T21:30:21.136Z","avatar_url":"https://github.com/rodgeraraujo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Profanity\n\n\u003ca aria-label=\"npm package\" href=\"https://www.npmjs.com/package/profanity-js\"\u003e\n\u003cimg alt=\"\" src=\"https://img.shields.io/npm/v/profanity-js.svg\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/rodgeraraujo/profanity/issues\"\u003e\u003cimg src=\"https://img.shields.io/github/issues/rodgeraraujo/profanity.svg\"\u003e\u003c/a\u003e\n\u003ca aria-label=\"contributors graph\" href=\"https://github.com/rodgeraraujo/profanity/graphs/contributors\"\u003e\n\u003cimg src=\"https://img.shields.io/github/contributors/rodgeraraujo/profanity.svg\"\u003e\n\u003c/a\u003e\n\u003ca aria-label=\"license\" href=\"https://github.com/rodgeraraujo/profanity/blob/main/LICENSE.md\"\u003e\n\u003cimg src=\"https://img.shields.io/github/license/rodgeraraujo/profanity\" alt=\"\"\u003e\n\u003c/a\u003e\n\n\u003e *A filter of swear words.*\n\n## Instalation\n\n```sh\nnpm i profanity-js\n```\n\n## API\n\nThis module exports a constructor function which takes an `inputStr` string and `config` object, to creates a `Profanity` instance.\n\n    Profanity(inputStr, config)\n\nCreates a new `Profanity` instance.\n\n### Arguments\n\n- `inputStr` - Optional - A plain JavaScript string containing the value to be filtered.\n\n- `config` - Optional - A plain JavaScript object containing configuration options.\n\n#### inputStr\n- Input string to evaluate if contains profanity.\n\n#### config\n\nProfanity configurations.\n- `saveOriginal` - Define if the original input string will be saved.\n- `enabled` - Define if the filter will be enabled.\n- `placeHolder` - Character used to replace profane words.\n- `replaceRegex` - Regular expression used to replace profane words with placeHolder.\n- `separatorRegex` - Regular expression used to split a string into words.\n- `excludeWords` - List of words to be ignored when filter profane words.\n- `wordsList` - List of words to be override the default dictionary of profane words.\n- `language` - Language used to filter profane texts.\n\n### Return value\nA `Profanity` instance.\n\n#### Resources\nEvery resource is accessed via your `Profanity` instance:\n\n- `.censor()` - Evaluate if string is profanity and return an edited version.\n- `.isProfane()` - Evaluate if a string is a profane language.\n- `.censureWord()` - Censure a word with placeHolder characters.\n- `.loadOriginal()` - Return original text if config.saveOrigial as true.\n- `.addWords()` - Add word(s) to wordlist filter.\n- `.removeWords()` - Remove word(s) from wordlist filter.\n\n## Usage\n\n```js\nconst Profanity = require('profanity-js');\n```\n### 1. Censor swear words from a text\nBy default, `profanity` replaces each swear words with the string length with asterisk `*`.\n\n\n```js\nconst profanity = new Profanity();\n\nconsole.log(profanity.isProfane(\"merda\"));\n// log: true\n\nlet censoredText = profanity.censor(\"isso é uma merda\");\nconsole.log(censoredText); \n// log: isso é uma *****\n```\n\n### 2. Censor swear words with custom character (if in wordlits)\nIn `.censor()` asterisks in will be used to replace the swear words.\n\n```js\nlet censoredText = profanity.censor(\"You piece of sH1t\");\nconsole.log(censoredText); \n// log: You piece of ****\n```\n\n### 3. Check if the string contains any swear words\nFunction `.isProfane()` return `True` if any words in the given string has a word existing in the wordlist.\n\n```js\nlet dirtyText = \"That l3sbi4n did a very good H4ndjob.\";\n\nconsole.log(profanity.isProfane(dirtyText));\n// log: true\n```\n\n### 4. Add more censor words\n```js\nlet customBadwords = ['happy', 'sometext'];\n\nprofanity.addWords(...customBadwords);\n\nconsole.log(profanity.isProfane(\"Happy day bro!\"));\n// log: true\n```\n\n### 5. Remove censor words\n```js\nlet removeBadwords = ['asshole'];\n\nprofanity.removeWords(...removeBadwords);\n\nconsole.log(profanity.isProfane(\"Don't be an asshole\"));\n// log: false\n```\n\n### 6. Check if the string contains any swear words\nFunction `.isProfane()` return `True` if any words in the given string has a word existing in the wordlist.\n\n```js\nlet dirtyText = \"That l3sbi4n did a very good H4ndjob.\";\n\nconsole.log(profanity.isProfane(dirtyText));\n// log: true\n```\n\n### 7. Language support\nThe lib supports two languages they are Brazilian Portuguese and English, the defaults are Portuguese and to change this, see below.\n\n```js\nlet config = {\n    language: \"en-us\"\n};\n\nlet dirtyText = \"fuck this shit\";\n\nconst profanity = new Profanity(dirtyText, config)\n\nconsole.log(profanity.censor());\n// log: **** this ****\n```\n\n\u003e The `config` Object will be overwritten the default values.\n\n### 8. Overrides placeHolder\nTo use a custom placeHolder, just overwritten the default value with a config Object.\n\n```js\nlet config = {\n    placeHolder: \"-\"\n};\n\nlet dirtyText = \"fuck this shit\";\n\nconst profanity = new Profanity(dirtyText, config)\n\nconsole.log(profanity.censor());\n// log: ---- this ----\n```\n\n### 9. Overrides default dictionary\nTo overrides the default profane dictionary, just set the new `Array` of words in config Object.\n\n```js\nlet config = {\n    wordsList: ['shit', 'fuck', 'this']\n};\n\nlet dirtyText = \"fuck this shit\";\n\nconst profanity = new Profanity(dirtyText, config)\n\nconsole.log(profanity.censor());\n// log: **** **** *****\n```\n\n## Testing\n\n```sh\nnpm run test\n```\nor\n\n```sh\nyarn test\n```\n\n## License\nThis project is licensed under the MIT License - see the [LICENSE.md](https://github.com/rodgeraraujo/profanity/blob/main/LICENSE.md) file for details.\n\n## Contributing\nIf you want to contribute to a project and make it better, feel free to fork and contribute.\n\n## Special thanks to\n- [youngkaneda](https://github.com/youngkaneda) - For help and support with the Regex expressions and make this code better.\n\n## Author\n\nMade with ❤ by [Rogério Araújo](https://github.com/rodgeraraujo)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodgeraraujo%2Fprofanity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodgeraraujo%2Fprofanity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodgeraraujo%2Fprofanity/lists"}