Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flake-idgen

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flake-idgen - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

7

flake-id-gen.js

@@ -67,2 +67,9 @@ /**

// Generates id in the same millisecond as the previous id
if (time < this.lastTime) {
if (cb) {
setTimeout(self.next.bind(self, cb), this.lastTime - time);
return;
}
throw new Error(`Clock moved backwards. Refusing to generate id for ${this.lastTime - time} milliseconds`);
}
if (time === this.lastTime) {

@@ -69,0 +76,0 @@

2

package.json
{
"name": "flake-idgen",
"version": "1.3.0",
"version": "1.4.0",
"description": "Flake ID generator yields k-ordered, conflict-free ids in a distributed environment",

@@ -5,0 +5,0 @@ "main": "flake-id-gen.js",

@@ -101,2 +101,8 @@ Flake ID Generator

### Counter overflow ###
Flake ID Generator can generate up to 4096 unique identifiers within a millisecond. When generator tries to generate more than 4096 identifiers within a millisecond, the following things will happen:
* When using `next()` without a callback function, an error is thrown.
* When using `next(cb)` with a callback function, the callback function is called in the following millisecond without any error.
### Additional generator setup parameters ###
Flake Id generator constructor takes optional parameter (generator configuration options) with the following properties:

@@ -186,4 +192,9 @@ * `datacenter` (5 bit) - datacenter identifier. It can have values from 0 to 31.

### Formatting ###
### Clock moving backward ###
From time to time Node.js clock may move backward. In most cases it is only a few millisecond. However, as the generator relies on current timestamp, it won't be able to generate conflict-free identifiers (i.e. without duplicates) until the clock catches up with the last timestamp value. In case of clock move backward the following things will happen:
* When using `next()` without a callback function, an error is thrown.
* When using `next(cb)` with a callback function, the callback function is called with a new identifier generated once the clock catches up with the last timestamp.
## Formatting ##
Flake Id generator returns node Buffer representing 64-bit number for the sake of future extensions or returned buffer modifications. Node Buffer can also be very easily converted to string format. There is a NPM [biguint-format](https://npmjs.org/package/biguint-format) module which provides Buffer to string conversion functionality e.g.

@@ -190,0 +201,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc