![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
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.
A js library to generate and parse UUIDs,TimeUUIDs and generate TimeUUID based on Date for range selections
A js library to generate and parse UUID's, TimeUUID's and generate empty TimeUUID's based on TimeStamp for range selections.
var UUID = require('uuid-js');
// Generate a V4 UUID
var uuid4 = UUID.create();
console.log(uuid4.toString());
// Prints: 896b677f-fb14-11e0-b14d-d11ca798dbac
// Generate a V1 TimeUUID
var uuid1 = UUID.create(1);
console.log(uuid1.toString());
// First and last possible v1 TimeUUID for a given timestamp:
var date = new Date().getTime();
var uuidFirst = UUID.fromTime(date, false);
var uuidLast = UUID.fromTime(date, true);
console.log(uuidFirst.toString(), uuidLast.toString());
// Prints: aa0f9af0-0e1f-11e1-0000-000000000000 aa0f9af0-0e1f-11e1-c0ff-ffffffffffff
// Use these TimeUUID's to perform range queries in cassandra:
var today = new Date().getTime();
var last30days = (new Date().setDate( today.getDate() - 30 )).getTime();
var rangeStart = UUID.firstFromTime(last30days);
var rangeEnd = UUID.lastFromTime(today);
var query = ...("select first 50 reversed ?..? from user_twits where key=?", [ rangeStart, rangeEnd, "patricknegri" ]);
$ npm install uuid-js
These are available just with require and return an instance of the UUID object:
UUID.create(4); // Generate V4 UUID
UUID.create(1); // Generate V1 TimeUUID
UUID.fromTime(time, last); // Generate a V1 empty TimeUUID from a Date object (Ex: new Date().getTime() )
UUID.firstFromTime(time); // Same as fromTime but first sequence
UUID.lastFromTime(time); // Same as fromTime but last sequence
UUID.fromURN(strId); // Generate a UUID object from string
UUID.fromBytes(ints); // Generate a UUID object from bytes
UUID.fromBinary(binary); // Generate a UUID object from binary
These must be called on an instance of the UUID object:
uuid.fromParts(timeLow, timeMid, timeHiAndVersion, clockSeqHiAndReserved, clockSeqLow, node);
uuid.toString(); // hex string version of UUID
uuid.toURN(); // same as hex, but with urn:uuid prefix
uuid.toBytes(); // converted to an array of bytes
make test
This work was based RFC and by the work of these people.
FAQs
A js library to generate and parse UUIDs,TimeUUIDs and generate TimeUUID based on Date for range selections
The npm package uuid-js receives a total of 55,575 weekly downloads. As such, uuid-js popularity was classified as popular.
We found that uuid-js 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.