alexzel / bad-words-next

JavaScript/TypeScript filter and checker for bad words aka profanity
MIT License
15 stars 4 forks source link

Replace filtered characters with per-character placeholder #15

Closed ufna closed 1 year ago

ufna commented 1 year ago

It'll be cool to have ability to filter like this:

MYBADWORD -> ***** MYWORD -> **

alexzel commented 1 year ago

Thanks for the feature request. I have implemented it in v2.2.0 with placeholderMode option that you can change to repeat and make the placeholder be just one character like * so it will achieve the behavior you describe above.

const badwords = new BadWordsNext({
  data: en,
  placeholder: '*',
  placeholderMode: 'repeat'
})
...
ufna commented 1 year ago

@alexzel works like a charm, thank you!