[TIMESTAMP_BITS_INVALID_RANGE]
If bits is less than
38
[EPOCH_INVALID_TYPE]
If epoch is not a number
[EPOCH_INVALID_RANGE]
If epoch is not within 0 and
Date.now()
The number of bits for the fragment.
A custom epoch timestamp.
Defaults to 1420070400000
(2015-01-01
00:00:00) if omitted.
The bit mask used to isolate the fragment's bits from the snowflake.
bitMask is equal to maxValue << bitShift
The hexadecimal representation of the bit mask as string.
The number of bits for left and right shifting.
bitShift is equal to the number of bits on the right side
Readonly
bits
Private
Readonly
epoch
Epoch timestamp used to calculate the fragment's timestamps.
The fragment identifier.
Private
lastValue of the last timestamp.
Readonly
maxThe maximum value that can be represented by this fragment.
maxValue is equal to 2 ** bits - 1
Private
Readonly
nanoNanosecond time reference.
Date.now() returns the number of milliseconds since the Unix epoch. hrtime.bigint() returns a high-resolution time value in nanoseconds, however it is relative to an arbitrary time in the past and not the Unix epoch.
If x
hrtime was taken at y
Unix timestamp,
then when we recapture a hrttime at x'
we can
calculate the time with the following formula:
y + (x' - x)
or (y - x) + x'
Private
sequenceReference to the SequenceFragment instance. This is used to check for sequence collisions, and to reset the sequence when necessary.
Private
Readonly
timeTime unit used to convert the nanosecond timestamp to.
1
: nanosecond10 ** 3
: microsecond10 ** 6
: millisecondThe current value of the fragment.
Private
checkPrivate
unixPrivate
waitGenerated using TypeDoc
TimestampFragment class for timestamp IDs.