badword-util
- A highly consumable list of bad (profanity) English words
- Some ultilities functions for check badwords, find badwords, filter badwords...
- No dependencies
Install
npm install badword-util
Usage
var bwut = require('badword-util');
Get badwords data
This data has been exposed as
- an array
- an object
- a regular expression
depending on what is required for your purposes.
<<<<<<< HEAD
- var badwordArray = bwut.array;
- var badwordObject = bwut.object;
- var badwordRegex = bwut.regex;
Change badwords data
Add more badwords
bwut.addBadWords([...]);
;
Remove badwords
bwut.removeBadWords([...]);
;
Apply new dictionary
bwut.use([...]);
;
Badword utilities functions
Check if a word is bad word
var check = bwut.isBadWord(wordToCheck);
;
Find bad word(s) in text
var badWords = bwut.findBadWords(text); return an array of object with structure {content: 'bad word content', times: 'number of time this bad word had occurred'}
;
Filter bad word(s) in text
var godOne = bwut.filterBadWords(text, badWords, character, numberOfChar); replace bad word found in text
- badwords here is array which restrict bad words to check
- character here is the character will be replace for each character of bad word, if character is undefined or null or empty then '*' will be use
- numberOfChar here is the number character of bad word will be replace by character count from the end of bad word (eg: found bad word 'fuck' with numberOfChar is 2 then the result will be 'fu**'), if numberOfChar is undefined or null or bigger than bad word's length then all bad word's character will be replace.
;
Testing
=======
Requires Mocha
Script
npm installnpm test