npm module for removing disallowed words
npm install disallowed
Require the package
const disallowed = require('disallowed')
To set the disallowed words, pass in an array. This will be stored locally in json format.
Then, pass the string in that you want to remove the disallowed words from:
disallowed.disallow(' this foo aint bar. sometimes, you go to a baz and the food is foo, but the bar is bad.');
keep in mind, the disallowed words are writing to the file system which means it will not happen instantly. It is best to wait until that operation has time to complete before using the disallow function. The disallowed words will be persisted, so unless the words change, you should only need to set it up once.