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

Method pull

http/unstable_formdata_encoder_stream.ts:104–132  ·  view source on GitHub ↗
(controller)

Source from the content-addressed store, hash-verified

102 await gen.next();
103 },
104 async pull(controller) {
105 const length = controller.byobRequest!.view!.byteLength;
106 const buffer = new Uint8Array(
107 controller.byobRequest!.view!.buffer,
108 controller.byobRequest!.view!.byteOffset,
109 length,
110 );
111
112 try {
113 const { done, value } = await gen.next(buffer);
114 if (done) {
115 controller.close();
116 return controller.byobRequest!.respond(0);
117 }
118
119 // deno-lint-ignore no-explicit-any
120 if ((buffer.buffer as any).detached) {
121 controller.byobRequest!.respondWithNewView(value);
122 } else if (buffer.buffer === value.buffer) {
123 controller.byobRequest!.respond(value.length);
124 } else {
125 buffer.set(value.subarray(0, length));
126 controller.byobRequest!.respond(length);
127 controller.enqueue(value.subarray(length));
128 }
129 } catch (error) {
130 controller.error(error);
131 }
132 },
133 async cancel(reason) {
134 await gen.throw(reason).catch(() => undefined);
135 },

Callers

nothing calls this directly

Calls 3

closeMethod · 0.65
setMethod · 0.65
nextMethod · 0.45

Tested by

no test coverage detected