You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP

uniqid

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
u

uniqid

Unique ID Generator

5.4.0
latest
100

Supply Chain Security

100

Vulnerability

100

Quality

76

Maintenance

100

License

Version published
Weekly downloads
806K
4.52%
Maintainers
1
Weekly downloads
 
Created
Issues
26

What is uniqid?

The uniqid npm package is a simple utility for generating unique IDs based on the current time, process ID, and a random number. It is useful for creating unique identifiers for objects, database entries, or any other entities that require a unique ID.

What are uniqid's main functionalities?

Basic Unique ID Generation

Generates a unique ID using the default settings. This ID is based on the current time, process ID, and a random number.

const uniqid = require('uniqid');
const id = uniqid();
console.log(id);

Unique ID with Prefix

Generates a unique ID with a specified prefix. This can be useful for categorizing or identifying the source of the ID.

const uniqid = require('uniqid');
const idWithPrefix = uniqid('prefix-');
console.log(idWithPrefix);

Unique ID with Suffix

Generates a unique ID with a specified suffix. This can be useful for adding additional context or information to the ID.

const uniqid = require('uniqid');
const idWithSuffix = uniqid('', '-suffix');
console.log(idWithSuffix);

Unique ID with Both Prefix and Suffix

Generates a unique ID with both a specified prefix and suffix. This provides maximum flexibility for customizing the ID format.

const uniqid = require('uniqid');
const idWithBoth = uniqid('prefix-', '-suffix');
console.log(idWithBoth);

Other packages similar to uniqid

FAQs

Package last updated on 18 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts