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

Function _destroy

lib/internal/streams/destroy.js:90–126  ·  view source on GitHub ↗
(self, err, cb)

Source from the content-addressed store, hash-verified

88}
89
90function _destroy(self, err, cb) {
91 let called = false;
92
93 function onDestroy(err) {
94 if (called) {
95 return;
96 }
97 called = true;
98
99 const r = self._readableState;
100 const w = self._writableState;
101
102 checkError(err, w, r);
103
104 if (w) {
105 w[kState] |= kClosed;
106 }
107 if (r) {
108 r[kState] |= kClosed;
109 }
110
111 if (typeof cb === 'function') {
112 cb(err);
113 }
114
115 if (err) {
116 process.nextTick(emitErrorCloseNT, self, err);
117 } else {
118 process.nextTick(emitCloseNT, self);
119 }
120 }
121 try {
122 self._destroy(err || null, onDestroy);
123 } catch (err) {
124 onDestroy(err);
125 }
126}
127
128function emitErrorCloseNT(self, err) {
129 emitErrorNT(self, err);

Callers 1

destroyFunction · 0.70

Calls 2

onDestroyFunction · 0.85
_destroyMethod · 0.45

Tested by

no test coverage detected