Registry / serialization / bad-words-plus

bad-words-plus

JSON →
library3.0.4jsnpmunverified

A Node.js profanity filter that extends the original badwords library by allowing the first and/or last letter of filtered words to be displayed. Current stable version is 3.0.4 (2020). No recent updates. Key differentiators: placeholder override, regex customization, add/remove words, empty list instantiation, and firstLetter/lastLetter display options. Requires Node >=12. Compared to alternatives like bad-words (the parent project), bad-words-plus adds these display options but may lag in maintenance.

npm install bad-words-plus
INSTALL
IMPORT
SIG · BAD-WORDS-PLUS
B
bad-words-plus
serializationjavascriptv3.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Filter
import Filter from 'bad-words-plus'
const Filter = require('bad-words-plus')
Package uses default export. ESM import works in Node 12+ with appropriate settings; require() is CommonJS and still works.
Filter (CommonJS)
const Filter = require('bad-words-plus')
const { Filter } = require('bad-words-plus')
CommonJS usage; do not destructure as named export.
Filter type
import type { FilterOptions } from 'bad-words-plus'
import { FilterOptions } from 'bad-words-plus'
FilterOptions is a TypeScript type, not a runtime value. Use type import.

Shows basic instantiation with firstLetter option, custom words, and isProfane check.

// Quick start: filter profanity with first letter visible import Filter from 'bad-words-plus'; // Create filter with options const filter = new Filter({ firstLetter: true, lastLetter: false }); // Clean a string console.log(filter.clean("Don't be an ash0le")); // "Don't be an a*****" // Add custom words filter.addWords('darn', 'heck'); console.log(filter.clean('What the heck!')); // "What the ****!" // Check if profane console.log(filter.isProfane('ash0le')); // true
Debug
Known issues
gotchaWhen using emptyList: true, the filter has no built-in bad words, so addWords must be used to add them.
fix
Use new Filter({ emptyList: true, list: ['bad', 'word'] })
affects: >=3.0.0
gotchaThe replaceRegex option overrides the default regex that matches characters. If misconfigured, the filter may not detect profanity.
fix
Ensure replaceRegex includes all characters you want to replace, e.g., /[A-Za-z0-9가-힣_]/g
affects: >=3.0.0
deprecatedPackage last updated in 2020; no recent maintenance. May have unpatched vulnerabilities or compatibility issues with newer Node versions.
fix
Consider migrating to actively maintained alternatives like 'bad-words' or 'leo-profanity'.
affects: >=3.0.0
gotchaThe 'list' option in constructor expects an array of strings; passing a single string will not work.
fix
Use new Filter({ list: ['word1', 'word2'] })
affects: >=3.0.0
Errors
Common errors & fixes
Error: Could not find module: bad-words-plus
Package not installed or not in node_modules
fix
Run 'npm install bad-words-plus'
TypeError: filter.clean is not a function
Using wrong import (e.g., destructuring { Filter })
fix
Use 'import Filter from 'bad-words-plus'' or 'const Filter = require('bad-words-plus')'
Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
Calling clean() or isProfane() without initializing filter
fix
Ensure filter is created: const filter = new Filter({...})
Upgrade
Version history
3.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
19 hits · last 30 days
node
16
OpenAI (training)
1
Resources
bad-words-plus — npm install bad-words-plus · libregistry