Sha256: 8ca1330b37e00f33c9731d0be5f166f72fb2069423b2aa9a3866ae6332404d47

Contents?: true

Size: 664 Bytes

Versions: 93

Compression:

Stored size: 664 Bytes

Contents

var ReadStream = require('fs').ReadStream
var Stream = require('stream')

module.exports = 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') {
    // node.js core bug work-around
    stream.on('open', onopenClose)
  }

  return stream
}

function onopenClose() {
  if (typeof this.fd === 'number') {
    // actually close down the fd
    this.close()
  }
}

Version data entries

93 entries across 93 versions & 5 rubygems

Version Path
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.5.18 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.5.17 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.5.16 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.5.15 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.5.14 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.5.13 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.5.12 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.5.11 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.5.10 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.5.9 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.5.8 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.5.7 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.5.6 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.5.5 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.5.4 node_modules/bower/node_modules/destroy/index.js