@oh-my-pi/pi-utils 11.0.0 → 11.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/snowflake.ts +4 -6
package/package.json
CHANGED
package/src/snowflake.ts
CHANGED
|
@@ -39,12 +39,10 @@ namespace Snowflake {
|
|
|
39
39
|
// Formats a sequence and timestamp into a snowflake hex string.
|
|
40
40
|
//
|
|
41
41
|
export function formatParts(dt: number, seq: number): Snowflake {
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
const lo = (dt << 22) | seq;
|
|
47
|
-
|
|
42
|
+
// Keep everything in Number space; dt is < 2^53 for current epochs.
|
|
43
|
+
const value = dt * 0x400000 + seq; // dt << 22
|
|
44
|
+
const hi = Math.floor(value / 0x100000000);
|
|
45
|
+
const lo = (value - hi * 0x100000000) >>> 0;
|
|
48
46
|
const hi1 = (hi >>> 16) & 0xffff;
|
|
49
47
|
const hi2 = hi & 0xffff;
|
|
50
48
|
const lo1 = (lo >>> 16) & 0xffff;
|