1.0.1 • Published 2 years ago

indonesian-badwords v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Indonesian Badwords

Downloads License MIT Size

This is a small JavaScript utility library to find and replace bad/swearing/cursing words in Bahasa Indonesia.

Live Demo

Installation

Using NPM

npm install indonesian-badwords

Using Yarn

yarn add indonesian-badwords

Usage

A basic example looks like this:

const badwords = require("indonesian-badwords");

console.log(badwords.flag("halo, namaku budi")); // false
console.log(badwords.flag("halo, namaku babi")); // true

console.log(badwords.filter("halo, namaku budi")); // halo, namaku budi
console.log(badwords.filter("halo, namaku babi")); // halo, namaku

console.log(badwords.badwords("halo, namaku budi")); // []
console.log(badwords.badwords("halo, namaku babi")); // ['anjing']

console.log(badwords.censor("halo, namaku budi")); // halo, namaku budi
console.log(badwords.censor("halo, namaku babi")); // halo, namaku ***

console.log(badwords.analyze("halo, namaku budi")); // Returns object, see table below
console.log(badwords.analyze("halo, namaku babi")); // Returns object, see table below

Available Functions

FunctionParamsTypeRequiredDefaultReturnDescription
flagtextstringyesbooleanChecks if passed text contains bad word.
badwordstextstringyesarrayGet all contained bad words from text.
filtertextstringyesstringTrim bad words from text.
censortextstringyesstringCensors passed text with replacement.
replacementstringno***string
analyzetextstringyesobjectOutputs object of original text, number of words, censored text, array of bad words, count of bad words, and index of individual bad words.

Test

Clone this repository and run the following:

npm run test

Contributing

If you think the dictionary is missing a bad word, feel free to submit a PR.

Semoga bermanfaat 😉