MCPcopy Create free account
hub / github.com/denoland/std / calcHeaderSize

Function calcHeaderSize

cbor/_common_encode.ts:15–21  ·  view source on GitHub ↗
(x: number | bigint)

Source from the content-addressed store, hash-verified

13}
14
15function calcHeaderSize(x: number | bigint): number {
16 if (x < 24) return 1;
17 if (x < 2 ** 8) return 2;
18 if (x < 2 ** 16) return 3;
19 if (x < 2 ** 32) return 5;
20 return 9;
21}
22
23export function calcEncodingSize(x: CborType): number {
24 if (x == undefined || typeof x === "boolean") return 1;

Callers 2

calcEncodingSizeFunction · 0.85
encodeStringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected