diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-10-10 03:43:44 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-10-10 03:43:44 +0200 |
commit | abd94a7f5a50f43c797a11b53549ae48fff667c3 (patch) | |
tree | ab8ed457f65cdd72e13e0571d2975729428f1551 /node_modules/duplexer2 | |
parent | a0247c6a3fd6a09a41a7e35a3441324c4dcb58be (diff) | |
download | wallet-core-abd94a7f5a50f43c797a11b53549ae48fff667c3.tar.xz |
add node_modules to address #4364
Diffstat (limited to 'node_modules/duplexer2')
-rw-r--r-- | node_modules/duplexer2/.npmignore | 1 | ||||
-rw-r--r-- | node_modules/duplexer2/.travis.yml | 3 | ||||
-rw-r--r-- | node_modules/duplexer2/LICENSE.md | 26 | ||||
-rw-r--r-- | node_modules/duplexer2/README.md | 129 | ||||
-rwxr-xr-x | node_modules/duplexer2/example.js | 49 | ||||
-rw-r--r-- | node_modules/duplexer2/index.js | 62 | ||||
-rw-r--r-- | node_modules/duplexer2/package.json | 90 | ||||
-rw-r--r-- | node_modules/duplexer2/test/tests.js | 161 |
8 files changed, 521 insertions, 0 deletions
diff --git a/node_modules/duplexer2/.npmignore b/node_modules/duplexer2/.npmignore new file mode 100644 index 000000000..07e6e472c --- /dev/null +++ b/node_modules/duplexer2/.npmignore @@ -0,0 +1 @@ +/node_modules diff --git a/node_modules/duplexer2/.travis.yml b/node_modules/duplexer2/.travis.yml new file mode 100644 index 000000000..6e5919de3 --- /dev/null +++ b/node_modules/duplexer2/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - "0.10" diff --git a/node_modules/duplexer2/LICENSE.md b/node_modules/duplexer2/LICENSE.md new file mode 100644 index 000000000..547189a6a --- /dev/null +++ b/node_modules/duplexer2/LICENSE.md @@ -0,0 +1,26 @@ +Copyright (c) 2013, Deoxxa Development +====================================== +All rights reserved. +-------------------- + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the name of Deoxxa Development nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY DEOXXA DEVELOPMENT ''AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL DEOXXA DEVELOPMENT BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/duplexer2/README.md b/node_modules/duplexer2/README.md new file mode 100644 index 000000000..e39e1e9ed --- /dev/null +++ b/node_modules/duplexer2/README.md @@ -0,0 +1,129 @@ +duplexer2 [![build status](https://travis-ci.org/deoxxa/duplexer2.png)](https://travis-ci.org/deoxxa/fork) +========= + +Like duplexer (http://npm.im/duplexer) but using streams2. + +Overview +-------- + +duplexer2 is a reimplementation of [duplexer](http://npm.im/duplexer) using the +readable-stream API which is standard in node as of v0.10. Everything largely +works the same. + +Installation +------------ + +Available via [npm](http://npmjs.org/): + +> $ npm install duplexer2 + +Or via git: + +> $ git clone git://github.com/deoxxa/duplexer2.git node_modules/duplexer2 + +API +--- + +**duplexer2** + +Creates a new `DuplexWrapper` object, which is the actual class that implements +most of the fun stuff. All that fun stuff is hidden. DON'T LOOK. + +```javascript +duplexer2([options], writable, readable) +``` + +```javascript +var duplex = duplexer2(new stream.Writable(), new stream.Readable()); +``` + +Arguments + +* __options__ - an object specifying the regular `stream.Duplex` options, as + well as the properties described below. +* __writable__ - a writable stream +* __readable__ - a readable stream + +Options + +* __bubbleErrors__ - a boolean value that specifies whether to bubble errors + from the underlying readable/writable streams. Default is `true`. + +Example +------- + +Also see [example.js](https://github.com/deoxxa/duplexer2/blob/master/example.js). + +Code: + +```javascript +var stream = require("stream"); + +var duplexer2 = require("duplexer2"); + +var writable = new stream.Writable({objectMode: true}), + readable = new stream.Readable({objectMode: true}); + +writable._write = function _write(input, encoding, done) { + if (readable.push(input)) { + return done(); + } else { + readable.once("drain", done); + } +}; + +readable._read = function _read(n) { + // no-op +}; + +// simulate the readable thing closing after a bit +writable.once("finish", function() { + setTimeout(function() { + readable.push(null); + }, 500); +}); + +var duplex = duplexer2(writable, readable); + +duplex.on("data", function(e) { + console.log("got data", JSON.stringify(e)); +}); + +duplex.on("finish", function() { + console.log("got finish event"); +}); + +duplex.on("end", function() { + console.log("got end event"); +}); + +duplex.write("oh, hi there", function() { + console.log("finished writing"); +}); + +duplex.end(function() { + console.log("finished ending"); +}); +``` + +Output: + +``` +got data "oh, hi there" +finished writing +got finish event +finished ending +got end event +``` + +License +------- + +3-clause BSD. A copy is included with the source. + +Contact +------- + +* GitHub ([deoxxa](http://github.com/deoxxa)) +* Twitter ([@deoxxa](http://twitter.com/deoxxa)) +* Email ([deoxxa@fknsrs.biz](mailto:deoxxa@fknsrs.biz)) diff --git a/node_modules/duplexer2/example.js b/node_modules/duplexer2/example.js new file mode 100755 index 000000000..90416e9ac --- /dev/null +++ b/node_modules/duplexer2/example.js @@ -0,0 +1,49 @@ +#!/usr/bin/env node + +var stream = require("readable-stream"); + +var duplexer2 = require("./"); + +var writable = new stream.Writable({objectMode: true}), + readable = new stream.Readable({objectMode: true}); + +writable._write = function _write(input, encoding, done) { + if (readable.push(input)) { + return done(); + } else { + readable.once("drain", done); + } +}; + +readable._read = function _read(n) { + // no-op +}; + +// simulate the readable thing closing after a bit +writable.once("finish", function() { + setTimeout(function() { + readable.push(null); + }, 500); +}); + +var duplex = duplexer2(writable, readable); + +duplex.on("data", function(e) { + console.log("got data", JSON.stringify(e)); +}); + +duplex.on("finish", function() { + console.log("got finish event"); +}); + +duplex.on("end", function() { + console.log("got end event"); +}); + +duplex.write("oh, hi there", function() { + console.log("finished writing"); +}); + +duplex.end(function() { + console.log("finished ending"); +}); diff --git a/node_modules/duplexer2/index.js b/node_modules/duplexer2/index.js new file mode 100644 index 000000000..b8fafcb3f --- /dev/null +++ b/node_modules/duplexer2/index.js @@ -0,0 +1,62 @@ +var stream = require("readable-stream"); + +var duplex2 = module.exports = function duplex2(options, writable, readable) { + return new DuplexWrapper(options, writable, readable); +}; + +var DuplexWrapper = exports.DuplexWrapper = function DuplexWrapper(options, writable, readable) { + if (typeof readable === "undefined") { + readable = writable; + writable = options; + options = null; + } + + options = options || {}; + options.objectMode = true; + + stream.Duplex.call(this, options); + + this._bubbleErrors = (typeof options.bubbleErrors === "undefined") || !!options.bubbleErrors; + + this._writable = writable; + this._readable = readable; + + var self = this; + + writable.once("finish", function() { + self.end(); + }); + + this.once("finish", function() { + writable.end(); + }); + + readable.on("data", function(e) { + if (!self.push(e)) { + readable.pause(); + } + }); + + readable.once("end", function() { + return self.push(null); + }); + + if (this._bubbleErrors) { + writable.on("error", function(err) { + return self.emit("error", err); + }); + + readable.on("error", function(err) { + return self.emit("error", err); + }); + } +}; +DuplexWrapper.prototype = Object.create(stream.Duplex.prototype, {constructor: {value: DuplexWrapper}}); + +DuplexWrapper.prototype._write = function _write(input, encoding, done) { + this._writable.write(input, encoding, done); +}; + +DuplexWrapper.prototype._read = function _read(n) { + this._readable.resume(); +}; diff --git a/node_modules/duplexer2/package.json b/node_modules/duplexer2/package.json new file mode 100644 index 000000000..534f275c9 --- /dev/null +++ b/node_modules/duplexer2/package.json @@ -0,0 +1,90 @@ +{ + "_args": [ + [ + { + "raw": "duplexer2@0.0.2", + "scope": null, + "escapedName": "duplexer2", + "name": "duplexer2", + "rawSpec": "0.0.2", + "spec": "0.0.2", + "type": "version" + }, + "/home/dold/repos/taler/wallet-webex/node_modules/multipipe" + ] + ], + "_from": "duplexer2@0.0.2", + "_id": "duplexer2@0.0.2", + "_inCache": true, + "_location": "/duplexer2", + "_npmUser": { + "name": "deoxxa", + "email": "deoxxa@fknsrs.biz" + }, + "_npmVersion": "1.4.3", + "_phantomChildren": {}, + "_requested": { + "raw": "duplexer2@0.0.2", + "scope": null, + "escapedName": "duplexer2", + "name": "duplexer2", + "rawSpec": "0.0.2", + "spec": "0.0.2", + "type": "version" + }, + "_requiredBy": [ + "/multipipe" + ], + "_resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", + "_shasum": "c614dcf67e2fb14995a91711e5a617e8a60a31db", + "_shrinkwrap": null, + "_spec": "duplexer2@0.0.2", + "_where": "/home/dold/repos/taler/wallet-webex/node_modules/multipipe", + "author": { + "name": "Conrad Pankoff", + "email": "deoxxa@fknsrs.biz", + "url": "http://www.fknsrs.biz/" + }, + "bugs": { + "url": "https://github.com/deoxxa/duplexer2/issues" + }, + "dependencies": { + "readable-stream": "~1.1.9" + }, + "description": "Like duplexer (http://npm.im/duplexer) but using streams2", + "devDependencies": { + "chai": "~1.7.2", + "mocha": "~1.12.1" + }, + "directories": {}, + "dist": { + "shasum": "c614dcf67e2fb14995a91711e5a617e8a60a31db", + "tarball": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz" + }, + "homepage": "https://github.com/deoxxa/duplexer2", + "keywords": [ + "duplex", + "stream", + "join", + "combine" + ], + "license": "BSD", + "main": "index.js", + "maintainers": [ + { + "name": "deoxxa", + "email": "deoxxa@fknsrs.biz" + } + ], + "name": "duplexer2", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/deoxxa/duplexer2.git" + }, + "scripts": { + "test": "mocha -R tap" + }, + "version": "0.0.2" +} diff --git a/node_modules/duplexer2/test/tests.js b/node_modules/duplexer2/test/tests.js new file mode 100644 index 000000000..c3cf76f67 --- /dev/null +++ b/node_modules/duplexer2/test/tests.js @@ -0,0 +1,161 @@ +var assert = require("chai").assert; + +var stream = require("readable-stream"); + +var duplexer2 = require("../"); + +describe("duplexer2", function() { + var writable, readable; + + beforeEach(function() { + writable = new stream.Writable({objectMode: true}); + readable = new stream.Readable({objectMode: true}); + + writable._write = function _write(input, encoding, done) { + return done(); + }; + + readable._read = function _read(n) { + }; + }); + + it("should interact with the writable stream properly for writing", function(done) { + var duplex = duplexer2(writable, readable); + + writable._write = function _write(input, encoding, _done) { + assert.strictEqual(input, "well hello there"); + + return done(); + }; + + duplex.write("well hello there"); + }); + + it("should interact with the readable stream properly for reading", function(done) { + var duplex = duplexer2(writable, readable); + + duplex.on("data", function(e) { + assert.strictEqual(e, "well hello there"); + + return done(); + }); + + readable.push("well hello there"); + }); + + it("should end the writable stream, causing it to finish", function(done) { + var duplex = duplexer2(writable, readable); + + writable.once("finish", done); + + duplex.end(); + }); + + it("should finish when the writable stream finishes", function(done) { + var duplex = duplexer2(writable, readable); + + duplex.once("finish", done); + + writable.end(); + }); + + it("should end when the readable stream ends", function(done) { + var duplex = duplexer2(writable, readable); + + // required to let "end" fire without reading + duplex.resume(); + duplex.once("end", done); + + readable.push(null); + }); + + it("should bubble errors from the writable stream when no behaviour is specified", function(done) { + var duplex = duplexer2(writable, readable); + + var originalErr = Error("testing"); + + duplex.on("error", function(err) { + assert.strictEqual(err, originalErr); + + return done(); + }); + + writable.emit("error", originalErr); + }); + + it("should bubble errors from the readable stream when no behaviour is specified", function(done) { + var duplex = duplexer2(writable, readable); + + var originalErr = Error("testing"); + + duplex.on("error", function(err) { + assert.strictEqual(err, originalErr); + + return done(); + }); + + readable.emit("error", originalErr); + }); + + it("should bubble errors from the writable stream when bubbleErrors is true", function(done) { + var duplex = duplexer2({bubbleErrors: true}, writable, readable); + + var originalErr = Error("testing"); + + duplex.on("error", function(err) { + assert.strictEqual(err, originalErr); + + return done(); + }); + + writable.emit("error", originalErr); + }); + + it("should bubble errors from the readable stream when bubbleErrors is true", function(done) { + var duplex = duplexer2({bubbleErrors: true}, writable, readable); + + var originalErr = Error("testing"); + + duplex.on("error", function(err) { + assert.strictEqual(err, originalErr); + + return done(); + }); + + readable.emit("error", originalErr); + }); + + it("should not bubble errors from the writable stream when bubbleErrors is false", function(done) { + var duplex = duplexer2({bubbleErrors: false}, writable, readable); + + var timeout = setTimeout(done, 25); + + duplex.on("error", function(err) { + clearTimeout(timeout); + + return done(Error("shouldn't bubble error")); + }); + + // prevent uncaught error exception + writable.on("error", function() {}); + + writable.emit("error", Error("testing")); + }); + + it("should not bubble errors from the readable stream when bubbleErrors is false", function(done) { + var duplex = duplexer2({bubbleErrors: false}, writable, readable); + + var timeout = setTimeout(done, 25); + + duplex.on("error", function(err) { + clearTimeout(timeout); + + return done(Error("shouldn't bubble error")); + }); + + // prevent uncaught error exception + readable.on("error", function() {}); + + readable.emit("error", Error("testing")); + }); +}); |