bad-words-next
JavaScript/TypeScript filter and checker for bad words aka profanity.
API documentation in GitHub Wiki.
Install
yarn add bad-words-next
or
npm install bad-words-next
Basic usage
const BadWordsNext = require('bad-words-next')
const en = require('bad-words-next/data/en.json')
const badwords = new BadWordsNext({ data: en })
console.log(badwords.check('S0me sh!tt is here'))
console.log(badwords.filter('S0me sh!tt is here'))
Add more dictionaries
const BadWordsNext = require('bad-words-next')
const en = require('bad-words-next/data/en.json')
const es = require('bad-words-next/data/es.json')
const fr = require('bad-words-next/data/fr.json')
const de = require('bad-words-next/data/de.json')
const ru = require('bad-words-next/data/ru.json')
const rl = require('bad-words-next/data/ru_lat.json')
const ua = require('bad-words-next/data/ua.json')
const pl = require('bad-words-next/data/pl.json')
const ch = require('bad-words-next/data/ch.json')
const badwords = new BadWordsNext()
badwords.add(en)
badwords.add(es)
badwords.add(fr)
badwords.add(de)
badwords.add(ru)
badwords.add(rl)
badwords.add(ua)
badwords.add(pl)
badwords.add(ch)
Dictionary files format
interface Data {
id: string
words: string[]
lookalike: Lookalike
}
interface Lookalike {
[key: string | number]: string
}
Options
interface Options {
data?: Data
placeholder?: string
specialChars?: RegExp
spaceChars?: string[]
confusables?: string[]
maxCacheSize?: number
}
Notes
-
Filtering may be potentially slow on large strings and large dictionaries
-
Dictionary words with spaces won't work
-
Dictionaries have to be improved over time