New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

scru128

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scru128 - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

4

dist/index.d.ts

@@ -9,6 +9,6 @@ /**

/**
* Generates a new SCRU128 ID.
* Generates a new SCRU128 ID encoded in a string.
*
* @returns Canonical representation consisting of 26 characters.
* @returns 26-digit canonical string representation.
*/
export declare const scru128: () => string;

@@ -110,3 +110,3 @@ "use strict";

}
/** Returns the canonical textual representation. */
/** Returns the 26-digit canonical string representation. */
toString() {

@@ -120,7 +120,7 @@ const h48 = this.timestamp * 0x10 + (this.counter >> 24);

}
/** Parses textual representation to create an object. */
static fromString(s) {
const m = s.match(/^([0-7][0-9A-V]{9})([0-9A-V]{8})([0-9A-V]{8})$/i);
/** Creates an object from a 26-digit string representation. */
static fromString(value) {
const m = value.match(/^([0-7][0-9A-V]{9})([0-9A-V]{8})([0-9A-V]{8})$/i);
if (m === null) {
throw new SyntaxError("invalid string representation: " + s);
throw new SyntaxError("invalid string representation: " + value);
}

@@ -135,5 +135,5 @@ const h48 = parseInt(m[1], 32);

/**
* Generates a new SCRU128 ID.
* Generates a new SCRU128 ID encoded in a string.
*
* @returns Canonical representation consisting of 26 characters.
* @returns 26-digit canonical string representation.
*/

@@ -140,0 +140,0 @@ const scru128 = () => defaultGenerator.generate().toString();

{
"name": "scru128",
"version": "0.2.0",
"version": "0.2.1",
"description": "SCRU128: Sortable, Clock and Random number-based Unique identifier",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -57,3 +57,3 @@ # SCRU128: Sortable, Clock and Random number-based Unique identifier

same `timestamp`; however, this mechanism does not ensure the uniqueness of IDs
generated by multiple generators that do not share a `counter` state. SCRU128
generated by multiple generators that do not share a `counter` state. SCRU128
relies on random numbers to avoid such collisions.

@@ -76,11 +76,10 @@

A SCRU128 ID is encoded to a string as a 128-bit unsigned integer denoted in the
A SCRU128 ID is encoded in a string as a 128-bit unsigned integer denoted in the
radix of 32 using the digits of `[0-9A-V]`, with leading zeros added to form a
26-digit canonical representation. Converters for this simple base 32 notation
are widely available in many languages; even if not, it is easily implemented
with bitwise operations by translating each 5-bit group, from the least
significant group to the most, into one digit of `[0-9A-V]`, from the least
significant digit to the most. Since the three most significant bits are mapped
to one of `[0-7]`, any numeral greater than `7VVVVVVVVVVVVVVVVVVVVVVVVV` is not
a valid SCRU128 ID.
with bitwise operations by translating each 5-bit group into one digit of
`[0-9A-V]`, from the least significant digit to the most. Since the three most
significant bits are mapped to one of `[0-7]`, any numeral greater than
`7VVVVVVVVVVVVVVVVVVVVVVVVV` is not a valid SCRU128 ID.

@@ -87,0 +86,0 @@ Note that this is different from the encodings commonly referred to as _base32_

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