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

Method #decodeSix

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

Source from the content-addressed store, hash-verified

462 }
463
464 async #decodeSix(
465 aI: number,
466 ): Promise<
467 Date | CborTag<CborStreamOutput> | [
468 CborTag<CborStreamOutput>,
469 lock: Promise<unknown>,
470 ]
471 > {
472 const tagNumber = await this.#decodeZero(aI);
473 const tagContent = await this.#decode(
474 arrayToNumber((await this.#read(1, true)).buffer, true) as number,
475 );
476 switch (tagNumber) {
477 case 0:
478 if (typeof tagContent !== "string") {
479 throw new TypeError(
480 "Invalid DataItem: Expected text string to follow tag number 0",
481 );
482 }
483 return new Date(tagContent);
484 case 1:
485 if (typeof tagContent !== "number" && typeof tagContent !== "bigint") {
486 throw new TypeError(
487 "Invalid DataItem: Expected integer or float to follow tagNumber 1",
488 );
489 }
490 return new Date(Number(tagContent) * 1000);
491 }
492 if (tagContent instanceof Array) {
493 return [new CborTag(tagNumber, tagContent[0]), tagContent[1]];
494 }
495 return new CborTag(tagNumber, tagContent);
496 }
497
498 async #decodeSeven(aI: number): Promise<undefined | null | boolean | number> {
499 switch (aI) {

Callers 1

#decodeMethod · 0.95

Calls 4

#decodeZeroMethod · 0.95
#decodeMethod · 0.95
#readMethod · 0.95
arrayToNumberFunction · 0.90

Tested by

no test coverage detected