MCPcopy
hub / github.com/codeaashu/claude-code / base58Encode

Function base58Encode

src/utils/taggedId.ts:19–31  ·  view source on GitHub ↗

* Encode a 128-bit unsigned integer as a fixed-length base58 string.

(n: bigint)

Source from the content-addressed store, hash-verified

17 * Encode a 128-bit unsigned integer as a fixed-length base58 string.
18 */
19function base58Encode(n: bigint): string {
20 const base = BigInt(BASE_58_CHARS.length)
21 const result = new Array<string>(ENCODED_LENGTH).fill(BASE_58_CHARS[0]!)
22 let i = ENCODED_LENGTH - 1
23 let value = n
24 while (value > 0n) {
25 const rem = Number(value % base)
26 result[i] = BASE_58_CHARS[rem]!
27 value = value / base
28 i--
29 }
30 return result.join('')
31}
32
33/**
34 * Parse a UUID string (with or without hyphens) into a 128-bit bigint.

Callers 1

toTaggedIdFunction · 0.85

Calls 1

fillMethod · 0.80

Tested by

no test coverage detected