Socket
Book a DemoInstallSign in
Socket

fast-snowflake-id

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-snowflake-id

Fast snowflake id generator for Node.js

2.0.1
latest
Source
npmnpm
Version published
Weekly downloads
34
61.9%
Maintainers
1
Weekly downloads
 
Created
Source
banner

Fast snowflake id generator for Node.js

I guess...?

npm version npm type definition license


Installation

Using npm:

$ npm install fast-snowflake-id

Using yarn:

$ yarn add fast-snowflake-id

Features

  • Get snowflake id as bigint
  • Get snowflake id as buffer

Without any dependencies!

Usage/Examples

setup:

// CommonJS
const SnowflakeId = require('fast-snowflake-id').default;

// ES Module
import SnowflakeId from 'fast-snowflake-id';

initialization:

// All properties are optional
const snowflakeId = new SnowflakeId({
	epoch: 1288834974657 /* Twitter's snowflake id epoch */,
	instanceId: SnowflakeId.getInstanceId(31, 31) /* Getting instanceId from datacenterId and workerId */,
	overflowHandler: function () {
		console.error('overflow!!!!');

		return;
	}
});

printing snowflake id as bigint:

console.log(snowflakeId.getId());

printing snowflake id as buffer:

console.log(snowflakeId.getBufferId());

Contribution

Contribution, issues and feature requests are welcome!
Feel free to check issues page.

Keywords

unique

FAQs

Package last updated on 25 Jun 2023

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.