MCPcopy
hub / github.com/tinyplex/tinybase / encodeHlc

Function encodeHlc

test/unit/common/mergeable.ts:14–34  ·  view source on GitHub ↗
(
  logicalTime42: number,
  counter24: number,
  clientHash30: number,
)

Source from the content-addressed store, hash-verified

12const toB64 = (num: number): string => String.fromCharCode(48 + (num & MASK6));
13
14const encodeHlc = (
15 logicalTime42: number,
16 counter24: number,
17 clientHash30: number,
18): string =>
19 toB64(logicalTime42 / SHIFT36) +
20 toB64(logicalTime42 / SHIFT30) +
21 toB64(logicalTime42 / SHIFT24) +
22 toB64(logicalTime42 / SHIFT18) +
23 toB64(logicalTime42 / SHIFT12) +
24 toB64(logicalTime42 / SHIFT6) +
25 toB64(logicalTime42) +
26 toB64(counter24 / SHIFT18) +
27 toB64(counter24 / SHIFT12) +
28 toB64(counter24 / SHIFT6) +
29 toB64(counter24) +
30 toB64(clientHash30 / SHIFT24) +
31 toB64(clientHash30 / SHIFT18) +
32 toB64(clientHash30 / SHIFT12) +
33 toB64(clientHash30 / SHIFT6) +
34 toB64(clientHash30);
35
36const STORE_ID_HASHES: {[id: string]: number} = {s1: 139573449, s2: 89240592};
37const START_TIME = new Date('2024-01-01 00:00:00 UTC').valueOf();

Callers 2

timeFunction · 0.70
common.test.tsFile · 0.50

Calls 1

toB64Function · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…