New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

unique-number

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unique-number

Generate a unique number.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

unique-number NPM Version Bower Version Build Status

Generate a unique number.

var uniqueNumber = require("unique-number");

// Timestamp
console.log( uniqueNumber() );

// Iterated timestamps
for (var i=0; i<1000; i++) {
	console.log( uniqueNumber() );
}

// Resets timestamp+1000 back to timestamp
uniqueNumber.reset();

setTimeout( function() {
	console.log( uniqueNumber() );
}, 100);

When multiple requests are made per millisecond, the timestamp is simply iterated. After a few billion runs—typically when your operations are complete—you should run uniqueNumber.reset() to avoid passing Number.MAX_SAFE_INTEGER.

Because this library is so small and simple, it requires this one extra step. If you disapprove, you may prefer cuid, puid or shortid.

Keywords

FAQs

Package last updated on 29 May 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc