{"id":19007838,"url":"https://github.com/topener/no-profanity","last_synced_at":"2025-04-22T19:26:21.087Z","repository":{"id":183461421,"uuid":"668027377","full_name":"Topener/no-profanity","owner":"Topener","description":"A JavaScript package to filter and detect profanity","archived":false,"fork":false,"pushed_at":"2023-08-14T13:45:35.000Z","size":800,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-17T10:58:15.944Z","etag":null,"topics":["package","profanity","profanity-filter"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/no-profanity","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/Topener.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-18T21:10:45.000Z","updated_at":"2024-12-10T08:34:42.000Z","dependencies_parsed_at":"2024-11-08T18:45:33.184Z","dependency_job_id":"ea31e91b-8993-4ccd-a648-71d10c526678","html_url":"https://github.com/Topener/no-profanity","commit_stats":null,"previous_names":["topener/no-profanity"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Topener%2Fno-profanity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Topener%2Fno-profanity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Topener%2Fno-profanity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Topener%2Fno-profanity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Topener","download_url":"https://codeload.github.com/Topener/no-profanity/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250307682,"owners_count":21409117,"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":["package","profanity","profanity-filter"],"created_at":"2024-11-08T18:39:27.075Z","updated_at":"2025-04-22T19:26:21.059Z","avatar_url":"https://github.com/Topener.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# no-profanity\n\nA JavaScript package to detect and filter profanity. Yes this code, contain profanity. But what do you expect from a no-profanity package.\n## Installation\n```\nnpm i no-profanity\n```\n## Credit\nThanks to [bad-words](https://github.com/web-mech/badwords) for the original package. This package is a rewrite of that package, with some extra features and a lot of performance improvements.\n\nThanks to [google-profanity-words](https://github.com/coffee-and-fun/google-profanity-words) for providing the list of profanities.\n\n## Usage\nUsing the no-profanity package is very simple. You can use it to detect profanity, or to filter profanity from a string. There are some basic options as well, such as overriding the placeholder character, or adding/removing words from the filterlist.\n\n### Check if a string contains profanity\nA basic sample showing a simple checker\n```js\nimport { isProfane } from 'no-profanity';\nconsole.log(isProfane(\"Don't be an asshole\")); // true\nconsole.log(isProfane(\"This is a nice text\")); // false\n```\n\n### Replace profanity in a string\nA basic sample showing how to replace profanities\n```js\nimport { replaceProfanities } from 'no-profanity';\nconsole.log(replaceProfanities(\"Don't be an asshole\")); // Don't be an *******\nconsole.log(replaceProfanities(\"This is a nice text\")); // This is a nice text\n```\n\n### Get profanities from a string\nA basic sample returning the profanities\n```js\nconsole.log(containsProfanities(\"what an asshole\"));\n```\n\nWill return:\n```js\n[ { \n    word: 'asshole', \n    index: 8 \n} ]\n```\n\n### Get all profanities\nA basic sample returning all profanities. It will take all options into account, such as excludes and includes. This can be useful in running tests, such as in the file [test/list.test.js](./test/list.test.js).\n\n```js\nimport { getProfanities } from 'no-profanity';\nconst options = {}; // add your options here\nconsole.log(getProfanities({options: options}));\n```\n\n## Options\nThere are some overrides possible, but as soon as you want to use an override you will no longer be able pass a string to the functions defined above, but instead, they require an arguments object, like this:\n\n```js\nreplaceProfanities({\n    testString: \"testable string\",\n    options: {}\n});\n```\n\n### Override placeholder\n The options object should contain a property called `replacement` which should be a string of length 1, unless you want a longer replacement value as the original wordlength. The default value is `*`.\n\n```js\nreplaceProfanities({\n    testString: \"testable string\",\n    options: {\n        replacement: '#'\n    }\n});\n```\n\n### Remove words from the filterlist\nThe options object should contain a property called `excludes` which should be an array of strings you don't want to filter on. \n\n```js\nreplaceProfanities({\n    testString: \"testable string\",\n    options: {\n        excludes: ['testable']\n    }\n});\n```\n\nYou can also remove all words from the filter list so you can start your own, using the `emptyList` property.\n\n```js\nreplaceProfanities({\n    testString: \"testable string\",\n    options: {\n        emptyList: true\n    }\n});\n```\n\n### Add words to the filterlist\nThe options object should contain a property called `includes` which should be an array of strings you want to filter on. \n\n```js\nreplaceProfanities({\n    testString: \"testable string\",\n    options: {\n        includes: ['testable']\n    }\n});\n```\n\n### Pre-sanitize the string\nThe options object has the option to contain a regex pattern to sanitize the string before checking for profanities. \n\n```js\nreplaceProfanities({\n    testString: \"testable string\",\n    options: {\n        preSanitize: /[^a-zA-Z0-9]/g\n    }\n});\n```\n\nAll matches will be replaced with an empty string. If you want to change the replacement for `preSanitize`, you can use the `preSanitizeReplacement` property.\n\n```js\nreplaceProfanities({\n    testString: \"tabs are the best\",\n    options: {\n        preSanitizeReplacement: \"spaces\",\n        preSanitize: /\\btabs\\b/,\n    }\n});\n```\n\n## bad-words package\nThis package is the replacement for the `bad-words` package which is outdated and slow. According to a handful of benchmarks, this package is about 150 times as fast. \n\nSee also [this](other-packages.md) page for more information and the migration guide.\n\nMost options from the `bad-words` package are usable in the `options` object to be used in this package. However, the `replaceRegex` option is not supported.\n\n## Contributing\nAny contributions are highly appreciated. If you want to contribute, please fork the repository and create a pull request. If you have any questions, feel free to create an issue.\n\n## License\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. With MIT comes the freedom to use the code for whatever you want, but a credit would be appreciated.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftopener%2Fno-profanity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftopener%2Fno-profanity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftopener%2Fno-profanity/lists"}