# devspeed-filterjs

> filter.js is an javaScript library that makes it easy to filter User inputs.

Latest version **2.0.7** (published 2022-10-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install devspeed-filterjs
pnpm add devspeed-filterjs
yarn add devspeed-filterjs
bun add devspeed-filterjs
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.7 |
| Published | 2022-10-11 |
| First published | 2021-06-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 39.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | SilentWolf |
| Maintainers | silentwolf-dev |
| Keywords | bad words, filter-js, JavaScript, bad-words, censor, cuss word blocker, swear word blocker, text filter, badword |

## Links

- npm: https://www.npmjs.com/package/devspeed-filterjs
- Repository: https://github.com/DevSpeedjs/DevSpeed-filterjs
- Homepage: https://github.com/DevSpeedjs/DevSpeed-filterjs#readme
- Issues: https://github.com/DevSpeedjs/filterjs/issues
- npm.io page: https://npm.io/package/devspeed-filterjs

## Recent versions

- 2.0.7 (latest) — 2022-10-11
- 2.0.6 — 2022-10-01
- 2.0.5 — 2022-10-01
- 2.0.4 — 2022-10-01
- 2.0.3 — 2022-10-01
- 2.0.2 — 2022-09-24
- 2.0.1 — 2022-09-24
- 2.0.0 — 2022-09-23
- 1.1.17 — 2021-08-09
- 1.1.16 — 2021-08-03
- 1.1.15 — 2021-07-28
- 1.1.14 — 2021-07-25
- 1.1.13 — 2021-07-23
- 1.1.12 — 2021-07-23
- 1.1.11 — 2021-07-23
- … 12 more at https://npm.io/package/devspeed-filterjs/versions

## README

# Filterjs

This package has been fully re-created the documentation below will help you with the new syntax.

Another package for filtering text and curse words. 

## Quick start

```js

const {TextFilter} = require('devspeed-filterjs');

const message = new TextFilter({
  text: "shut the **** up", // set the text that is being manipulated
  disableBlackList:  false, // set to false by default.
  customBlacklist: ['foo', 'aah'], // create the custom blacklist.
})


```
### censorWith
> The `censorWith` option allow to you change the default **replacer** to what ever you like.

```js
const message = new TextFilter({
  text: "hello 'badword'",
  censorWith: "#"
})

message.censor()  // returns hello ######
```

### customBlacklist 

> The `customBlacklist` allows you to create your own custom **blacklist** words this will override the default blacklist and create a new one.
 
### disableBlacklist

> The  `disableblacklist`  disables the blacklist functionality  which means the `censor()` function won't filter the text. it will just return the text.


## censor Function
> checks if the text have any blacklist words in it. note that this package already have default blacklist  words if you want to see what it looks like **click here** 

```js
const mystr = new TextFilter({
  text: "shut the 'nastyword' up", 
})

mystr.censor() // returns shut the **** up
// or
mystr.censor("nastyword you")  // returns ****** you
```

> if you want your `text` to be censored globaly. You can use `option textoveride` see below for example

### before

```js 
const filter = new TextFilter({
  text: "shut the 'nastyword' up", 
})

console.log(filter.censor())// returns "shut the ****** up"
console.log(filter.text) // returns "shut the ******* up"
```
### after

```js
const filter = new TextFilter({
  text: "shut the 'nastyword' up",
  textoveride: true, // false by default
})
console.log(filter.censor())// returns "shut the **** up"
console.log(filter.text) // returns "shut the **** up"
``` 
> `textoverride` determines if the `censor()` function should filter the text globaly.

## hasblacklist function

> The `hasblacklist()` function checks a string and determines whether it contains a blacklist strings and return `true` or `false`

```js
const filter = new TextFilter({
  text: "shut the 'nastyword' up",
})

console.log(filter.hasblacklist())  // returns true 
```
> another way that you can use the `hasblacklist` function is passing a string as the first parameter.

```js
 console.log(filter.hasblacklist("some text"))
```
more example 

```js
filter.hasblacklist("nastyword jake",(results, match, text)=>{
  // results returns true are false
 // match returns an array with the blacklistword that was found in the text

  if(results) {
    console.log(result) // true
    console.log(match) // ["nastyword"]
    console.log(text) //  nastyword jake
  }
})
```

---
_Source: https://npm.io/package/devspeed-filterjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
