2.0.1 • Published 10 months ago

fast-snowflake-id v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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.

2.0.1

10 months ago

2.0.0

10 months ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago