vaxerski / Proper-Wordcheck

Check for words properly, not with .indexOf()

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

npm minified size Snyk Vulnerabilities for npm package GitHub issues GitHub last commit npm Eating Cake

Proper-Wordcheck

So you can stop using indexOf() and actually detect people trying to sneak through.

Usage

To install, run

npm install proper-wordcheck

Basic usage example:

//require the package
const wordcheck = require('proper-wordcheck');

//Add words to the list
wordcheck.addBadWord('pineapple');

//check if a message has it
if(wordcheck.checkForWord('Who even puts pineapple on pizza?'))
  return console.log("bad word detected!");
else
  return console.log("message clear chief.");

Full list of commands

addBadWord(word);

Add a bad word to the badWord list. (string)
Returns: nothing.

addBadWords(words);

Add multiple bad words to the badWord list. (array)
Returns: nothing.

removeBadWord(word);

Remove bad word from the badWord list. (string)
Returns: nothing.

checkForWord(content);

Check a string (content) for containing any of the bad words.
Returns: true on match, false otherwise.

allowUnicode(state);

Allow or disallow unicode. Makes the checks a bit worse but avoids false positives (See Issue #1)
Returns: nothing.

addToWhitelist(word);

Add a word to white-list, so it will be skipped. Ex. badword = apple, whitelist = applepie, checkForWord("applepies are great") will return false.

Issues

All issues or pull requests are welcome.
These checks won't be perfect, but I'm trying to make them as good as possible.

Licensing

This repo uses the MIT license.

About

Check for words properly, not with .indexOf()

License:MIT License


Languages

Language:JavaScript 100.0%