source: trip-planner-front/node_modules/destroy/README.md@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.1 KB
Line 
1# Destroy
2
3[![NPM version][npm-image]][npm-url]
4[![Build status][travis-image]][travis-url]
5[![Test coverage][coveralls-image]][coveralls-url]
6[![License][license-image]][license-url]
7[![Downloads][downloads-image]][downloads-url]
8[![Gittip][gittip-image]][gittip-url]
9
10Destroy a stream.
11
12This module is meant to ensure a stream gets destroyed, handling different APIs
13and Node.js bugs.
14
15## API
16
17```js
18var destroy = require('destroy')
19```
20
21### destroy(stream)
22
23Destroy the given stream. In most cases, this is identical to a simple
24`stream.destroy()` call. The rules are as follows for a given stream:
25
26 1. If the `stream` is an instance of `ReadStream`, then call `stream.destroy()`
27 and add a listener to the `open` event to call `stream.close()` if it is
28 fired. This is for a Node.js bug that will leak a file descriptor if
29 `.destroy()` is called before `open`.
30 2. If the `stream` is not an instance of `Stream`, then nothing happens.
31 3. If the `stream` has a `.destroy()` method, then call it.
32
33The function returns the `stream` passed in as the argument.
34
35## Example
36
37```js
38var destroy = require('destroy')
39
40var fs = require('fs')
41var stream = fs.createReadStream('package.json')
42
43// ... and later
44destroy(stream)
45```
46
47[npm-image]: https://img.shields.io/npm/v/destroy.svg?style=flat-square
48[npm-url]: https://npmjs.org/package/destroy
49[github-tag]: http://img.shields.io/github/tag/stream-utils/destroy.svg?style=flat-square
50[github-url]: https://github.com/stream-utils/destroy/tags
51[travis-image]: https://img.shields.io/travis/stream-utils/destroy.svg?style=flat-square
52[travis-url]: https://travis-ci.org/stream-utils/destroy
53[coveralls-image]: https://img.shields.io/coveralls/stream-utils/destroy.svg?style=flat-square
54[coveralls-url]: https://coveralls.io/r/stream-utils/destroy?branch=master
55[license-image]: http://img.shields.io/npm/l/destroy.svg?style=flat-square
56[license-url]: LICENSE.md
57[downloads-image]: http://img.shields.io/npm/dm/destroy.svg?style=flat-square
58[downloads-url]: https://npmjs.org/package/destroy
59[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square
60[gittip-url]: https://www.gittip.com/jonathanong/
Note: See TracBrowser for help on using the repository browser.