https://github.com/krsbx/badwords-ts
Badwords js alternatives
https://github.com/krsbx/badwords-ts
Last synced: 3 months ago
JSON representation
Badwords js alternatives
- Host: GitHub
- URL: https://github.com/krsbx/badwords-ts
- Owner: krsbx
- License: mit
- Created: 2022-09-02T10:46:31.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-01T15:00:00.000Z (about 2 years ago)
- Last Synced: 2025-02-12T13:18:55.920Z (4 months ago)
- Language: TypeScript
- Size: 793 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Badwords-TS
A [badwords-js](https://github.com/web-mech/badwords) alternatives
# Why use Badwords-TS
Do you ever need to use more filters for different languanges than english? Ever though that some of your languanges is not supported by `badwords-js`? This package will fix those problems for you. By having a list of bad words in clouds, you can load it on the go. An example of the settings can be found in [badwords-ts.settings.json](./src/test/badwords-ts.settings.json).
# How to use?
It use singleton so all the settings for the instance can be use all around the projects. For using the instance, just use the `instance` property from `BadwordFilter` class.
```ts
import BadwordFilter from 'badwords-ts';///
// Using the singleton instance
BadwordFilter.instance;///
```# API
### Removing Badwords
```ts
BadwordFilter.instance.clean('just a bad word');
```### Changing the censors/placeholder
```ts
// By default is using asterisk (*)
BadwordFilter.instance.placeHolder = '#'; // It will change censors to # instead of *
```### Add a New Bad Word
```ts
BadwordFilter.instance.addWords('txt', 'asd'); // Will mark 'txt' and 'asd' as a bad word
```### Exclude a Bad Word
```ts
BadwordFilter.instance.removeWords('txt', 'asd'); // Will mark 'txt' and 'asd' as not a bad word
```### Check a word is a bad word
```ts
BadwordFilter.instance.isProfane('bad'); // Will return a boolean
```### Download word banks from the settings
```ts
BadwordFilter.instance.downloadWordBank();
```### Load word banks from the settings
```ts
BadwordFilter.instance.loadWordBank();
```