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

Function calcBytes

cbor/_common_encode.ts:6–13  ·  view source on GitHub ↗
(x: bigint)

Source from the content-addressed store, hash-verified

4import type { CborType } from "./types.ts";
5
6function calcBytes(x: bigint): number {
7 let bytes = 0;
8 while (x > 0n) {
9 ++bytes;
10 x >>= 8n;
11 }
12 return bytes;
13}
14
15function calcHeaderSize(x: number | bigint): number {
16 if (x < 24) return 1;

Callers 2

calcEncodingSizeFunction · 0.85
encodeBigIntFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected