diff options
author | Rebecca Turner <me@re-becca.org> | 2015-06-27 07:57:49 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2015-07-01 14:05:43 +0300 |
commit | c1312b8a0582895b744310867e6667efce97e4df (patch) | |
tree | c69835d7c067ceacd1a2e12abeaf63f461795d84 | |
parent | 92f8474a1c010762eba4a62c3c545d9e0c382321 (diff) |
unpipe@1.0.0
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | node_modules/unpipe/HISTORY.md | 4 | ||||
-rw-r--r-- | node_modules/unpipe/LICENSE | 22 | ||||
-rw-r--r-- | node_modules/unpipe/README.md | 43 | ||||
-rw-r--r-- | node_modules/unpipe/index.js | 69 | ||||
-rw-r--r-- | node_modules/unpipe/package.json | 83 | ||||
-rw-r--r-- | package.json | 2 |
7 files changed, 223 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore index 0442cd1b2..36feb5f9c 100644 --- a/.gitignore +++ b/.gitignore @@ -68,7 +68,6 @@ npm-debug.log /node_modules/url/ /node_modules/utils-merge/ /node_modules/watch/ -/node_modules/unpipe/ # tap /node_modules/align-text/ diff --git a/node_modules/unpipe/HISTORY.md b/node_modules/unpipe/HISTORY.md new file mode 100644 index 000000000..85e0f8d74 --- /dev/null +++ b/node_modules/unpipe/HISTORY.md @@ -0,0 +1,4 @@ +1.0.0 / 2015-06-14 +================== + + * Initial release diff --git a/node_modules/unpipe/LICENSE b/node_modules/unpipe/LICENSE new file mode 100644 index 000000000..aed013827 --- /dev/null +++ b/node_modules/unpipe/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.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. diff --git a/node_modules/unpipe/README.md b/node_modules/unpipe/README.md new file mode 100644 index 000000000..e536ad2c0 --- /dev/null +++ b/node_modules/unpipe/README.md @@ -0,0 +1,43 @@ +# unpipe + +[![NPM Version][npm-image]][npm-url] +[![NPM Downloads][downloads-image]][downloads-url] +[![Node.js Version][node-image]][node-url] +[![Build Status][travis-image]][travis-url] +[![Test Coverage][coveralls-image]][coveralls-url] + +Unpipe a stream from all destinations. + +## Installation + +```sh +$ npm install unpipe +``` + +## API + +```js +var unpipe = require('unpipe') +``` + +### unpipe(stream) + +Unpipes all destinations from a given stream. With stream 2+, this is +equivalent to `stream.unpipe()`. When used with streams 1 style streams +(typically Node.js 0.8 and below), this module attempts to undo the +actions done in `stream.pipe(dest)`. + +## License + +[MIT](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/unpipe.svg +[npm-url]: https://npmjs.org/package/unpipe +[node-image]: https://img.shields.io/node/v/unpipe.svg +[node-url]: http://nodejs.org/download/ +[travis-image]: https://img.shields.io/travis/stream-utils/unpipe.svg +[travis-url]: https://travis-ci.org/stream-utils/unpipe +[coveralls-image]: https://img.shields.io/coveralls/stream-utils/unpipe.svg +[coveralls-url]: https://coveralls.io/r/stream-utils/unpipe?branch=master +[downloads-image]: https://img.shields.io/npm/dm/unpipe.svg +[downloads-url]: https://npmjs.org/package/unpipe diff --git a/node_modules/unpipe/index.js b/node_modules/unpipe/index.js new file mode 100644 index 000000000..15c3d97a1 --- /dev/null +++ b/node_modules/unpipe/index.js @@ -0,0 +1,69 @@ +/*! + * unpipe + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */ + +'use strict' + +/** + * Module exports. + * @public + */ + +module.exports = unpipe + +/** + * Determine if there are Node.js pipe-like data listeners. + * @private + */ + +function hasPipeDataListeners(stream) { + var listeners = stream.listeners('data') + + for (var i = 0; i < listeners.length; i++) { + if (listeners[i].name === 'ondata') { + return true + } + } + + return false +} + +/** + * Unpipe a stream from all destinations. + * + * @param {object} stream + * @public + */ + +function unpipe(stream) { + if (!stream) { + throw new TypeError('argument stream is required') + } + + if (typeof stream.unpipe === 'function') { + // new-style + stream.unpipe() + return + } + + // Node.js 0.8 hack + if (!hasPipeDataListeners(stream)) { + return + } + + var listener + var listeners = stream.listeners('close') + + for (var i = 0; i < listeners.length; i++) { + listener = listeners[i] + + if (listener.name !== 'cleanup' && listener.name !== 'onclose') { + continue + } + + // invoke the listener + listener.call(stream) + } +} diff --git a/node_modules/unpipe/package.json b/node_modules/unpipe/package.json new file mode 100644 index 000000000..8d270a91e --- /dev/null +++ b/node_modules/unpipe/package.json @@ -0,0 +1,83 @@ +{ + "_args": [ + [ + "unpipe@~1.0.0", + "/Users/rebecca/code/npm" + ] + ], + "_from": "unpipe@>=1.0.0 <1.1.0", + "_id": "unpipe@1.0.0", + "_inCache": true, + "_location": "/unpipe", + "_npmUser": { + "email": "doug@somethingdoug.com", + "name": "dougwilson" + }, + "_npmVersion": "1.4.28", + "_phantomChildren": {}, + "_requested": { + "name": "unpipe", + "raw": "unpipe@~1.0.0", + "rawSpec": "~1.0.0", + "scope": null, + "spec": ">=1.0.0 <1.1.0", + "type": "range" + }, + "_requiredBy": [ + "/" + ], + "_resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "_shasum": "b2bf4ee8514aae6165b4817829d21b2ef49904ec", + "_shrinkwrap": null, + "_spec": "unpipe@~1.0.0", + "_where": "/Users/rebecca/code/npm", + "author": { + "email": "doug@somethingdoug.com", + "name": "Douglas Christopher Wilson" + }, + "bugs": { + "url": "https://github.com/stream-utils/unpipe/issues" + }, + "dependencies": {}, + "description": "Unpipe a stream from all destinations", + "devDependencies": { + "istanbul": "0.3.15", + "mocha": "2.2.5", + "readable-stream": "1.1.13" + }, + "directories": {}, + "dist": { + "shasum": "b2bf4ee8514aae6165b4817829d21b2ef49904ec", + "tarball": "http://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz" + }, + "engines": { + "node": ">= 0.8" + }, + "files": [ + "HISTORY.md", + "LICENSE", + "README.md", + "index.js" + ], + "gitHead": "d2df901c06487430e78dca62b6edb8bb2fc5e99d", + "homepage": "https://github.com/stream-utils/unpipe", + "license": "MIT", + "maintainers": [ + { + "name": "dougwilson", + "email": "doug@somethingdoug.com" + } + ], + "name": "unpipe", + "optionalDependencies": {}, + "repository": { + "type": "git", + "url": "https://github.com/stream-utils/unpipe" + }, + "scripts": { + "test": "mocha --reporter spec --bail --check-leaks test/", + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" + }, + "version": "1.0.0" +} diff --git a/package.json b/package.json index 2687bd377..2ce87fb01 100644 --- a/package.json +++ b/package.json @@ -91,6 +91,7 @@ "uid-number": "0.0.6", "umask": "~1.1.0", "unique-filename": "~1.0.0", + "unpipe": "~1.0.0", "validate-npm-package-name": "~2.2.2", "which": "~1.1.1", "wrappy": "~1.0.1", @@ -158,6 +159,7 @@ "uid-number", "umask", "unique-filename", + "unpipe", "validate-npm-package-name", "which", "wrappy", |