2.1.3 • Published 1 year ago

react-badword v2.1.3

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

react-badword

A React hook for filter badwords

Installation

npm i react-badword --save

Usage

import { useBadWords } from 'react-badword';

const {
  filterBadWord,
} = useBadWords();

console.log(filterBadWord("What the hell")); // What the ****

Placeholder Overrides

const options = {
  placeholder: '#'
};
const {
  filterBadWord,
} = useBadWords(options);

console.log(filterBadWord("What the hell")); // What the ####

Add words to the blacklist

const blackList = ['ass', 'cum'];
const {
  addWords,
} = useBadWords();

useEffect(() => {
  addWords(blackList);
}, []);

console.log(filterBadWord("cum to me")); // *** to me

Instantiate with an empty list bad words

const options = {
  emptyList: true
};
const {
  filterBadWord,
} = useBadWords(options);

console.log(filterBadWord("What the hell")); // What the hell

Remove words from the blacklist

const whiteList = ['ass', 'cum'];
const {
  removeWord,
} = useBadWords();

useEffect(() => {
  removeWord(whiteList);
}, []);

console.log(filterBadWord("cum to me")); // cum to me

Check for obscene content

const {
  hasBadWord,
} = useBadWords();

console.log(hasBadWord("cum to me")); // true

Parameters

  • options object Filter instance options (optional)
  • options.emptyList boolean Instantiate filter with no blacklist
  • options.placeholder string Character used to replace obscene words.
2.1.3

1 year ago

2.1.2

1 year ago

2.0.2

1 year ago

1.0.0

1 year ago