Skip to content

deloz/snowflake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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.