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

@2toad/profanity

v2.2.0

Published

A JavaScript profanity filter

Downloads

23,904

Readme

Profanity

GitHub version Downloads Build status

A JavaScript profanity filter (with TypeScript support)

Getting Started

Install package

npm i @2toad/profanity

if you're using Node 11.x or older you'll need to install Profanity 1.x (e.g., npm i @2toad/[email protected])

Usage

import { profanity } from '@2toad/profanity';
// or
var profanity = require('@2toad/profanity').profanity;


profanity.exists('I like big butts and I cannot lie');
// true

profanity.exists('I like big glutes and I cannot lie');
// false

profanity.censor('I like big butts (aka arses) and I cannot lie');
// I like big @#$%&! (aka @#$%&!) and I cannot lie

profanity.censor('I like big butts (aka arses) and I cannot lie', CensorType.FirstChar);
// I like big *utts (aka *rses) and I cannot lie

Options

Create an instance of the Profanity class to change the default options:

import { Profanity, ProfanityOptions } from '@2toad/profanity';

const options = new ProfanityOptions();
options.wholeWord = false;
options.grawlix = '*****';
options.grawlixChar = '$';

const profanity = new Profanity(options);

wholeWord

By default this is set to true, so profanity only matches on whole words:

profanity.exists('Arsenic is poisonous but not profane');
// false

Setting this to false, results in partial word matches:

profanity.exists('Arsenic is poisonous but not profane');
// true (matched on arse)

grawlix

By default this is set to @#$%&!:

profanity.censor('I like big butts and I cannot lie');
// I like big @#$%&! and I cannot lie

Setting this to ****, results in:

profanity.censor('I like big butts and I cannot lie');
// I like big **** and I cannot lie

grawlixChar

When specifying a CensorType other than CensorType.Word, this is the character used by the censor function.

By default this is set to *:

profanity.censor('I like big butts and I cannot lie', CensorType.AllVowels);
// I like big b*tts and I cannot lie

Setting this to $, results in:

profanity.censor('I like big butts and I cannot lie', CensorType.AllVowels);
// I like big b$tts and I cannot lie

Customize the word list

Add words:

profanity.addWords(['aardvark', 'zebra']);

Remove words:

profanity.removeWords(['butt', 'arse']);

Whitelist

The whitelist allows you to specify words that are always ignored by the profanity filter.

This can be useful if you want to turn partial word matching on (wholeWord = true), so combined words are caught (e.g., arselicker), while specific words you add to the whitelist are ignored (e.g., arsenic).

Add words to the whitelist:

profanity.whitelist.addWords(['arsenic', 'buttress']);

Remove words from the whitelist:

profanity.whitelist.removeWords(['arsenic', 'buttress']);

Contributing

So you want to contribute to the Profanikty project? Fantastic! Please read the Contribute doc to get started.