Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
unique-number
Advanced tools
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.
FAQs
Generate a unique number.
The npm package unique-number receives a total of 0 weekly downloads. As such, unique-number popularity was classified as not popular.
We found that unique-number demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.