diff options
Diffstat (limited to 'node_modules/multipipe')
-rw-r--r-- | node_modules/multipipe/.npmignore | 1 | ||||
-rw-r--r-- | node_modules/multipipe/.travis.yml | 3 | ||||
-rw-r--r-- | node_modules/multipipe/History.md | 25 | ||||
-rw-r--r-- | node_modules/multipipe/Makefile | 10 | ||||
-rw-r--r-- | node_modules/multipipe/Readme.md | 102 | ||||
-rw-r--r-- | node_modules/multipipe/index.js | 72 | ||||
-rw-r--r-- | node_modules/multipipe/package.json | 16 | ||||
-rw-r--r-- | node_modules/multipipe/test/multipipe.js | 141 |
8 files changed, 0 insertions, 370 deletions
diff --git a/node_modules/multipipe/.npmignore b/node_modules/multipipe/.npmignore deleted file mode 100644 index 3c3629e64..000000000 --- a/node_modules/multipipe/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/node_modules/multipipe/.travis.yml b/node_modules/multipipe/.travis.yml deleted file mode 100644 index 6e5919de3..000000000 --- a/node_modules/multipipe/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: node_js -node_js: - - "0.10" diff --git a/node_modules/multipipe/History.md b/node_modules/multipipe/History.md deleted file mode 100644 index 52f6e8581..000000000 --- a/node_modules/multipipe/History.md +++ /dev/null @@ -1,25 +0,0 @@ - -0.1.1 / 2014-06-01 -================== - - * update duplexer2 dep - -0.1.0 / 2014-05-24 -================== - - * add optional callback - -0.0.2 / 2014-02-20 -================== - - * fix infinite loop - -0.0.1 / 2014-01-15 -================== - -* fix error bubbling - -0.0.0 / 2014-01-13 -================== - -* initial release diff --git a/node_modules/multipipe/Makefile b/node_modules/multipipe/Makefile deleted file mode 100644 index d1df0ab3d..000000000 --- a/node_modules/multipipe/Makefile +++ /dev/null @@ -1,10 +0,0 @@ - -node_modules: package.json - @npm install - -test: - @./node_modules/.bin/mocha \ - --reporter spec \ - --timeout 100 - -.PHONY: test
\ No newline at end of file diff --git a/node_modules/multipipe/Readme.md b/node_modules/multipipe/Readme.md deleted file mode 100644 index fe8c221a1..000000000 --- a/node_modules/multipipe/Readme.md +++ /dev/null @@ -1,102 +0,0 @@ -# multipipe - -A better `Stream#pipe` that creates duplex streams and lets you handle errors in one place. - -[](http://travis-ci.org/segmentio/multipipe) - -## Example - -```js -var pipe = require('multipipe'); - -// pipe streams -var stream = pipe(streamA, streamB, streamC); - -// centralized error handling -stream.on('error', fn); - -// creates a new stream -source.pipe(stream).pipe(dest); - -// optional callback on finish or error -pipe(streamA, streamB, streamC, function(err){ - // ... -}); -``` - -## Duplex streams - - Write to the pipe and you'll really write to the first stream, read from the pipe and you'll read from the last stream. - -```js -var stream = pipe(a, b, c); - -source - .pipe(stream) - .pipe(destination); -``` - - In this example the flow of data is: - - * source -> - * a -> - * b -> - * c -> - * destination - -## Error handling - - Each `pipe` forwards the errors the streams it wraps emit, so you have one central place to handle errors: - -```js -var stream = pipe(a, b, c); - -stream.on('error', function(err){ - // called three times -}); - -a.emit('error', new Error); -b.emit('error', new Error); -c.emit('error', new Error); -``` - -## API - -### pipe(stream, ...) - -Pass a variable number of streams and each will be piped to the next one. - -A stream will be returned that wraps passed in streams in a way that errors will be forwarded and you can write to and/or read from it. - -Pass a function as last argument to be called on `error` or `finish` of the last stream. - -## Installation - -```bash -$ npm install multipipe -``` - -## License - -The MIT License (MIT) - -Copyright (c) 2014 Segment.io Inc. <friends@segment.io> -Copyright (c) 2014 Julian Gruber <julian@juliangruber.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/multipipe/index.js b/node_modules/multipipe/index.js deleted file mode 100644 index 5e406db88..000000000 --- a/node_modules/multipipe/index.js +++ /dev/null @@ -1,72 +0,0 @@ - -/** - * Module dependencies. - */ - -var duplexer = require('duplexer2'); -var Stream = require('stream'); - -/** - * Slice reference. - */ - -var slice = [].slice; - -/** - * Duplexer options. - */ - -var opts = { - bubbleErrors: false -}; - -/** - * Expose `pipe`. - */ - -module.exports = pipe; - -/** - * Pipe. - * - * @param {Stream,...,[Function]} - * @return {Stream} - * @api public - */ - -function pipe(){ - if (arguments.length == 1) return arguments[0]; - var streams = slice.call(arguments); - var cb; - if ('function' == typeof streams[streams.length - 1]) { - cb = streams.splice(-1)[0]; - } - var first = streams[0]; - var last = streams[streams.length - 1]; - var ret; - - if (first.writable && last.readable) ret = duplexer(opts, first, last); - else if (first.writable) ret = first; - else if (last.readable) ret = last; - else ret = new Stream; - - streams.forEach(function(stream, i){ - var next = streams[i+1]; - if (next) stream.pipe(next); - if (stream != ret) stream.on('error', ret.emit.bind(ret, 'error')); - }); - - if (cb) { - var ended = false; - ret.on('error', end); - last.on('finish', end); - function end(err){ - if (ended) return; - ended = true; - cb(err); - } - } - - return ret; -} - diff --git a/node_modules/multipipe/package.json b/node_modules/multipipe/package.json deleted file mode 100644 index 8951329de..000000000 --- a/node_modules/multipipe/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "multipipe", - "version": "0.1.2", - "description": "pipe streams with centralized error handling", - "license": "MIT", - "repository": "juliangruber/multipipe", - "dependencies": { - "duplexer2": "0.0.2" - }, - "devDependencies": { - "mocha": "~1.17.0" - }, - "scripts": { - "test": "make test" - } -} diff --git a/node_modules/multipipe/test/multipipe.js b/node_modules/multipipe/test/multipipe.js deleted file mode 100644 index 078d2e031..000000000 --- a/node_modules/multipipe/test/multipipe.js +++ /dev/null @@ -1,141 +0,0 @@ -var assert = require('assert'); -var pipe = require('..'); -var Stream = require('stream'); - -describe('pipe(a)', function(){ - it('should return a', function(){ - var readable = Readable(); - var stream = pipe(readable); - assert.equal(stream, readable); - }); -}); - -describe('pipe(a, b, c)', function(){ - it('should pipe internally', function(done){ - pipe(Readable(), Transform(), Writable(done)); - }); - - it('should be writable', function(done){ - var stream = pipe(Transform(), Writable(done)); - assert(stream.writable); - Readable().pipe(stream); - }); - - it('should be readable', function(done){ - var stream = pipe(Readable(), Transform()); - assert(stream.readable); - stream.pipe(Writable(done)); - }); - - it('should be readable and writable', function(done){ - var stream = pipe(Transform(), Transform()); - assert(stream.readable); - assert(stream.writable); - Readable() - .pipe(stream) - .pipe(Writable(done)); - }); - - describe('errors', function(){ - it('should reemit', function(done){ - var a = Transform(); - var b = Transform(); - var c = Transform(); - var stream = pipe(a, b, c); - var err = new Error; - var i = 0; - - stream.on('error', function(_err){ - i++; - assert.equal(_err, err); - assert(i <= 3); - if (i == 3) done(); - }); - - a.emit('error', err); - b.emit('error', err); - c.emit('error', err); - }); - - it('should not reemit endlessly', function(done){ - var a = Transform(); - var b = Transform(); - var c = Transform(); - c.readable = false; - var stream = pipe(a, b, c); - var err = new Error; - var i = 0; - - stream.on('error', function(_err){ - i++; - assert.equal(_err, err); - assert(i <= 3); - if (i == 3) done(); - }); - - a.emit('error', err); - b.emit('error', err); - c.emit('error', err); - }); - }); -}); - -describe('pipe(a, b, c, fn)', function(){ - it('should call on finish', function(done){ - var finished = false; - var a = Readable(); - var b = Transform(); - var c = Writable(function(){ - finished = true; - }); - - pipe(a, b, c, function(err){ - assert(!err); - assert(finished); - done(); - }); - }); - - it('should call with error once', function(done){ - var a = Readable(); - var b = Transform(); - var c = Writable(); - var err = new Error; - - pipe(a, b, c, function(err){ - assert(err); - done(); - }); - - a.emit('error', err); - b.emit('error', err); - c.emit('error', err); - }); -}); - -function Readable(){ - var readable = new Stream.Readable({ objectMode: true }); - readable._read = function(){ - this.push('a'); - this.push(null); - }; - return readable; -} - -function Transform(){ - var transform = new Stream.Transform({ objectMode: true }); - transform._transform = function(chunk, _, done){ - done(null, chunk.toUpperCase()); - }; - return transform; -} - -function Writable(cb){ - var writable = new Stream.Writable({ objectMode: true }); - writable._write = function(chunk, _, done){ - assert.equal(chunk, 'A'); - done(); - cb(); - }; - return writable; -} |