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

@litert/uuid

v1.0.0

Published

A uuid generator library for LiteRT framework.

Downloads

7

Readme

LiteRT/UUID

npm version License node GitHub issues GitHub Releases

A uuid generator library for LiteRT framework.

Requirement

  • TypeScript v2.7.1 (or newer)
  • Node.js v7.0.0 (or newer)

Installation

Install by NPM:

npm i @litert/uuid --save

Algorithms

Following algorithms are supported:

Snowflake

A 64-bit integer UUID algorithm provided by Twitter.

Snowflake-SI

The Snowflake-SI algorithm generates safe integer (52-bits integer) for JavaScript, with capacity 128 uuids per milliseconds, and 64 machine parallel working.

Snowflake-SI-vA

A variant of Snowflake-SI algorithm.

Samples

Snowflake-SI Usage

import * as libuuid from "@litert/uuid";

const makeUUID = libuuid.SnowflakeSI.createGenerateor({

    /**
     * The machine ID.
     *
     * By default the uinWidth is 8, and the rest 5 bits is left to MID, so
     * that the mid must be between 0 and 31.
     */
    "mid": 1,

    /**
     * The base-clock of generator. Is unchangeable once setup.
     *
     * And it cannot be earlier than 2003-03-18T07:20:20Z
     */
    "baseClock": new Date(2004, 0, 1, 0, 0, 0, 0).getTime(),

});

console.log(makeUUID()); // Generate a UUIN
console.log(makeUUID()); // Generate a UUIN
console.log(makeUUID.MS_CAPACITY); // See the capacity of UUIDs in 1ms
console.log(makeUUID.MACHINE_ID); // See the machine ID.
console.log(new Date(makeUUID.BASE_CLOCK)); // See the base-clock

Snowflake-SI Adjustment

import * as libuuid from "@litert/uuid";

const makeUUID = libuuid.SnowflakeSI.createGenerateor({

    /**
     * The machine ID.
     *
     * Now the uinWidth has been set to 12, and only 1 bit is left to MID, so
     * that the mid can be either 1 or 0.
     */
    "mid": 1,

    /**
     * The base-clock of generator. Is unchangeable once setup.
     *
     * And it cannot be earlier than 2003-03-18T07:20:20Z
     */
    "baseClock": new Date(2004, 0, 1, 0, 0, 0, 0).getTime(),

    /**
     * The bit-width of UIN.
     */
    "uinWidth": 12
});

console.log(makeUUID()); // Generate a UUIN
console.log(makeUUID()); // Generate a UUIN
console.log(makeUUID.MS_CAPACITY); // See the capacity of UUIDs in 1ms
console.log(makeUUID.MACHINE_ID); // See the machine ID.
console.log(new Date(makeUUID.BASE_CLOCK)); // See the base-clock

Snowflake-SI-vA Usage

import * as libuuid from "@litert/uuid";

const makeUUID = libuuid.SnowflakeSIvA.createGenerateor({

    /**
     * The ID of machine, 0 ~ 1023
     */
    "mid": 333,

    /**
     * Calculate the cursor of the incremental sequence insides generator by
     * the last generated UUID.
     */
    "cursor": libuuid.SnowflakeSIvA.calculateCursor(1562244321456127)
});

console.log(nextUUID());
console.log(nextUUID());
console.log(nextUUID.MACHINE_ID);
console.log(Number.isSafeInteger(nextUUID()));

License

This library is published under Apache-2.0 license.