MCPcopy Create free account
hub / github.com/denoland/std / #decodeFive

Method #decodeFive

cbor/sequence_decoder_stream.ts:396–462  ·  view source on GitHub ↗
(
    aI: number,
  )

Source from the content-addressed store, hash-verified

394 }
395
396 async #decodeFive(
397 aI: number,
398 ): Promise<[CborMapDecodedStream, lock: Promise<unknown>]> {
399 async function* convert(
400 gen: AsyncGenerator<CborStreamOutput>,
401 ): AsyncGenerator<CborMapStreamOutput> {
402 while (true) {
403 const key = await gen.next();
404 if (key.done) break;
405 if (typeof key.value !== "string") {
406 throw new TypeError(
407 "Cannot parse map key: Only text string map keys are supported",
408 );
409 }
410
411 const value = await gen.next();
412 if (value.done) {
413 throw new RangeError(
414 "Impossible State: readDefinite | readIndefinite should have thrown an error",
415 );
416 }
417
418 yield [key.value, value.value];
419 }
420 }
421
422 let releaseLock: ReleaseLock = () => {};
423 const lock = new Promise((x) => releaseLock = x);
424 if (aI < 24) {
425 return [
426 new CborMapDecodedStream(
427 convert(this.#readDefinite(aI * 2)),
428 releaseLock,
429 ),
430 lock,
431 ];
432 }
433 if (aI <= 27) {
434 return [
435 new CborMapDecodedStream(
436 convert(
437 this.#readDefinite(
438 arrayToNumber(
439 (await this.#read(2 ** (aI - 24), true)).buffer,
440 true,
441 ),
442 ),
443 ),
444 releaseLock,
445 ),
446 lock,
447 ];
448 }
449 if (aI === 31) {
450 return [
451 new CborMapDecodedStream(
452 convert(this.#readIndefinite(false)),
453 releaseLock,

Callers 1

#decodeMethod · 0.95

Calls 5

#readDefiniteMethod · 0.95
#readMethod · 0.95
#readIndefiniteMethod · 0.95
arrayToNumberFunction · 0.90
toStringMethod · 0.45

Tested by

no test coverage detected