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

decent-username

v2.1.2

Published

decent-username package is a library to check if a username doesn't contain offensive or bad words.

Downloads

11

Readme

decent-username

decent-username is a library to check if a username doesn't contain offensive or bad words.

Unlike leo-profanity package, decent-usernametransform all homoglyph in a real letter, replace special characters and supress char repetition

Installation

You can install decent-username from npm

npm install decent-username

Example

The decent-username package contains a DecentUsernameclass to check your username, here an example More details in src/example.ts file

// Import JS module with :
import { DecentUsername, DecentUsernameProblem } from 'decent-username';

const username = 'iamnâZiiit';
// Even if it looks like, the "i" is a special char not equals to "i"

console.log(`Let's validate '${username}' !`);

// Test if your username is decent !
const decentUsername = new DecentUsername(username);
// Validate it in a second time, if you want to change somes settings before validation
decentUsername.validate();

// Check if your username is decent
if (decentUsername.isValid()) {
    console.log('This username is decent, you can use it !');
} else {
    console.log('This username is not decent !');
}

Customize

You can add your own word librairy very quickly, in the future, another languages than english will be available

Add your own dictionary

If you look at src/index.ts comments, you can see this :

// List of special chars to remove, can be changed if needed
public specialsChars: string[];
// List of reserved words to detect, can be changed if needed
public reservedWords: string[];
// Letters to change by another, can be changed if needed
public lettersMap: any;
// List of banned words to detect, can be changed if needed
public badWords: string[];

So to change some dictionary for a custom usage you can do it with :

const decentUsername = new DecentUsername(username);
decentUsername.specialsChars = ['$', '*', '`', ' ', '#']; // etc...
decentUsername.reservedWords = ['settings', 'home']; // etc...
decentUsername.lettersMap = {
    a: 'ÀÁÂÃÄÅâãα@',
    b: 'ΒВЬBb8',
    c: 'Cc',
    d: 'ĎďĐđԁժⅾDd',
}; // etc...
// Example for french
decentUsername.badWords = ['idiot', 'tueur', 'crétin', 'abruti']; // etc...
decentUsername.validate();

Commands

There is few command to use to "play" and use decent-username

  • npm start : Basic start, just run the example
  • npm run build : For contributing, build the Typescript package
  • npm run dev: For contributing, it just run tsc -w that compile Typescript when a file change
  • npm run postinstall: For package deployment only

Reported bug

False positive

Unfortunately, there sometimes some false-positive (around 9.5%), this algorithm can be tricked

Contributing

For contributing, nothing easier !

git clone # Url of your fork
cd decent-username
npm run dev # Watch files changes
npm start # To run example file that you can modify

And after you changes are done, you'll be able to do a pull request to the main repository