MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / getInteger

Method getInteger

modules/crypt/etc/ber.js:83–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

81 return this.#a.subarray(i, this.#i)
82 }
83 getInteger() {
84 if (this.getTag() !== 2)
85 throw new Error("BER: not an integer");
86 const length = this.getLength();
87 const offset = this.#a.byteOffset + this.#i;
88 if (this.peek() & 0x80) {
89 const c = this.getChunk(length).slice(); // copy. cannot modify source data.
90 for (let i = 0; i < length; i++) // could use Logical.not
91 c[i] = ~c[i];
92 return -(BigInt.fromArrayBuffer(c.buffer) + 1n);
93 }
94 else {
95 this.skip(length)
96 return BigInt.fromArrayBuffer(this.#a.buffer.slice(offset, offset + length));
97 }
98 }
99 getBitString() {
100 let result;
101 if (this.getTag() != 3)

Callers 8

parseMethod · 0.95
decryptMethod · 0.95
verifyMethod · 0.95
verifyMethod · 0.95
parseMethod · 0.95
_verifyMethod · 0.95
getDHMethod · 0.95
decodeSPKIFunction · 0.80

Calls 7

getTagMethod · 0.95
getLengthMethod · 0.95
peekMethod · 0.95
getChunkMethod · 0.95
skipMethod · 0.95
sliceMethod · 0.65
fromArrayBufferMethod · 0.65

Tested by

no test coverage detected