FilterKata is a lightweight and customizable TypeScript class to detect and censor inappropriate or offensive words from text input. Perfect for chat systems, comment moderation, forums, and more.
Install via npm:
npm install filter-kata
Or using Yarn:
yarn add filter-kata
import { FilterKata } from 'filter-kata';
const filter = new FilterKata();
filter.([, ]);
const result = filter.cek('You are so stupid!');
console.log(result); // true
const censored = filter.sensor('You are so stupid!');
console.log(censored); // You are so ******
You can customize the censor character:
filter.sensor('You are evil', '#'); // You are ####
filter.hapus(['stupid']);
console.log(filter.daftar()); // ['evil']
| Method | Description |
|---|---|
tambah(kataList: string[]) | Add words to the filter |
cek(teks: string): boolean | Check if text contains offensive words |
sensor(teks: string, mask: string = '*') | Censor the offensive words in the text |
hapus(kataList: string[]) | Remove words from the filter list |
daftar(): string[] | Get the current list of filtered words |
MIT © kikuk24
End of Project Documentation. Explore other works.