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

Method #read

cbor/sequence_decoder_stream.ts:145–159  ·  view source on GitHub ↗
(
    bytes: number,
    expectMore: boolean,
  )

Source from the content-addressed store, hash-verified

143 expectMore: false,
144 ): Promise<Uint8Array | undefined>;
145 async #read(
146 bytes: number,
147 expectMore: boolean,
148 ): Promise<Uint8Array | undefined> {
149 if (bytes === 0) return new Uint8Array(0);
150 const { done, value } = await this.#source.read(new Uint8Array(bytes), {
151 min: bytes,
152 });
153 if (done) {
154 if (expectMore) throw new RangeError("More bytes were expected");
155 else return undefined;
156 }
157 if (value.length < bytes) throw new RangeError("More bytes were expected");
158 return value;
159 }
160
161 async *#readGen(bytes: bigint): AsyncGenerator<Uint8Array> {
162 for (let i = 0n; i < bytes; i += 2n ** 16n) {

Callers 11

#readGenMethod · 0.95
#readDefiniteMethod · 0.95
#readIndefiniteMethod · 0.95
#decodeSequenceMethod · 0.95
#decodeZeroMethod · 0.95
#decodeTwoMethod · 0.95
#decodeThreeMethod · 0.95
#decodeFourMethod · 0.95
#decodeFiveMethod · 0.95
#decodeSixMethod · 0.95
#decodeSevenMethod · 0.95

Calls 1

readMethod · 0.65

Tested by

no test coverage detected