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

@stalepretzels/bartender

v0.1.2

Published

bindings to rustrict

Downloads

3

Readme

Bartender

.github/workflows/release.yml npmpkg

Node.js bindings for the rustrict crate.

NOTE: rustrict was made by @finnbear, and not me! I am simply making bindings to it! Please check out his original project.

How capable is this library?

Since it's based off of rustrict, it has every capability of the rust crate! Here's what the original can do:

  • Multiple types (profane, offensive, sexual, mean, spam)
  • Multiple levels (mild, moderate, severe)
  • Resistant to evasion
    • Alternative spellings (like "fck")
    • Repeated characters (like "craaaap")
    • Confusable characters (like 'ᑭ', '𝕡', and '🅿')
    • Spacing (like "c r_a-p")
    • Accents (like "pÓöp")
    • Bidirectional Unicode (related reading)
    • Self-censoring (like "f*ck")
    • Safe phrase list for known bad actors]
    • Censors invalid Unicode characters
    • Battle-tested in Mk48.io
  • Resistant to false positives
    • One word (like "assassin")
    • Two words (like "push it")
  • Flexible
    • Censor and/or analyze
    • Input &str or Iterator<Item = char>
    • Can track per-user state with context feature
    • Can add words with the customize feature
    • Accurately reports the width of Unicode via the width feature
    • Plenty of options
  • Performant
    • O(n) analysis and censoring
    • No regex (uses custom trie)
    • 3 MB/s in release mode
    • 100 KB/s in debug mode

Limitations

This is handicapped by everything the original was:

  • Mostly English/emoji
  • Censoring removes most diacritics (accents)
  • Does not detect right-to-left profanity while analyzing, so...
  • Censoring forces Unicode to be left-to-right
  • Doesn't understand context
  • Not resistant to false positives affecting profanities added at runtime

How do I use this?

Simple! Just alias (or import) Bartender at the beginning of the your .js file to begin!

let bartender = require('@stalepretzels/bartender');   // commonjs require
import * as bartender from '@stalepretzels/bartender'; // esm import
// Simply remove `bartender.` from the beginning of the code if you plan on importing functions by themselves. 

Censor and check for profanity:

// censor(input: String) -> String
// is_inappropriate(input: String) -> bool

bartender.censor("hello crap") // -> "hello c***"

bartender.is_inappropriate("f u c k") // -> true

Type match strings:

// is(input: String, filter_input: String) -> bool
// isnt(input: String, filter_input: String) -> bool

bartender.is("pron", "evasive"); // -> true
bartender.isnt("porn", "evasive"); // -> true

bartender.is("Hello there!", "safe"); // -> true
bartender.is("nice work.", "safe"); // -> true
bartender.is("yes", "safe"); // -> true
bartender.is("NVM", "safe"); // -> true
bartender.is("gtg", "safe"); // -> true
bartender.isnt("not a common phrase", "safe"); // -> true

Roadmap

  1. Add custom words and censors
  2. Implement context feature
  3. Array iterators