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

pottymouth-client

v0.3.2

Published

dictionary and slug matching lookups for verbal blunders

Downloads

9

Readme

pottymouth

FUCK

####Filter badwords and profanity a little smarter

  • No dependencies
  • AMD, Node and browser ready

Pottymouth will catch badwords like 'sh!!!t', 'b000000bs', 'phuck' or any variation of words of the sort. Pottymouth will catch nested badwords. Pottymouth tries to be smart to not filter names like 'Cassandra' but names like 'Fatima' unfortunately will be caught in the crossfire.

####Installation

NPM, Bower & Git

npm install pottymouth
bower install pottymouth
git clone https://github.com/listenrightmeow/pottymouth

####Usage

Pottymouth exposes 3 public endpoint-api methods for validation. Pottymouth exposes 2 public endpoint-api methods to retrieve and set custom threshold values used in validation calculation.

#####AMD

If loading pottymouth in an AMD environment, json plugin by millermedeiros is required.

Currently, almond is not supported.

#####threshold

Default : 0.5. Float/Integer

pottymouth.validate.threshold.set(integer/float)
pottymouth.validate.threshold.get()

threshold.set will throw an exception if a non-number is passed as an argument.

#####public methods

Full

This method will validate input with both dictionary and regex methods. If dictionary fails, regex is not called and the boolean is returned immediately.

pottymouth.validate.full('b00bies');

Dictionary

Want to choose your own dictionary?

grunt --dictionary=URL --filetype=URL.CONTENT.TYPE

Define the direct url to download your dictionary and make sure to define the filetype. Filetype expected is either js or txt.

pottymouth.validate.dictionary('b00bies');

Regex

pottymouth.validate.regex('b00bies');

#####dictionary

dictionary lookups can be disabled

pottymouth.badwords.ignore = true

Will do a quick object lookup for custom badwords. Dictionary is an easy way to add word violations without having to write a comprehensive regex.

If loading pottymouth in an AMD environment, define a config path entry with a location to the badwords.json file. Pottymouth requires badwords before the class is instantiated.

If loading pottymouth in a Node environment, make sure that pottymouth and badwords remain in the same directory together.

If loading pottymouth in a browser in a non-AMD environment, you will be required to define badmouth with either a url to badwords.json or your can set this class variable to the badwords object itself.

pottymouth.badwords.set('/bower_components/pottymouth/dist/badwords.json');
pottymouth.badwords.set({ bad : 'word' });

If badwords contains the word as an object key, true will be returned regardless of the threshold set.

pottymouth.validate.dictionary('assmunchies');

#####regex

Will match global and case-insensitive regex matches against the user input.

User input may potentially have multiple-nested bad words. This method will iterate over an array of pre-defined regex strings and add will add the number of consecutive characters matched to a score. If the score at anypoint exceeds the class threshold, the method will immediately stop propagation and return true.

Default class threshold is 0.5. Threshold will then be used to evaluate user input * threshold.

Pass

pottymouth.validate.threshold.set(0.5);
pottymouth.validate.regex('assmunchies');

The example above would not be filtered. 'ass' (3 characters) does not exceed the threshold of 'assmunchies' (11 characters) set at 0.5.

Fail

pottymouth.validate.threshold.set(0.5);
pottymouth.validate.regex('sh!!!!tface');

The example above would be fintered. 'sh!!!!t' (7 characters) does exceed the threshold of 'sh!!!!tface' (11 characters) set at 0.5.