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

uneeqid

v1.0.10

Published

Generate random strings of given length and type + check for unique

Downloads

1

Readme

What's this?

A random string generator. (Yes, there are lots of them, but this was built as a learning exercise).

Demo

Right here

How to use it?

Just like so:

var ID = require('uneeqid');

and then in your program:

ID.generate()

Works right out of the box. Without setting any options, you'll get a 64-character alphanumeric.

Where can I use it?

Most likely when you want to create unique IDs for something like users, or links etc.

How can I make sure the ID is unique?

So you can pass a list of IDs as an array to the library. Like so:

ID.list = ['...','...','...'];
ID.generate();

Or

var arr = [...]; // this is some array that you build. Like an array of all existing userIDs in your table
ID.list = arr;
ID.generate();

ID will automatically check if the generated ID is already in the list of IDs you fed into ID.list. If yes, it will re-generate another ID till it creates an ID that's unique.

Options

When you use ID.generate() just like that, you get a 64-character long alphanumeric (with upper- and lower-case letters).

You can configure the length and the type of a string you want.

Type:

ID.type = 'loweralpha';

| Type | Explanation | Example (length = 16) | | ---- | ----------- | --------------------- | | alphanumeric | lower and upper case alphabets + numbers (0-9) | GejPA8BmYh55GuYU | | loweralphanumeric | lowercase alphabets + numbers | djnzzm1eh7p1n82e | | alpha | lower and upper case alphabets only | KmIQCOvZzLVHiIZw | | numeric | numbers only | 8759684248582452 | | loweralpha | lower case alphabets only | civjbazwxbwbaqgw | | alphasymbol | alphabets and symbols | tlqQ_zXWa=l+ACFB | | loweralphasymbol | lower case alphabets and symbols | @dw%uq$ms~i!$x)m | | alphanumericsymbol | alphabets numbers and symbols | R^O=1Rz~A!qFB~58 | | loweralphanumericsymbol | lower case alphabets, numbers and symbols | ?ucprlw)yut8$_wj |

Length:

Default is 64. You can give a number between 4 and 512 (both included). Anything off this will result in fallback to the default (64).

ID.length = 128;

Mo' things to do with this:

ID.lastID

Gives you the last generated ID. Is changed whenever you use ID.generate();

ID.flush()

Flushes out ID.list

ID.reset()

Resets everything (type, length, list, lastID).

Licence

No warranties whatsoever. Other than that, do whatever you want; no credits required.