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.3.3 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.3.2 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.3.1 node_modules/bower/node_modules/destroy/index.js
trusty-festivity-extension-2.3.0 node_modules/bower/node_modules/destroy/index.js
webpack_rails-1.3.1 lib/webpack_rails/node_modules/express/node_modules/send/node_modules/destroy/index.js
webpack_rails-1.3.0 lib/webpack_rails/node_modules/express/node_modules/send/node_modules/destroy/index.js
webpack_rails-1.2.2 lib/webpack_rails/node_modules/express/node_modules/send/node_modules/destroy/index.js
webpack_rails-1.2.1 lib/webpack_rails/node_modules/express/node_modules/send/node_modules/destroy/index.js
webpack_rails-1.2.0 lib/webpack_rails/node_modules/express/node_modules/send/node_modules/destroy/index.js
hooch-0.4.2 jasmine/node_modules/karma/node_modules/connect/node_modules/serve-static/node_modules/send/node_modules/destroy/index.js
webpack_rails-1.1.1 lib/webpack_rails/node_modules/express/node_modules/send/node_modules/destroy/index.js
webpack_rails-1.1.0 lib/webpack_rails/node_modules/express/node_modules/send/node_modules/destroy/index.js
webpack_rails-1.0.1 lib/webpack_rails/node_modules/express/node_modules/send/node_modules/destroy/index.js
webpack_rails-1.0.0 lib/webpack_rails/node_modules/express/node_modules/send/node_modules/destroy/index.js
hooch-0.4.1 jasmine/node_modules/karma/node_modules/connect/node_modules/serve-static/node_modules/send/node_modules/destroy/index.js
hooch-0.4.0 jasmine/node_modules/karma/node_modules/connect/node_modules/serve-static/node_modules/send/node_modules/destroy/index.js
gulp_assets-1.0.0.pre.5 template/node_modules/webpack-dev-server/node_modules/express/node_modules/send/node_modules/destroy/index.js
gulp_assets-1.0.0.pre.4 template/node_modules/webpack-dev-server/node_modules/express/node_modules/send/node_modules/destroy/index.js
gulp_assets-1.0.0.pre.3 template/node_modules/webpack-dev-server/node_modules/express/node_modules/send/node_modules/destroy/index.js
hooch-0.3.0 jasmine/node_modules/karma/node_modules/connect/node_modules/serve-static/node_modules/send/node_modules/destroy/index.js