no-swears
Automagically filter out swear words in strings
Very simple package for censoring swear words from JavaScript strings,
replacing offending words with "****".
Usage
npm install --save no-swears
'use strict'
const noswears = require('no-swears')
filter()
This is the most basic filtering function, and requires the offending
string and a callback, returning the cleaned up string to the program.
let badString = "this is a bitching string"
noswears.filter(badString, goodString => {
console.log(goodString)
})
hasSwears()
This just returns true or false to callback depending on whether the passed string
contains a swear word
let badString = "this is a bitching string"
noswears.hasSwears(badString, swearBool => {
console.log(swearBool)
})
This just returns true or false synchronously to be used in true/false conditions
let badString = "this is a bitching string"
if (noswears.hasSwearsSync) {
console.log("Has swears!")
}