Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gmemstr/no-swears
Clean up your JavaScript strings and remove those filthy words.
https://github.com/gmemstr/no-swears
filter profanity swearing
Last synced: 25 days ago
JSON representation
Clean up your JavaScript strings and remove those filthy words.
- Host: GitHub
- URL: https://github.com/gmemstr/no-swears
- Owner: gmemstr
- License: mit
- Created: 2018-01-02T03:35:31.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-01-22T15:25:32.000Z (almost 4 years ago)
- Last Synced: 2024-10-03T16:06:06.849Z (3 months ago)
- Topics: filter, profanity, swearing
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 8
- Watchers: 4
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# no-swears
Automagically filter out swear words in strings
[![npm version](https://badge.fury.io/js/no-swears.svg)](https://badge.fury.io/js/no-swears)
Very simple package for censoring swear words from JavaScript strings,
replacing offending words with "\*\*\*\*".## Usage
```bash
npm install --save no-swears
``````javascript
"use strict";const noswears = require("no-swears");
```### filterSwearWords(string, callback)
This is the most basic filtering function, and requires the offending
string and a callback, returning the cleaned up string to the program.```javascript
let badString = "this is a bitching string";noswears.filterSwearWords(badString, (goodString) => {
console.log(goodString); // "this is a ****ing string"
});
```### hasSwears(string, callback)
This just returns true or false to callback depending on whether the passed string
contains a swear word```javascript
let badString = "this is a bitching string";noswears.hasSwears(badString, (swearBool) => {
console.log(swearBool); // true
});
```### hasSwearsSync(string)
This just returns true or false synchronously to be used in true/false conditions
```javascript
let badString = "this is a bitching string";if (noswears.hasSwearsSync(badString)) {
console.log("Has swears!"); // "Has swears"!
}
```