Skip to content
badwordsfilter / 1.1.3

badwordsfilter 1.1.3

Install from the command line:
Learn more about npm packages
$ npm install @elsowiny/badwordsfilter@1.1.3
Install via package.json:
"@elsowiny/badwordsfilter": "1.1.3"

About this version

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.

Details


Assets

  • badwordsfilter-1.1.3-npm.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0

Recent versions

View all