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

1.0.0 • Public • Published

ts-snowflake

ts-snowflake is generate time based 64bit unique id.

Implementation of Snowflake concept.

Installation

npm i @n-oouchi/ts-snowflake

Usage

import IdConfig from "@n-oouchi/ts-snowflake/dist/Domain/IdConfig/IdConfig";
import {TsSnowFlake} from "@n-oouchi/ts-snowflake";

const idConfig = new IdConfig(1, 0) //workerId,timeOffset
const snowFlake = new TsSnowFlake(idConfig)
const id = snowFlake.generate()

IdConfig

workerId

To any number :ex. machine id, process id, region id...

Unique to the different workerId.

offset

Time offset to be subtracted from the current time.

Set the unix timestamp.

TsSnowFlake

generate

Generate id from Snowflake instance.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.00latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.00
0.1.00

Package Sidebar

Install

npm i @n-oouchi/ts-snowflake

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

20 kB

Total Files

19

Last publish

Collaborators

  • n-oouchi