Socket
Book a DemoInstallSign in
Socket

snowyflake

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snowyflake

A modern implementation Snowflake on TypeScript

latest
Source
npmnpm
Version
2.0.1
Version published
Maintainers
1
Created
Source

NPM version Build Status NPM downloads

Snowyflake - A modern implementation Snowflake on TypeScript

📖 Documentation

Installation

Node.js 16.0.0 or newer is required

TypeScript config required "target": "ES2019" or higher

Yarn

Recommended

yarn add snowyflake

NPM

npm i snowyflake

Example usage

import { Snowyflake, Epoch } from 'snowyflake';

const snowyflake = new Snowyflake({
    workerId: 1n,
    epoch: Epoch.Twitter // BigInt timestamp
});

const snowflake = snowyflake.nextId();

console.log(snowflake); // => 1075766315999952896n

const deconstructSnowflake = snowyflake.deconstruct(snowflake);

console.log(deconstructSnowflake); // =>
// { timestamp: 1545317651163n,
//     workerId: 1n,
//     processId: 0n,
//     sequence: 0n }

Keywords

snowflake

FAQs

Package last updated on 15 Feb 2025

Did you know?

Socket

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.

Install

Related posts