Censors blacklisted words with built in lists of words that can be used.
This library is available through the npm registry.
NPM
$ npm -i @princedev/redact
Yarn
$ yarn add @princedev/redact
Start using it by importing the library first.
const redact = require('@princedev/redact');
import { redact } from '@princedev/redact';
Redact or censor a word from a sentence
import { redact } from '@princedev/redact';
const englishProfanity = ['fuck', 'shit', ...];
redact('Fuck yeah', englishProfanity,);
// output: **** yeah
redact('Fuck yeah', englishProfanity, {
grawlix: '$',
replaceByLength: false,
});
// output: $ yeah
Can also be done in this way.
import redact from '@princedev/redact';
const englishProfanity = ['fuck', 'shit', ...];
redact.redact('Fuck yeah', englishProfanity);
// output: **** yeah
redact.redact('Fuck yeah', englishProfanity, {
grawlix: '$',
replaceByLength: false,
});
// output: $ yeah
Read the docs for more.
- Prince Neil Cedrick Castro - Initial work
See also the list of contributors who participated in this project.