MCPcopy Create free account
hub / github.com/nodejs/node / destroyer

Function destroyer

lib/internal/streams/pipeline.js:51–69  ·  view source on GitHub ↗
(stream, reading, writing)

Source from the content-addressed store, hash-verified

49let addAbortListener;
50
51function destroyer(stream, reading, writing) {
52 let finished = false;
53 stream.on('close', () => {
54 finished = true;
55 });
56
57 const cleanup = eos(stream, { readable: reading, writable: writing }, (err) => {
58 finished = !err;
59 });
60
61 return {
62 destroy: (err) => {
63 if (finished) return;
64 finished = true;
65 destroyImpl.destroyer(stream, err || new ERR_STREAM_DESTROYED('pipe'));
66 },
67 cleanup,
68 };
69}
70
71function popCallback(streams) {
72 // Streams should never be an empty array. It should always contain at least

Callers 1

pipelineImplFunction · 0.70

Calls 2

eosFunction · 0.85
onMethod · 0.45

Tested by

no test coverage detected