A simple module that filters rude words from a given text.
Install with npm
npm install rude-filter
or with yarn
yarn add rude-filter
To add or remove rude words from the filter, use the following methods:
RudeFilter.addRudeWords(["word1", "word2", ...]);
RudeFilter.removeRudeWords(["word1", "word2", ...]);
To get a list of the current rude words in the filter or to clear the filter, use the following methods:
RudeFilter.getRudeWords(); // Returns an array of the current rude words
RudeFilter.clearRudeWords(); // Removes all rude words
To filter text and replace any instances of rude words with a specified replacement string (default is "[censored]"), use the following method:
const text = "This is a rude and inappropriate message.";
const filteredText = RudeFilter.filter(text);
console.log(filteredText);
// Output: "This is a [censored] and [censored] message."
To filter text and replace any instances of rude words with a custom replacement string, use the following method:
const text = "This is a rude and inappropriate message.";
const filteredText = RudeFilter.filter(text, "****");
console.log(filteredText);
// Output: "This is a **** and **** message."