Global

Members

CastAs

Types.
Deprecated:
  • Yes
Source:

Methods

explode(id, options) → {array}

Explode an ID into parts and valid flag,
Parameters:
Name Type Description
id any An ID to explode and validate.
options object Options, optional.
Properties
Name Type Description
offset number The timestamp offset to use as zero time.
Deprecated:
  • Use explodeId function instead.
Source:
Returns:
Tuple of unix timestamp, node ID, sequence ID, and valid. If invalid the numbers will be undefined.
Type
array

explodeId(id, options) → {array}

Explode an ID into parts and valid flag,
Parameters:
Name Type Description
id bigint | number | string An ID to explode and validate.
options object Options, optional.
Properties
Name Type Description
offset number The timestamp offset to use as zero time.
Source:
Returns:
Tuple of unix timestamp, node ID, sequence ID, and valid. If invalid the numbers will be undefined.
Type
array

(generator) idSequence(options) → {bigint}

ID Sequence generator.
Parameters:
Name Type Description
options object Options, optional.
Properties
Name Type Description
node number The numeric ID of the node (0-1023).
offset number The timestamp offset to use as zero time.
as 'string' | 'bigint' Deprecated: Cast generated ID. Defaults to bigint.
getTimestamp function A function that returns the current MS timestamp.
singleNode boolean Turn into a single node instance automatically populating node as sequence wraps.
Source:
Yields:
The resulting ID.
Type
bigint

(generator) idStringSequence(options) → {string}

ID Sequence generator yielding strings instead of bigints.
Parameters:
Name Type Description
options object Options, optional.
Properties
Name Type Description
node number The numeric ID of the node (0-1023).
offset number The timestamp offset to use as zero time.
getTimestamp function A function that returns the current MS timestamp.
singleNode boolean Turn into a single node instance automatically populating node as sequence wraps.
Source:
Yields:
The resulting ID as a string.
Type
string