The badwords-js-detector library exported as Node.js modules.
npm install badwords-js-detectorbash
$ npm i badwords-js-detector
`
Using CDN:
`html
`
$3
`javascript
// CJS
const { Detector } = require('badwords-js-detector');
const badwords = new Detector();
// ESM
import { Detector } from 'badwords-js-detector';
const badwords = new Detector();
// CDN
const badwords = new Detector();
`
$3
`javascript
const response = badwords.filter('Hello fuck you...');
console.log(response);
/*
Expected output:
{
bad-words-list: [
'fuck'
],
bad-words-total: 1,
censor-character: '*',
content: 'Hello fuck you...',
content-filtered: 'Hello ** you...'
}
*/
// You can customized censor-character
const badwords = new Detector({ placeholder: '@' });
const response = badwords.filter('Hello fuck you...');
console.log(response);
/*
Expected output:
{
bad-words-list: [
'fuck'
],
bad-words-total: 1,
censor-character: '@',
content: 'Hello fuck you...',
content-filtered: 'Hello @@@@ you...'
}
*/
``