MCPcopy Create free account
hub / github.com/AlexErrant/Pentive / prefixEpochToArray

Function prefixEpochToArray

shared/src/binary.ts:39–44  ·  view source on GitHub ↗
(epoch: number, id: Uint8Array)

Source from the content-addressed store, hash-verified

37
38// uses big endian
39export function prefixEpochToArray(epoch: number, id: Uint8Array) {
40 for (let i = 0; i < epochLength; i++) {
41 const divisor = Math.pow(256, epochLength - 1 - i)
42 id[i] = Math.floor(epoch / divisor) % 256
43 }
44}
45
46export function idToEpoch(id: Uint8Array): number {
47 let epoch = 0

Callers 4

getNotes.test.tsFile · 0.90
binary.test.tsFile · 0.90
idFactoryFunction · 0.85
rawIdWithTimeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected