diff options
Diffstat (limited to 'node_modules/end-of-stream')
-rw-r--r-- | node_modules/end-of-stream/.npmignore | 1 | ||||
-rw-r--r-- | node_modules/end-of-stream/LICENSE | 21 | ||||
-rw-r--r-- | node_modules/end-of-stream/README.md | 19 | ||||
-rw-r--r-- | node_modules/end-of-stream/index.js | 21 | ||||
-rw-r--r-- | node_modules/end-of-stream/node_modules/once/LICENSE | 15 | ||||
-rw-r--r-- | node_modules/end-of-stream/node_modules/once/README.md | 51 | ||||
-rw-r--r-- | node_modules/end-of-stream/node_modules/once/once.js | 21 | ||||
-rw-r--r-- | node_modules/end-of-stream/node_modules/once/package.json | 33 | ||||
-rw-r--r-- | node_modules/end-of-stream/package.json | 7 | ||||
-rw-r--r-- | node_modules/end-of-stream/test.js | 62 |
10 files changed, 54 insertions, 197 deletions
diff --git a/node_modules/end-of-stream/.npmignore b/node_modules/end-of-stream/.npmignore deleted file mode 100644 index 3c3629e64..000000000 --- a/node_modules/end-of-stream/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/node_modules/end-of-stream/LICENSE b/node_modules/end-of-stream/LICENSE new file mode 100644 index 000000000..757562ec5 --- /dev/null +++ b/node_modules/end-of-stream/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Mathias Buus + +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.
\ No newline at end of file diff --git a/node_modules/end-of-stream/README.md b/node_modules/end-of-stream/README.md index df800c1eb..f2560c939 100644 --- a/node_modules/end-of-stream/README.md +++ b/node_modules/end-of-stream/README.md @@ -7,34 +7,35 @@ A node module that calls a callback when a readable/writable/duplex stream has c ## Usage Simply pass a stream and a callback to the `eos`. -Both legacy streams and streams2 are supported. +Both legacy streams, streams2 and stream3 are supported. ``` js var eos = require('end-of-stream'); eos(readableStream, function(err) { + // this will be set to the stream instance if (err) return console.log('stream had an error or closed early'); - console.log('stream has ended'); + console.log('stream has ended', this === readableStream); }); eos(writableStream, function(err) { if (err) return console.log('stream had an error or closed early'); - console.log('stream has finished'); + console.log('stream has finished', this === writableStream); }); eos(duplexStream, function(err) { if (err) return console.log('stream had an error or closed early'); - console.log('stream has ended and finished'); + console.log('stream has ended and finished', this === duplexStream); }); eos(duplexStream, {readable:false}, function(err) { if (err) return console.log('stream had an error or closed early'); - console.log('stream has ended but might still be writable'); + console.log('stream has finished but might still be readable'); }); eos(duplexStream, {writable:false}, function(err) { if (err) return console.log('stream had an error or closed early'); - console.log('stream has ended but might still be readable'); + console.log('stream has ended but might still be writable'); }); eos(readableStream, {error:false}, function(err) { @@ -44,4 +45,8 @@ eos(readableStream, {error:false}, function(err) { ## License -MIT
\ No newline at end of file +MIT + +## Related + +`end-of-stream` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one. diff --git a/node_modules/end-of-stream/index.js b/node_modules/end-of-stream/index.js index 9f61ed5af..b3a906863 100644 --- a/node_modules/end-of-stream/index.js +++ b/node_modules/end-of-stream/index.js @@ -6,6 +6,10 @@ var isRequest = function(stream) { return stream.setHeader && typeof stream.abort === 'function'; }; +var isChildProcess = function(stream) { + return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3 +}; + var eos = function(stream, opts, callback) { if (typeof opts === 'function') return eos(stream, null, opts); if (!opts) opts = {}; @@ -23,17 +27,21 @@ var eos = function(stream, opts, callback) { var onfinish = function() { writable = false; - if (!readable) callback(); + if (!readable) callback.call(stream); }; var onend = function() { readable = false; - if (!writable) callback(); + if (!writable) callback.call(stream); + }; + + var onexit = function(exitCode) { + callback.call(stream, exitCode ? new Error('exited with error code: ' + exitCode) : null); }; var onclose = function() { - if (readable && !(rs && rs.ended)) return callback(new Error('premature close')); - if (writable && !(ws && ws.ended)) return callback(new Error('premature close')); + if (readable && !(rs && rs.ended)) return callback.call(stream, new Error('premature close')); + if (writable && !(ws && ws.ended)) return callback.call(stream, new Error('premature close')); }; var onrequest = function() { @@ -50,6 +58,8 @@ var eos = function(stream, opts, callback) { stream.on('close', onlegacyfinish); } + if (isChildProcess(stream)) stream.on('exit', onexit); + stream.on('end', onend); stream.on('finish', onfinish); if (opts.error !== false) stream.on('error', callback); @@ -63,10 +73,11 @@ var eos = function(stream, opts, callback) { stream.removeListener('end', onlegacyfinish); stream.removeListener('close', onlegacyfinish); stream.removeListener('finish', onfinish); + stream.removeListener('exit', onexit); stream.removeListener('end', onend); stream.removeListener('error', callback); stream.removeListener('close', onclose); }; }; -module.exports = eos;
\ No newline at end of file +module.exports = eos; diff --git a/node_modules/end-of-stream/node_modules/once/LICENSE b/node_modules/end-of-stream/node_modules/once/LICENSE deleted file mode 100644 index 19129e315..000000000 --- a/node_modules/end-of-stream/node_modules/once/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -The ISC License - -Copyright (c) Isaac Z. Schlueter and Contributors - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/end-of-stream/node_modules/once/README.md b/node_modules/end-of-stream/node_modules/once/README.md deleted file mode 100644 index a2981ea07..000000000 --- a/node_modules/end-of-stream/node_modules/once/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# once - -Only call a function once. - -## usage - -```javascript -var once = require('once') - -function load (file, cb) { - cb = once(cb) - loader.load('file') - loader.once('load', cb) - loader.once('error', cb) -} -``` - -Or add to the Function.prototype in a responsible way: - -```javascript -// only has to be done once -require('once').proto() - -function load (file, cb) { - cb = cb.once() - loader.load('file') - loader.once('load', cb) - loader.once('error', cb) -} -``` - -Ironically, the prototype feature makes this module twice as -complicated as necessary. - -To check whether you function has been called, use `fn.called`. Once the -function is called for the first time the return value of the original -function is saved in `fn.value` and subsequent calls will continue to -return this value. - -```javascript -var once = require('once') - -function load (cb) { - cb = once(cb) - var stream = createStream() - stream.once('data', cb) - stream.once('end', function () { - if (!cb.called) cb(new Error('not found')) - }) -} -``` diff --git a/node_modules/end-of-stream/node_modules/once/once.js b/node_modules/end-of-stream/node_modules/once/once.js deleted file mode 100644 index 2e1e721bf..000000000 --- a/node_modules/end-of-stream/node_modules/once/once.js +++ /dev/null @@ -1,21 +0,0 @@ -var wrappy = require('wrappy') -module.exports = wrappy(once) - -once.proto = once(function () { - Object.defineProperty(Function.prototype, 'once', { - value: function () { - return once(this) - }, - configurable: true - }) -}) - -function once (fn) { - var f = function () { - if (f.called) return f.value - f.called = true - return f.value = fn.apply(this, arguments) - } - f.called = false - return f -} diff --git a/node_modules/end-of-stream/node_modules/once/package.json b/node_modules/end-of-stream/node_modules/once/package.json deleted file mode 100644 index 28fe2ff72..000000000 --- a/node_modules/end-of-stream/node_modules/once/package.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "once", - "version": "1.3.3", - "description": "Run a function exactly one time", - "main": "once.js", - "directories": { - "test": "test" - }, - "dependencies": { - "wrappy": "1" - }, - "devDependencies": { - "tap": "^1.2.0" - }, - "scripts": { - "test": "tap test/*.js" - }, - "files": [ - "once.js" - ], - "repository": { - "type": "git", - "url": "git://github.com/isaacs/once" - }, - "keywords": [ - "once", - "function", - "one", - "single" - ], - "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)", - "license": "ISC" -} diff --git a/node_modules/end-of-stream/package.json b/node_modules/end-of-stream/package.json index 5e36241b5..81315b690 100644 --- a/node_modules/end-of-stream/package.json +++ b/node_modules/end-of-stream/package.json @@ -1,17 +1,20 @@ { "name": "end-of-stream", - "version": "1.0.0", + "version": "1.4.0", "description": "Call a callback when a readable/writable/duplex stream has completed or failed.", "repository": { "type": "git", "url": "git://github.com/mafintosh/end-of-stream.git" }, "dependencies": { - "once": "~1.3.0" + "once": "^1.4.0" }, "scripts": { "test": "node test.js" }, + "files": [ + "index.js" + ], "keywords": [ "stream", "streams", diff --git a/node_modules/end-of-stream/test.js b/node_modules/end-of-stream/test.js deleted file mode 100644 index d4d126fe5..000000000 --- a/node_modules/end-of-stream/test.js +++ /dev/null @@ -1,62 +0,0 @@ -var assert = require('assert'); -var eos = require('./index'); - -var expected = 6; -var fs = require('fs'); -var net = require('net'); - -var ws = fs.createWriteStream('/dev/null'); -eos(ws, function(err) { - expected--; - assert(!!err); - if (!expected) process.exit(0); -}); -ws.close(); - -var rs = fs.createReadStream('/dev/random'); -eos(rs, function(err) { - expected--; - assert(!!err); - if (!expected) process.exit(0); -}); -rs.close(); - -var rs = fs.createReadStream(__filename); -eos(rs, function(err) { - expected--; - assert(!err); - if (!expected) process.exit(0); -}); -rs.pipe(fs.createWriteStream('/dev/null')); - -var rs = fs.createReadStream(__filename); -eos(rs, function(err) { - throw new Error('no go') -})(); -rs.pipe(fs.createWriteStream('/dev/null')); - -var socket = net.connect(50000); -eos(socket, function(err) { - expected--; - assert(!!err); - if (!expected) process.exit(0); -}); - -var server = net.createServer(function(socket) { - eos(socket, function() { - expected--; - if (!expected) process.exit(0); - }); - socket.destroy(); -}).listen(30000, function() { - var socket = net.connect(30000); - eos(socket, function() { - expected--; - if (!expected) process.exit(0); - }); -}); - -setTimeout(function() { - assert(expected === 0); - process.exit(0); -}, 1000); |