npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

badword-util

v1.0.0

Published

A highly consumable list and utilities of bad english words

Downloads

5

Readme

badword-util

  • A highly consumable list of bad (profanity) English words
  • Some ultilities functions for check badwords, find badwords, filter badwords...
  • No dependencies

Install

npm install badword-util

Usage

var bwut = require('badword-util');

Get badwords data

This data has been exposed as

  • an array
  • an object
  • a regular expression

depending on what is required for your purposes.

<<<<<<< HEAD

  • var badwordArray = bwut.array;
  • var badwordObject = bwut.object;
  • var badwordRegex = bwut.regex;

Change badwords data

Add more badwords

bwut.addBadWords([...]);

it('Bad words should be added', function() {
    bwut.addBadWords(['abc', 'def']);
    assert(bwut.object.hasOwnProperty('abc'));
    assert(bwut.object.hasOwnProperty('def'));
    assert(bwut.array.indexOf('abc') !== -1);
    assert(bwut.array.indexOf('def') !== -1);
    assert(bwut.regex.toString().indexOf('|abc|def') !== -1);
  });

Remove badwords

bwut.removeBadWords([...]);

it('Bad words should be removed', function() {
	bwut.removeBadWords(['abc', 'def']);
	assert(!bwut.object.hasOwnProperty('abc'));
	assert(!bwut.object.hasOwnProperty('def'));
	assert(bwut.array.indexOf('abc') === -1);
	assert(bwut.array.indexOf('def') === -1);
	assert(bwut.regex.toString().indexOf('|abc|def') === -1);
});

Apply new dictionary

bwut.use([...]);

it('New Dictionary should be used instead of default then revert', function() {
    var oldDictionary = bwut.array;
    bwut.use(['abc', 'def', 'ghi']);
    assert(bwut.array.indexOf('abc') !== -1);
    assert(bwut.array.indexOf('def') !== -1);
    assert(bwut.array.indexOf('ghi') !== -1);
    assert(bwut.array.indexOf('fuck') === -1);
    assert(bwut.array.indexOf('shit') === -1);
    bwut.use(oldDictionary);
    assert(bwut.array.indexOf('abc') === -1);
    assert(bwut.array.indexOf('def') === -1);
    assert(bwut.array.indexOf('ghi') === -1);
    assert(bwut.array.indexOf('fuck') !== -1);
    assert(bwut.array.indexOf('shit') !== -1);
});

Badword utilities functions

Check if a word is bad word

var check = bwut.isBadWord(wordToCheck);

it('"fuck" should be a bad word and "love" shouldn\'t', function() {
	var result = bwut.isBadWord('fuck'); //true
	assert(result);
	result = bwut.isBadWord('love'); // false
	assert(!result);
});

Find bad word(s) in text

var badWords = bwut.findBadWords(text); return an array of object with structure {content: 'bad word content', times: 'number of time this bad word had occurred'}

it('Bad words should be found', function() {
	var badWords = bwut.findBadWords('fuck you all, you are shit you know, shit');
	//badWords will be [{content: 'fuck', times: 1}, {content: 'shit', times: 2}]
	assert(badWords[0].content === 'fuck');
	assert(badWords[1].content === 'shit');
	assert(badWords[0].times === 1);
	assert(badWords[1].times === 2);
});

Filter bad word(s) in text

var godOne = bwut.filterBadWords(text, badWords, character, numberOfChar); replace bad word found in text

  • badwords here is array which restrict bad words to check
  • character here is the character will be replace for each character of bad word, if character is undefined or null or empty then '*' will be use
  • numberOfChar here is the number character of bad word will be replace by character count from the end of bad word (eg: found bad word 'fuck' with numberOfChar is 2 then the result will be 'fu**'), if numberOfChar is undefined or null or bigger than bad word's length then all bad word's character will be replace.
it('Bad words should be replace', function() {
    var goodOne = bwut.filterBadWords('fuck you all, you are shit and ass as you know');
    assert(goodOne.indexOf('shit') === -1);
    assert(goodOne.indexOf('fuck') === -1);
    assert(goodOne.indexOf('ass') === -1);
    assert(goodOne.indexOf('****') !== -1);
    assert(goodOne.indexOf('***') !== -1);

    goodOne = bwut.filterBadWords('fuck you all, you are shit and ass as you know', null, '#');
    assert(goodOne.indexOf('shit') === -1);
    assert(goodOne.indexOf('fuck') === -1);
    assert(goodOne.indexOf('ass') === -1);
    assert(goodOne.indexOf('####') !== -1);
    assert(goodOne.indexOf('###') !== -1);

    goodOne = bwut.filterBadWords('fuck you all, you are shit and ass as you know', ['fuck','ass']);
    assert(goodOne.indexOf('shit') !== -1);
    assert(goodOne.indexOf('fuck') === -1);
    assert(goodOne.indexOf('ass') === -1);
    assert(goodOne.indexOf('****') !== -1);
    assert(goodOne.indexOf('***') !== -1);
    
    goodOne = bwut.filterBadWords('fuck you all, you are shit and ass as you know', ['fuck','ass'], '#');
    assert(goodOne.indexOf('shit') !== -1);
    assert(goodOne.indexOf('fuck') === -1);
    assert(goodOne.indexOf('ass') === -1);
    assert(goodOne.indexOf('####') !== -1);
    assert(goodOne.indexOf('###') !== -1);

    goodOne = bwut.filterBadWords('fuck you all, you are shit and ass as you know', ['fuck','ass'], '#', 2);  
    assert(goodOne.indexOf('shit') !== -1);
    assert(goodOne.indexOf('fuck') === -1);
    assert(goodOne.indexOf('ass') === -1);
    assert(goodOne.indexOf('fu##') !== -1);
    assert(goodOne.indexOf('a##') !== -1);
    assert(goodOne.indexOf('####') === -1);
    assert(goodOne.indexOf('###') === -1);
});

Testing

=======

Requires Mocha

Script

npm install
npm test