1.2.0 • Published 2 years ago

destroy v1.2.0

Weekly downloads
16,574,794
License
MIT
Repository
github
Last release
2 years ago

destroy

NPM version Build Status Test coverage License Downloads

Destroy a stream.

This module is meant to ensure a stream gets destroyed, handling different APIs and Node.js bugs.

API

var destroy = require('destroy')

destroy(stream , suppress)

Destroy the given stream, and optionally suppress any future error events.

In most cases, this is identical to a simple stream.destroy() call. The rules are as follows for a given stream:

  1. If the stream is an instance of ReadStream, then call stream.destroy() and add a listener to the open event to call stream.close() if it is fired. This is for a Node.js bug that will leak a file descriptor if .destroy() is called before open.
  2. If the stream is an instance of a zlib stream, then call stream.destroy() and close the underlying zlib handle if open, otherwise call stream.close(). This is for consistency across Node.js versions and a Node.js bug that will leak a native zlib handle.
  3. If the stream is not an instance of Stream, then nothing happens.
  4. If the stream has a .destroy() method, then call it.

The function returns the stream passed in as the argument.

Example

var destroy = require('destroy')

var fs = require('fs')
var stream = fs.createReadStream('package.json')

// ... and later
destroy(stream)
sendbody-parser@teakit/atom@directus-asolole/apicomponennentteasy-select-rnchinjowwchinjowvuedragdropuploadimagesreact-native-bluetooth2killi8n-react-native-fast-imageqiniu-mpextensible-node-serverrn-send-sms@arisageha/react-lazyload@arisageha/react-lazyload-fixsfr-koaali-oss-weiyieali-oss-weiyie1react-native-template-rfbaseairscanairscan-examplebb-chatreact-native-esc-pos-sahaab@borisovart/atol-kkt-module@frxf/frxfdeneme323112@texttree/demo-bsa-reference-rclwlite-avsdk-vod-upload-node-userswlite-avsdk-vod-upload-node-v2-u@bravejs/http-response@ntt_app/react-native-custom-notificationali-oss-weiyiweiyie-test-ts-ali-ossreact-native-custom-text-hwjames@easyboot/corereact-native-covid-sdkanime-randomeni-chatmidlyreact-native-thanh-toast-librarypmswebserve@thanhnguyen14797/react-native-thanh-toast-library@l1nyanm1ng/react-picture-viewercthpb-plugin-socialdirectus9-liteexpress-easy-staticreact-native-printer-brothersrn-pdf-reader-offline@annoai/node-stream-helperreact-native-shekhar-bridge-testlevibestliblevibestlib2levilibtest19levilibtest24levilibtest25levilibtest26levilibtest27levilibtest28levilibtest29wilscanner@oiti/documentoscopy-react-nativequoc-testreact-native-slider-kfnodejs-filesharenotespod-ali-ossunblock-block-save-variableshexa-node-common@infinitebrahmanuniverse/nolb-desdimensiodap-clidata-access-platform-clicclibyarntest@saaspe/componentshyperpass-sdkexpress-api-pack-tropea-bootstraapluminos-ui-corelizeknushiliyahaotadiesklif-ui-kitsklif-api@everything-registry/sub-chunk-1471jawwy-sdkjawwy_gamification_release@314oner_npm/universal-components-libraryreact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkgondp149-tablesklif-uireact-native-jawwy_sample@skedulr/nebula-ui-library@aclisp/directus@amirdiafi/react-native-ios-haptics@asiz33/smartblok-vendure-plugin@assystant/firebase@aleen42/gitbook@aleung/gitbook
1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.4

8 years ago

1.0.3

10 years ago

0.0.0

10 years ago