diff options
Diffstat (limited to 'deps/npm/node_modules/mississippi/node_modules/duplexify')
14 files changed, 425 insertions, 28 deletions
diff --git a/deps/npm/node_modules/mississippi/node_modules/duplexify/.npmignore b/deps/npm/node_modules/mississippi/node_modules/duplexify/.npmignore new file mode 100644 index 0000000000..3c3629e647 --- /dev/null +++ b/deps/npm/node_modules/mississippi/node_modules/duplexify/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/deps/npm/node_modules/mississippi/node_modules/duplexify/README.md b/deps/npm/node_modules/mississippi/node_modules/duplexify/README.md index 8352900fc6..27669f6b6b 100644 --- a/deps/npm/node_modules/mississippi/node_modules/duplexify/README.md +++ b/deps/npm/node_modules/mississippi/node_modules/duplexify/README.md @@ -46,7 +46,7 @@ If you call `setReadable` or `setWritable` multiple times it will unregister the To disable the readable or writable part call `setReadable` or `setWritable` with `null`. If the readable or writable streams emits an error or close it will destroy both streams and bubble up the event. -You can also explicitly destroy the streams by calling `dup.destroy()`. The `destroy` method optionally takes an +You can also explictly destroy the streams by calling `dup.destroy()`. The `destroy` method optionally takes an error object as argument, in which case the error is emitted as part of the `error` event. ``` js diff --git a/deps/npm/node_modules/mississippi/node_modules/duplexify/index.js b/deps/npm/node_modules/mississippi/node_modules/duplexify/index.js index 8323e654ac..a04f124fa9 100644 --- a/deps/npm/node_modules/mississippi/node_modules/duplexify/index.js +++ b/deps/npm/node_modules/mississippi/node_modules/duplexify/index.js @@ -3,9 +3,7 @@ var eos = require('end-of-stream') var inherits = require('inherits') var shift = require('stream-shift') -var SIGNAL_FLUSH = (Buffer.from && Buffer.from !== Uint8Array.from) - ? Buffer.from([0]) - : new Buffer([0]) +var SIGNAL_FLUSH = new Buffer([0]) var onuncork = function(self, fn) { if (self._corked) self.once('uncork', fn) @@ -14,7 +12,7 @@ var onuncork = function(self, fn) { var destroyer = function(self, end) { return function(err) { - if (err) self._destroyInterval(err) + if (err) self.destroy(err.message === 'premature close' ? null : err) else if (end && !self._ended) self.end() } } @@ -48,8 +46,6 @@ var Duplexify = function(writable, readable, opts) { this._unwrite = null this._unread = null this._ended = false - this._error = null - this._preferError = false this.destroyed = false @@ -171,24 +167,15 @@ Duplexify.prototype._forward = function() { } Duplexify.prototype.destroy = function(err) { - if (this._preferError && !this._error && err) this._error = err - if (this.destroyed) return this.destroyed = true var self = this process.nextTick(function() { - self._destroy(self._preferError ? self._error : err) + self._destroy(err) }) } -Duplexify.prototype._destroyInterval = function(err) { - if (this.destroyed) return - if (err.message !== 'premature close') return this.destroy(err) - this._preferError = true - this.destroy(null) -} - Duplexify.prototype._destroy = function(err) { if (err) { var ondrain = this._ondrain diff --git a/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/.npmignore b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/.npmignore new file mode 100644 index 0000000000..3c3629e647 --- /dev/null +++ b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/README.md b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/README.md new file mode 100644 index 0000000000..df800c1eb6 --- /dev/null +++ b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/README.md @@ -0,0 +1,47 @@ +# end-of-stream + +A node module that calls a callback when a readable/writable/duplex stream has completed or failed. + + npm install end-of-stream + +## Usage + +Simply pass a stream and a callback to the `eos`. +Both legacy streams and streams2 are supported. + +``` js +var eos = require('end-of-stream'); + +eos(readableStream, function(err) { + if (err) return console.log('stream had an error or closed early'); + console.log('stream has ended'); +}); + +eos(writableStream, function(err) { + if (err) return console.log('stream had an error or closed early'); + console.log('stream has finished'); +}); + +eos(duplexStream, function(err) { + if (err) return console.log('stream had an error or closed early'); + console.log('stream has ended and finished'); +}); + +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'); +}); + +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'); +}); + +eos(readableStream, {error:false}, function(err) { + // do not treat emit('error', err) as a end-of-stream +}); +``` + +## License + +MIT
\ No newline at end of file diff --git a/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/index.js b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/index.js new file mode 100644 index 0000000000..9f61ed5af9 --- /dev/null +++ b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/index.js @@ -0,0 +1,72 @@ +var once = require('once'); + +var noop = function() {}; + +var isRequest = function(stream) { + return stream.setHeader && typeof stream.abort === 'function'; +}; + +var eos = function(stream, opts, callback) { + if (typeof opts === 'function') return eos(stream, null, opts); + if (!opts) opts = {}; + + callback = once(callback || noop); + + var ws = stream._writableState; + var rs = stream._readableState; + var readable = opts.readable || (opts.readable !== false && stream.readable); + var writable = opts.writable || (opts.writable !== false && stream.writable); + + var onlegacyfinish = function() { + if (!stream.writable) onfinish(); + }; + + var onfinish = function() { + writable = false; + if (!readable) callback(); + }; + + var onend = function() { + readable = false; + if (!writable) callback(); + }; + + 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')); + }; + + var onrequest = function() { + stream.req.on('finish', onfinish); + }; + + if (isRequest(stream)) { + stream.on('complete', onfinish); + stream.on('abort', onclose); + if (stream.req) onrequest(); + else stream.on('request', onrequest); + } else if (writable && !ws) { // legacy streams + stream.on('end', onlegacyfinish); + stream.on('close', onlegacyfinish); + } + + stream.on('end', onend); + stream.on('finish', onfinish); + if (opts.error !== false) stream.on('error', callback); + stream.on('close', onclose); + + return function() { + stream.removeListener('complete', onfinish); + stream.removeListener('abort', onclose); + stream.removeListener('request', onrequest); + if (stream.req) stream.req.removeListener('finish', onfinish); + stream.removeListener('end', onlegacyfinish); + stream.removeListener('close', onlegacyfinish); + stream.removeListener('finish', onfinish); + stream.removeListener('end', onend); + stream.removeListener('error', callback); + stream.removeListener('close', onclose); + }; +}; + +module.exports = eos;
\ No newline at end of file diff --git a/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/node_modules/once/LICENSE b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/node_modules/once/LICENSE new file mode 100644 index 0000000000..19129e315f --- /dev/null +++ b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/node_modules/once/LICENSE @@ -0,0 +1,15 @@ +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/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/node_modules/once/README.md b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/node_modules/once/README.md new file mode 100644 index 0000000000..a2981ea070 --- /dev/null +++ b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/node_modules/once/README.md @@ -0,0 +1,51 @@ +# 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/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/node_modules/once/once.js b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/node_modules/once/once.js new file mode 100644 index 0000000000..2e1e721bfe --- /dev/null +++ b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/node_modules/once/once.js @@ -0,0 +1,21 @@ +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/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/node_modules/once/package.json b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/node_modules/once/package.json new file mode 100644 index 0000000000..8c0e6e2991 --- /dev/null +++ b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/node_modules/once/package.json @@ -0,0 +1,69 @@ +{ + "_from": "once@~1.3.0", + "_id": "once@1.3.3", + "_integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", + "_location": "/mississippi/duplexify/end-of-stream/once", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "once@~1.3.0", + "name": "once", + "escapedName": "once", + "rawSpec": "~1.3.0", + "saveSpec": null, + "fetchSpec": "~1.3.0" + }, + "_requiredBy": [ + "/mississippi/duplexify/end-of-stream" + ], + "_resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", + "_shasum": "b2e261557ce4c314ec8304f3fa82663e4297ca20", + "_shrinkwrap": null, + "_spec": "once@~1.3.0", + "_where": "/Users/zkat/Documents/code/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream", + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "bin": null, + "bugs": { + "url": "https://github.com/isaacs/once/issues" + }, + "bundleDependencies": false, + "dependencies": { + "wrappy": "1" + }, + "deprecated": false, + "description": "Run a function exactly one time", + "devDependencies": { + "tap": "^1.2.0" + }, + "directories": { + "test": "test" + }, + "files": [ + "once.js" + ], + "homepage": "https://github.com/isaacs/once#readme", + "keywords": [ + "once", + "function", + "one", + "single" + ], + "license": "ISC", + "main": "once.js", + "name": "once", + "optionalDependencies": {}, + "peerDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/isaacs/once.git" + }, + "scripts": { + "test": "tap test/*.js" + }, + "version": "1.3.3" +} diff --git a/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/package.json b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/package.json new file mode 100644 index 0000000000..433faa2e6c --- /dev/null +++ b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/package.json @@ -0,0 +1,65 @@ +{ + "_from": "end-of-stream@1.0.0", + "_id": "end-of-stream@1.0.0", + "_integrity": "sha1-1FlucCc0qT5A6a+GQxnqvZn/Lw4=", + "_location": "/mississippi/duplexify/end-of-stream", + "_phantomChildren": { + "wrappy": "1.0.2" + }, + "_requested": { + "type": "version", + "registry": true, + "raw": "end-of-stream@1.0.0", + "name": "end-of-stream", + "escapedName": "end-of-stream", + "rawSpec": "1.0.0", + "saveSpec": null, + "fetchSpec": "1.0.0" + }, + "_requiredBy": [ + "/mississippi/duplexify" + ], + "_resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.0.0.tgz", + "_shasum": "d4596e702734a93e40e9af864319eabd99ff2f0e", + "_shrinkwrap": null, + "_spec": "end-of-stream@1.0.0", + "_where": "/Users/zkat/Documents/code/npm/node_modules/mississippi/node_modules/duplexify", + "author": { + "name": "Mathias Buus", + "email": "mathiasbuus@gmail.com" + }, + "bin": null, + "bugs": { + "url": "https://github.com/mafintosh/end-of-stream/issues" + }, + "bundleDependencies": false, + "dependencies": { + "once": "~1.3.0" + }, + "deprecated": false, + "description": "Call a callback when a readable/writable/duplex stream has completed or failed.", + "devDependencies": {}, + "homepage": "https://github.com/mafintosh/end-of-stream", + "keywords": [ + "stream", + "streams", + "callback", + "finish", + "close", + "end", + "wait" + ], + "license": "MIT", + "main": "index.js", + "name": "end-of-stream", + "optionalDependencies": {}, + "peerDependencies": {}, + "repository": { + "type": "git", + "url": "git://github.com/mafintosh/end-of-stream.git" + }, + "scripts": { + "test": "node test.js" + }, + "version": "1.0.0" +} diff --git a/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/test.js b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/test.js new file mode 100644 index 0000000000..d4d126fe56 --- /dev/null +++ b/deps/npm/node_modules/mississippi/node_modules/duplexify/node_modules/end-of-stream/test.js @@ -0,0 +1,62 @@ +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); diff --git a/deps/npm/node_modules/mississippi/node_modules/duplexify/package.json b/deps/npm/node_modules/mississippi/node_modules/duplexify/package.json index ed3ea4ab17..2249d135e5 100644 --- a/deps/npm/node_modules/mississippi/node_modules/duplexify/package.json +++ b/deps/npm/node_modules/mississippi/node_modules/duplexify/package.json @@ -1,10 +1,11 @@ { "_from": "duplexify@^3.4.2", - "_id": "duplexify@3.5.4", - "_inBundle": false, - "_integrity": "sha512-JzYSLYMhoVVBe8+mbHQ4KgpvHpm0DZpJuL8PY93Vyv1fW7jYJ90LoXa1di/CVbJM+TgMs91rbDapE/RNIfnJsA==", + "_id": "duplexify@3.5.0", + "_integrity": "sha1-GqdzAC4VeEV+nZ1KULDMquvL1gQ=", "_location": "/mississippi/duplexify", - "_phantomChildren": {}, + "_phantomChildren": { + "wrappy": "1.0.2" + }, "_requested": { "type": "range", "registry": true, @@ -19,19 +20,21 @@ "/mississippi", "/mississippi/pumpify" ], - "_resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.5.4.tgz", - "_shasum": "4bb46c1796eabebeec4ca9a2e66b808cb7a3d8b4", + "_resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.5.0.tgz", + "_shasum": "1aa773002e1578457e9d9d4a50b0ccaaebcbd604", + "_shrinkwrap": null, "_spec": "duplexify@^3.4.2", "_where": "/Users/zkat/Documents/code/npm/node_modules/mississippi", "author": { "name": "Mathias Buus" }, + "bin": null, "bugs": { "url": "https://github.com/mafintosh/duplexify/issues" }, "bundleDependencies": false, "dependencies": { - "end-of-stream": "^1.0.0", + "end-of-stream": "1.0.0", "inherits": "^2.0.1", "readable-stream": "^2.0.0", "stream-shift": "^1.0.0" @@ -39,9 +42,9 @@ "deprecated": false, "description": "Turn a writable and readable stream into a streams2 duplex stream with support for async initialization and streams1/streams2 input", "devDependencies": { - "concat-stream": "^1.5.2", - "tape": "^4.0.0", - "through2": "^2.0.0" + "concat-stream": "^1.4.6", + "tape": "^2.13.3", + "through2": "^0.5.1" }, "homepage": "https://github.com/mafintosh/duplexify", "keywords": [ @@ -56,6 +59,8 @@ "license": "MIT", "main": "index.js", "name": "duplexify", + "optionalDependencies": {}, + "peerDependencies": {}, "repository": { "type": "git", "url": "git://github.com/mafintosh/duplexify.git" @@ -63,5 +68,5 @@ "scripts": { "test": "tape test.js" }, - "version": "3.5.4" + "version": "3.5.0" } diff --git a/deps/npm/node_modules/mississippi/node_modules/duplexify/test.js b/deps/npm/node_modules/mississippi/node_modules/duplexify/test.js index 4330e93cf0..f4856d39ea 100644 --- a/deps/npm/node_modules/mississippi/node_modules/duplexify/test.js +++ b/deps/npm/node_modules/mississippi/node_modules/duplexify/test.js @@ -260,6 +260,7 @@ tape('prefinish not twice', function(t) { tape('close', function(t) { var passthrough = through() var dup = duplexify(passthrough, passthrough) + var ok = false passthrough.emit('close') dup.on('close', function() { |