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

custom-id-new

v1.2.1

Published

Stopgap for the real custom-id to fix deprication problems. A tiny, unique but customizable,๐Ÿค  human-friendly but secure, encrypted but beautiful,๐Ÿฑโ€๐Ÿ‰intuitive string ID generator for JavaScript ๐ŸŽ‰๐ŸŽ‰

Downloads

89

Readme

Custom ID

A tiny, unique but customizable,๐Ÿค  human-friendly but secure, encrypted but beautiful,๐Ÿฑโ€๐Ÿ‰intuitive string ID generator for JavaScript ๐ŸŽ‰๐ŸŽ‰

Inspiration

It is built for both human and machine. We use familiar letters (from given name & email) in our randomly generated ID. People can easily recognize those familiar letters as they use it every time, everyday, every moment. You can randomly generate IDs with uuid or nanoid, but these are not generated for human. These are for machine. But this library is for both of them.

Use Case

As it's human-friendly you can use it as an OTP(one-time password), transaction ID, activation code, SMS code, Invitation key, React component key, Database random ID etc. Your imagination is your limitation. ๐ŸŽ‰๐ŸŽ‰

Installation

You can download this package from here - custom-id npm

npm i custom-id

Yarn installation

yarn add custom-id

installation of custom-id

Usage

You can generate an ID instantly by giving an empty object as the argument. ๐Ÿ‘€๐Ÿ‘€๐Ÿ‘€

var customId = require("custom-id");

customId({}); // Voila... A random 8 character string will be generated automatically

The custom ID will be generated in this format -

โœŒโœŒ** 2 Number + 2 Letter + 2 Number + 2 Letter = 8 characters ** โœŒโœŒ

All those number and letter will be generated randomly. We use cryptography to generate ids (if available).

client-id example

Customizable

The most beautiful & unique advantage of this library is its customizability.

customId({
  name: "Md. Fazlul Karim", // Optional
  email: "[email protected]", // Optional
  randomLength: 2, // Optional
  lowerCase: true // Optional
});

API

customId.name (string || optional)

You can provide a name for randomization. We sanitize the string by removing space, full stop or any special characters. Then we randomize those characters and select required number of characters(by default 2 characters) from those characters.

If no name is provided, we just select two random alphabet.

customId({
  name: "Md. Fazlul Karim" // Optional
});

customId.email (string || optional)

You can provide an email too. We sanitize the email and convert it to a string by removing space or any special characters. Then we randomize those characters and select required number of characters(by default 2 characters) from those words.

If no email is provided, we just select two random alphabet.

customId({
  email: "[email protected]" // Optional
});

customId.randomLength (number || optional)

Okay... you need flexibility too. Our by default structure is -

โœŒโœŒ 2 Number + 2 Letter + 2 Number + 2 Letter = 8 character random IdโœŒโœŒ (For example: 89KL43ZY)

We can alter this pattern too. if we pass customId.randomLength the value of 4, the result will be -

customId({
  randomLength: 4 // Optional // By default it's 2
});

โœŒโœŒ ** 4 Number + 4 String + 4 Number + 4 String = 16 character **โœŒโœŒ (For example: 9831MKLS7621GHYX)

Power is in your hand. You can make it super strong or super easy. It's your call. Use long key combination for really important random number. And use small key combination like 4K8L for OTP or inivitaion code.

customId.lowerCase (bool || optional)

We sanitize your string by toUpperCase() method. It's for easy readibility. So every ID created is always in uppercase format. But you may want it in lowercase format. You have the freedom. ๐Ÿ˜Ž๐Ÿ˜Ž

customId({
  lowerCase: true // Optional
});

customId.uniqueId ( number || Optional )

It's all about control & security. If you want to manipulate your randomly generated string, you can give an unique ID. Our encryption based algorithm will use this number to make a totally unpredictable combination of IDs. We just multiply the given number with the randomly generated number and cherrypick required characters from that multiplied number randomly. It's completely optional. You can give a static number or node js environment variable to increase unpredictabilty while generating IDs. This is how we can use both server & client machine to generate random ID. (nightmare for hackers & sniffers๐Ÿ˜‚)

customId({
  uniqueId: 4563 // Optional // You can provide any number
});

React Use Case

react client-id

Example Custom ID

customId({
  name: "Fazlul Karim",
  email: "[email protected]"
});

Rendered ID will be like below - 19UI91RR 69KI16LU 64IA13AG 34LA94KC 58ZU48MA

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate. ๐Ÿƒโ€๐Ÿƒโ€

License

MIT