123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- 'use strict'
- var ReadStream = require('fs').ReadStream
- var Stream = require('stream')
- module.exports = destroy
- function destroy(stream) {
- if (stream instanceof ReadStream) {
- return destroyReadStream(stream)
- }
- if (!(stream instanceof Stream)) {
- return stream
- }
- if (typeof stream.destroy === 'function') {
- stream.destroy()
- }
- return stream
- }
- function destroyReadStream(stream) {
- stream.destroy()
- if (typeof stream.close === 'function') {
-
- stream.on('open', onOpenClose)
- }
- return stream
- }
- function onOpenClose() {
- if (typeof this.fd === 'number') {
-
- this.close()
- }
- }
|