Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

destroy

Package Overview
Dependencies
0
Maintainers
2
Versions
5
Issues
File Explorer

Advanced tools

destroy

destroy a stream if possible

    1.2.0latest

Version published
Maintainers
2
Weekly downloads
29,841,581
increased by5.72%

Weekly downloads

Readme

Source

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)

Keywords

FAQs

What is destroy?

destroy a stream if possible

Is destroy popular?

The npm package destroy receives a total of 25,232,910 weekly downloads. As such, destroy popularity was classified as popular.

Is destroy well maintained?

We found that destroy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 2 open source maintainers collaborating on the project.

Last updated on 20 Mar 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc