mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-06-10 21:01:41 +00:00
update
This commit is contained in:
22
node_modules/destroy/LICENSE
generated
vendored
Normal file
22
node_modules/destroy/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Jonathan Ong me@jongleberry.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
60
node_modules/destroy/README.md
generated
vendored
Normal file
60
node_modules/destroy/README.md
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
# Destroy
|
||||
|
||||
[![NPM version][npm-image]][npm-url]
|
||||
[![Build status][travis-image]][travis-url]
|
||||
[![Test coverage][coveralls-image]][coveralls-url]
|
||||
[![License][license-image]][license-url]
|
||||
[![Downloads][downloads-image]][downloads-url]
|
||||
[![Gittip][gittip-image]][gittip-url]
|
||||
|
||||
Destroy a stream.
|
||||
|
||||
This module is meant to ensure a stream gets destroyed, handling different APIs
|
||||
and Node.js bugs.
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var destroy = require('destroy')
|
||||
```
|
||||
|
||||
### destroy(stream)
|
||||
|
||||
Destroy the given stream. 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 not an instance of `Stream`, then nothing happens.
|
||||
3. If the `stream` has a `.destroy()` method, then call it.
|
||||
|
||||
The function returns the `stream` passed in as the argument.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var destroy = require('destroy')
|
||||
|
||||
var fs = require('fs')
|
||||
var stream = fs.createReadStream('package.json')
|
||||
|
||||
// ... and later
|
||||
destroy(stream)
|
||||
```
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/destroy.svg?style=flat-square
|
||||
[npm-url]: https://npmjs.org/package/destroy
|
||||
[github-tag]: http://img.shields.io/github/tag/stream-utils/destroy.svg?style=flat-square
|
||||
[github-url]: https://github.com/stream-utils/destroy/tags
|
||||
[travis-image]: https://img.shields.io/travis/stream-utils/destroy.svg?style=flat-square
|
||||
[travis-url]: https://travis-ci.org/stream-utils/destroy
|
||||
[coveralls-image]: https://img.shields.io/coveralls/stream-utils/destroy.svg?style=flat-square
|
||||
[coveralls-url]: https://coveralls.io/r/stream-utils/destroy?branch=master
|
||||
[license-image]: http://img.shields.io/npm/l/destroy.svg?style=flat-square
|
||||
[license-url]: LICENSE.md
|
||||
[downloads-image]: http://img.shields.io/npm/dm/destroy.svg?style=flat-square
|
||||
[downloads-url]: https://npmjs.org/package/destroy
|
||||
[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square
|
||||
[gittip-url]: https://www.gittip.com/jonathanong/
|
75
node_modules/destroy/index.js
generated
vendored
Normal file
75
node_modules/destroy/index.js
generated
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
/*!
|
||||
* destroy
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var ReadStream = require('fs').ReadStream
|
||||
var Stream = require('stream')
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = destroy
|
||||
|
||||
/**
|
||||
* Destroy a stream.
|
||||
*
|
||||
* @param {object} stream
|
||||
* @public
|
||||
*/
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a ReadStream.
|
||||
*
|
||||
* @param {object} stream
|
||||
* @private
|
||||
*/
|
||||
|
||||
function destroyReadStream(stream) {
|
||||
stream.destroy()
|
||||
|
||||
if (typeof stream.close === 'function') {
|
||||
// node.js core bug work-around
|
||||
stream.on('open', onOpenClose)
|
||||
}
|
||||
|
||||
return stream
|
||||
}
|
||||
|
||||
/**
|
||||
* On open handler to close stream.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function onOpenClose() {
|
||||
if (typeof this.fd === 'number') {
|
||||
// actually close down the fd
|
||||
this.close()
|
||||
}
|
||||
}
|
74
node_modules/destroy/package.json
generated
vendored
Normal file
74
node_modules/destroy/package.json
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"destroy@1.0.4",
|
||||
"/Users/tatiana/selfdefined"
|
||||
]
|
||||
],
|
||||
"_from": "destroy@1.0.4",
|
||||
"_id": "destroy@1.0.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=",
|
||||
"_location": "/destroy",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "destroy@1.0.4",
|
||||
"name": "destroy",
|
||||
"escapedName": "destroy",
|
||||
"rawSpec": "1.0.4",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.0.4"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/send"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
|
||||
"_spec": "1.0.4",
|
||||
"_where": "/Users/tatiana/selfdefined",
|
||||
"author": {
|
||||
"name": "Jonathan Ong",
|
||||
"email": "me@jongleberry.com",
|
||||
"url": "http://jongleberry.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/stream-utils/destroy/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"description": "destroy a stream if possible",
|
||||
"devDependencies": {
|
||||
"istanbul": "0.4.2",
|
||||
"mocha": "2.3.4"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"LICENSE"
|
||||
],
|
||||
"homepage": "https://github.com/stream-utils/destroy#readme",
|
||||
"keywords": [
|
||||
"stream",
|
||||
"streams",
|
||||
"destroy",
|
||||
"cleanup",
|
||||
"leak",
|
||||
"fd"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "destroy",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/stream-utils/destroy.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot",
|
||||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"
|
||||
},
|
||||
"version": "1.0.4"
|
||||
}
|
Reference in New Issue
Block a user