Skip to content

Latest commit

 

History

History
69 lines (45 loc) · 3.22 KB

README.md

File metadata and controls

69 lines (45 loc) · 3.22 KB

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

Function Params Type Required Default Return Description
flag text string yes boolean Checks if passed text contains bad word.
badwords text string yes array Get all contained bad words from text.
filter text string yes string Trim bad words from text.
censor text string yes string Censors passed text with replacement.
replacement string no *** string
analyze text string yes object Outputs 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 😉