badwords-detector
v0.0.2
Published
Advanced bad word filterer.
Downloads
9
Maintainers
Readme
badwords-detector
Do you need my help? Visit our Discord server.
Node Version >= 16.16.0
Installation
npm i badwords-detector --save
# or
yarn add badwords-detector
Importing
// CJS
const { Detector } = require("badwords-detector");
const badwords = new Detector();
// ESM
import { Detector } from "badwords-detector";
const badwords = new Detector();
Usage
console.log(badwords.filter("I'm a badword!")); // String
console.log(badwords.detect("I'm a badword!")); // Boolean
/*
Output:
I'm a badword!
false
*/
badwords.addWords("badword"); // String or Array
console.log(badwords.filter("I'm a badword!"));
console.log(badwords.detect("I'm a badword!"));
/*
Output:
I'm a ****!
true
*/
// All Functions
badwords.filter(text: string) // Censore the badword
badwords.detect(text: string) // Detect the badword
badwords.addWords(...words: string[]) // Add a new word(s)
badwords.removeWords(...words: string[]) // Remove word(s)
badwords.setWords(...words: string[]) // Set words to [string]
badwords.clearWords() // Reset all words (with defaults)
badwords.getWords() // Get all words