node-profanity-filter
v3.0.1
Published
A Node.js profanity filter with support for exact matching, obfuscated word detection, and customizable replacement.
Downloads
467
Maintainers
Readme
Node Profanity Filter
A Node.js profanity filter with support for exact matching, obfuscated word detection, and customizable replacement.
Table of Contents
Installation
You can install the node-profanity-filter package using npm:
npm install node-profanity-filterUsage
import { Filter } from 'node-profanity-filter';
const filter = new Filter({
wordBoundaries: true,
normalize: true,
strict: false,
replaceWith: '',
words: ['badword']
});
// true
console.log(filter.isProfane('badword'));
// false
console.log(filter.isProfane('goodword'));
// true
console.log(filter.isProfane('b@dw0rd', {normalize: true}));
// result: {text: "I like your .", matches: string[]}
console.log(filter.replace('I like your badword.'));
// result: {text: "I like your cat.", matches: string[]}
console.log(filter.replace('I like your badword.', 'cat'));Options
| Option | Type | Default | Description |
|-------------------|------------|---------|--------------------------------------------------------------|
| wordBoundaries | boolean | false | Match only whole words instead of substrings |
| normalize | boolean | true | Normalize common character obfuscations before matching |
| replaceWith | string | '' | String to replace detected profane words with |
| words | string[] | [ ] | List of words to include in the filter |
Author
Created by Crytek1012.
License
This project is licensed under the MIT License.
