@deloz/snowflake
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

@deloz/snowflake

A TypeScript library for generating Snowflake IDs.

Snowflake is a distributed unique ID generation algorithm, commonly used to generate unique identifiers in distributed systems. This library provides a TypeScript class that makes it easy to generate Snowflake IDs.

Language Versions

Installation

Install using npm:

npm install @deloz/snowflake --save

Usage

import Snowflake from "@deloz/snowflake";

// Create an instance of Snowflake with custom datacenter ID, machine ID, and epoch
const snowflake = new Snowflake(datacenterId, machineId, "2023-01-01");

const id = snowflake.generateId();
console.log(id); // Output the generated Snowflake ID

Issues and Support

If you encounter any issues or have questions, feel free to raise them in the Issues section on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Package Sidebar

Install

npm i @deloz/snowflake

Weekly Downloads

1

Version

0.0.5

License

MIT

Unpacked Size

13.8 kB

Total Files

9

Last publish

Collaborators

  • deloz