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

Function decodeOne

cbor/_common_decode.ts:63–76  ·  view source on GitHub ↗
(
  input: Uint8Array,
  aI: number,
  offset: number,
)

Source from the content-addressed store, hash-verified

61}
62
63function decodeOne(
64 input: Uint8Array,
65 aI: number,
66 offset: number,
67): [number | bigint, number] {
68 if (aI > 27) {
69 throw new RangeError(
70 `Cannot decode value (0b001_${aI.toString(2).padStart(5, "0")})`,
71 );
72 }
73 const output = calcLength(input, aI, offset);
74 output[0] = typeof output[0] === "bigint" ? -output[0] - 1n : -output[0] - 1;
75 return output;
76}
77
78function decodeTwo(
79 input: Uint8Array,

Callers 1

decodeFunction · 0.85

Calls 2

calcLengthFunction · 0.85
toStringMethod · 0.45

Tested by

no test coverage detected