@elsowiny/badwordsfilter
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published
cover photo

CodeQL

buildandtest

codecov

Install

npm install 

Usage

Check if a word is profane

import {profane, filter, addWord, removeWord, filterArray, FilterConfig as fc} from "@elsowiny/badwordsfilter";

console.log(profane(username));
//returns true or false bool

For adding/exluding certain words just supply a list of those words to the config object

import {profane, filter, addWord, removeWord, filterArray, FilterConfig as fc} from "@elsowiny/badwordsfilter";

fc.include(["noob", "dang it"])
fc.exclude(["obgyn", "bloody"]) // can include or exclude as much as you want

console.log(filter("noob"))
// ****

console.log(filter("obgyn"))
// obgyn

Add/remove individual strings

import {profane, filter, addWord, removeWord, filterArray, FilterConfig as fc} from "@elsowiny/badwordsfilter";

addWord("noodle");

removeWord("darn");

console.log(filterArray["noodle", "darn"])
// ['******', 'darn']

Change the asterik(*) to be a different replacement value when filtering

import {profane, filter, addWord, removeWord, filterArray, FilterConfig as fc} from "@elsowiny/badwordsfilter";

fc.replacer("x") // sets the value of the replacer

addWord("noob");
console.log(filter("noob"));
// xxxx
console.log(filterArray(["noob", "noodle"]))
// ['xxxx', 'noodle'];

Testing

Requires

  • Jest, Babel (specified in Dev Dependencies)
npm test

Runs Jest using the babel.config settings as needed to run tests for TS by Jest.

Package Sidebar

Install

npm i @elsowiny/badwordsfilter

Weekly Downloads

1

Version

1.1.3

License

MIT

Unpacked Size

4.9 kB

Total Files

3

Last publish

Collaborators

  • elsowiny