(stream, err)
| 320 | |
| 321 | // Normalize destroy for legacy. |
| 322 | function destroyer(stream, err) { |
| 323 | if (!stream || isDestroyed(stream)) { |
| 324 | return; |
| 325 | } |
| 326 | |
| 327 | if (!err && !isFinished(stream)) { |
| 328 | err = new AbortError(); |
| 329 | } |
| 330 | |
| 331 | // TODO: Remove isRequest branches. |
| 332 | if (isServerRequest(stream)) { |
| 333 | stream.socket = null; |
| 334 | stream.destroy(err); |
| 335 | } else if (isRequest(stream)) { |
| 336 | stream.abort(); |
| 337 | } else if (isRequest(stream.req)) { |
| 338 | stream.req.abort(); |
| 339 | } else if (typeof stream.destroy === 'function') { |
| 340 | stream.destroy(err); |
| 341 | } else if (typeof stream.close === 'function') { |
| 342 | // TODO: Don't lose err? |
| 343 | stream.close(); |
| 344 | } else if (err) { |
| 345 | process.nextTick(emitErrorCloseLegacy, stream, err); |
| 346 | } else { |
| 347 | process.nextTick(emitCloseLegacy, stream); |
| 348 | } |
| 349 | |
| 350 | if (!stream.destroyed) { |
| 351 | stream[kIsDestroyed] = true; |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | module.exports = { |
| 356 | construct, |
no test coverage detected
searching dependent graphs…