MCPcopy Index your code
hub / github.com/nodejs/node / write

Function write

lib/internal/webstreams/adapters.js:238–266  ·  view source on GitHub ↗
(chunk)

Source from the content-addressed store, hash-verified

236 start(c) { controller = c; },
237
238 write(chunk) {
239 try {
240 options[kValidateChunk]?.(chunk);
241 if (!streamWritable.writableObjectMode && isAnyArrayBuffer(chunk)) {
242 chunk = new Uint8Array(chunk);
243 }
244 if (streamWritable.writableNeedDrain || !streamWritable.write(chunk)) {
245 backpressurePromise = PromiseWithResolvers();
246 if (!streamWritable.writableNeedDrain) {
247 backpressurePromise.resolve();
248 }
249 return SafePromisePrototypeFinally(
250 backpressurePromise.promise, () => {
251 backpressurePromise = undefined;
252 });
253 }
254 } catch (error) {
255 // When the kDestroyOnSyncError flag is set (e.g. for
256 // CompressionStream), a sync throw must also destroy the
257 // stream so the readable side is errored too. Without this
258 // the readable side hangs forever. This replicates the
259 // TransformStream semantics: error both sides on any throw
260 // in the transform path.
261 if (options[kDestroyOnSyncError]) {
262 destroy(streamWritable, error);
263 }
264 throw error;
265 }
266 },
267
268 abort(reason) {
269 destroy(streamWritable, reason);

Callers

nothing calls this directly

Calls 8

normalizeEncodingFunction · 0.85
encodeMethod · 0.80
destroyFunction · 0.70
doWriteFunction · 0.70
writeMethod · 0.45
resolveMethod · 0.45
fromMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…