diff options
Diffstat (limited to 'deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify')
13 files changed, 0 insertions, 727 deletions
diff --git a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/.travis.yml b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/.travis.yml deleted file mode 100644 index 32e71a6b55..0000000000 --- a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: node_js - -node_js: - - "0.10" - - "4" - - "5" - -sudo: false diff --git a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/LICENSE b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/LICENSE deleted file mode 100644 index 757562ec59..0000000000 --- a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -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/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/README.md b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/README.md deleted file mode 100644 index 4988f7b126..0000000000 --- a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# pumpify - -Combine an array of streams into a single duplex stream using [pump](https://github.com/mafintosh/pump) and [duplexify](https://github.com/mafintosh/duplexify). -If one of the streams closes/errors all streams in the pipeline will be destroyed. - -``` -npm install pumpify -``` - -[![build status](http://img.shields.io/travis/mafintosh/pumpify.svg?style=flat)](http://travis-ci.org/mafintosh/pumpify) - -## Usage - -Pass the streams you want to pipe together to pumpify `pipeline = pumpify(s1, s2, s3, ...)`. -`pipeline` is a duplex stream that writes to the first streams and reads from the last one. -Streams are piped together using [pump](https://github.com/mafintosh/pump) so if one of them closes -all streams will be destroyed. - -``` js -var pumpify = require('pumpify') -var tar = require('tar-fs') -var zlib = require('zlib') -var fs = require('fs') - -var untar = pumpify(zlib.createGunzip(), tar.extract('output-folder')) -// you can also pass an array instead -// var untar = pumpify([zlib.createGunzip(), tar.extract('output-folder')]) - -fs.createReadStream('some-gzipped-tarball.tgz').pipe(untar) -``` - -If you are pumping object streams together use `pipeline = pumpify.obj(s1, s2, ...)`. -Call `pipeline.destroy()` to destroy the pipeline (including the streams passed to pumpify). - -### Using `setPipeline(s1, s2, ...)` - -Similar to [duplexify](https://github.com/mafintosh/duplexify) you can also define the pipeline asynchronously using `setPipeline(s1, s2, ...)` - -``` js -var untar = pumpify() - -setTimeout(function() { - // will start draining the input now - untar.setPipeline(zlib.createGunzip(), tar.extract('output-folder')) -}, 1000) - -fs.createReadStream('some-gzipped-tarball.tgz').pipe(untar) -``` - -## License - -MIT - -## Related - -`pumpify` 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/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/index.js b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/index.js deleted file mode 100644 index 45bb987e85..0000000000 --- a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/index.js +++ /dev/null @@ -1,56 +0,0 @@ -var pump = require('pump') -var inherits = require('inherits') -var Duplexify = require('duplexify') - -var toArray = function(args) { - if (!args.length) return [] - return Array.isArray(args[0]) ? args[0] : Array.prototype.slice.call(args) -} - -var define = function(opts) { - var Pumpify = function() { - var streams = toArray(arguments) - if (!(this instanceof Pumpify)) return new Pumpify(streams) - Duplexify.call(this, null, null, opts) - if (streams.length) this.setPipeline(streams) - } - - inherits(Pumpify, Duplexify) - - Pumpify.prototype.setPipeline = function() { - var streams = toArray(arguments) - var self = this - var ended = false - var w = streams[0] - var r = streams[streams.length-1] - - r = r.readable ? r : null - w = w.writable ? w : null - - var onclose = function() { - streams[0].emit('error', new Error('stream was destroyed')) - } - - this.on('close', onclose) - this.on('prefinish', function() { - if (!ended) self.cork() - }) - - pump(streams, function(err) { - self.removeListener('close', onclose) - if (err) return self.destroy(err) - ended = true - self.uncork() - }) - - if (this.destroyed) return onclose() - this.setWritable(w) - this.setReadable(r) - } - - return Pumpify -} - -module.exports = define({destroy:false}) -module.exports.obj = define({destroy:false, objectMode:true, highWaterMark:16}) -module.exports.ctor = define diff --git a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/.travis.yml b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/.travis.yml deleted file mode 100644 index 17f94330e7..0000000000 --- a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: node_js -node_js: - - "0.10" - -script: "npm test" diff --git a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/LICENSE b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/LICENSE deleted file mode 100644 index 757562ec59..0000000000 --- a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -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/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/README.md b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/README.md deleted file mode 100644 index 5029b27d68..0000000000 --- a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# pump - -pump is a small node module that pipes streams together and destroys all of them if one of them closes. - -``` -npm install pump -``` - -[![build status](http://img.shields.io/travis/mafintosh/pump.svg?style=flat)](http://travis-ci.org/mafintosh/pump) - -## What problem does it solve? - -When using standard `source.pipe(dest)` source will _not_ be destroyed if dest emits close or an error. -You are also not able to provide a callback to tell when then pipe has finished. - -pump does these two things for you - -## Usage - -Simply pass the streams you want to pipe together to pump and add an optional callback - -``` js -var pump = require('pump') -var fs = require('fs') - -var source = fs.createReadStream('/dev/random') -var dest = fs.createWriteStream('/dev/null') - -pump(source, dest, function(err) { - console.log('pipe finished', err) -}) - -setTimeout(function() { - dest.destroy() // when dest is closed pump will destroy source -}, 1000) -``` - -You can use pump to pipe more than two streams together as well - -``` js -var transform = someTransformStream() - -pump(source, transform, anotherTransform, dest, function(err) { - console.log('pipe finished', err) -}) -``` - -If `source`, `transform`, `anotherTransform` or `dest` closes all of them will be destroyed. - -## License - -MIT - -## Related - -`pump` 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/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/index.js b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/index.js deleted file mode 100644 index d9ca0335cb..0000000000 --- a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/index.js +++ /dev/null @@ -1,82 +0,0 @@ -var once = require('once') -var eos = require('end-of-stream') -var fs = require('fs') // we only need fs to get the ReadStream and WriteStream prototypes - -var noop = function () {} -var ancient = /^v?\.0/.test(process.version) - -var isFn = function (fn) { - return typeof fn === 'function' -} - -var isFS = function (stream) { - if (!ancient) return false // newer node version do not need to care about fs is a special way - if (!fs) return false // browser - return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close) -} - -var isRequest = function (stream) { - return stream.setHeader && isFn(stream.abort) -} - -var destroyer = function (stream, reading, writing, callback) { - callback = once(callback) - - var closed = false - stream.on('close', function () { - closed = true - }) - - eos(stream, {readable: reading, writable: writing}, function (err) { - if (err) return callback(err) - closed = true - callback() - }) - - var destroyed = false - return function (err) { - if (closed) return - if (destroyed) return - destroyed = true - - if (isFS(stream)) return stream.close(noop) // use close for fs streams to avoid fd leaks - if (isRequest(stream)) return stream.abort() // request.destroy just do .end - .abort is what we want - - if (isFn(stream.destroy)) return stream.destroy() - - callback(err || new Error('stream was destroyed')) - } -} - -var call = function (fn) { - fn() -} - -var pipe = function (from, to) { - return from.pipe(to) -} - -var pump = function () { - var streams = Array.prototype.slice.call(arguments) - var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop - - if (Array.isArray(streams[0])) streams = streams[0] - if (streams.length < 2) throw new Error('pump requires two streams per minimum') - - var error - var destroys = streams.map(function (stream, i) { - var reading = i < streams.length - 1 - var writing = i > 0 - return destroyer(stream, reading, writing, function (err) { - if (!error) error = err - if (err) destroys.forEach(call) - if (reading) return - destroys.forEach(call) - callback(error) - }) - }) - - streams.reduce(pipe) -} - -module.exports = pump diff --git a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/package.json b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/package.json deleted file mode 100644 index d17c2429c4..0000000000 --- a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "_from": "pump@^2.0.0", - "_id": "pump@2.0.1", - "_inBundle": false, - "_integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", - "_location": "/pacote/make-fetch-happen/mississippi/pumpify/pump", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "pump@^2.0.0", - "name": "pump", - "escapedName": "pump", - "rawSpec": "^2.0.0", - "saveSpec": null, - "fetchSpec": "^2.0.0" - }, - "_requiredBy": [ - "/pacote/make-fetch-happen/mississippi/pumpify" - ], - "_resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", - "_shasum": "12399add6e4cf7526d973cbc8b5ce2e2908b3909", - "_spec": "pump@^2.0.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify", - "author": { - "name": "Mathias Buus Madsen", - "email": "mathiasbuus@gmail.com" - }, - "browser": { - "fs": false - }, - "bugs": { - "url": "https://github.com/mafintosh/pump/issues" - }, - "bundleDependencies": false, - "dependencies": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - }, - "deprecated": false, - "description": "pipe streams together and close all of them if one of them closes", - "homepage": "https://github.com/mafintosh/pump#readme", - "keywords": [ - "streams", - "pipe", - "destroy", - "callback" - ], - "license": "MIT", - "name": "pump", - "repository": { - "type": "git", - "url": "git://github.com/mafintosh/pump.git" - }, - "scripts": { - "test": "node test-browser.js && node test-node.js" - }, - "version": "2.0.1" -} diff --git a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/test-browser.js b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/test-browser.js deleted file mode 100644 index 75ea4a292e..0000000000 --- a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/test-browser.js +++ /dev/null @@ -1,62 +0,0 @@ -var stream = require('stream') -var pump = require('./index') - -var rs = new stream.Readable() -var ws = new stream.Writable() - -rs._read = function (size) { - this.push(Buffer(size).fill('abc')) -} - -ws._write = function (chunk, encoding, cb) { - setTimeout(function () { - cb() - }, 100) -} - -var toHex = function () { - var reverse = new (require('stream').Transform)() - - reverse._transform = function (chunk, enc, callback) { - reverse.push(chunk.toString('hex')) - callback() - } - - return reverse -} - -var wsClosed = false -var rsClosed = false -var callbackCalled = false - -var check = function () { - if (wsClosed && rsClosed && callbackCalled) { - console.log('test-browser.js passes') - clearTimeout(timeout) - } -} - -ws.on('finish', function () { - wsClosed = true - check() -}) - -rs.on('end', function () { - rsClosed = true - check() -}) - -pump(rs, toHex(), toHex(), toHex(), ws, function () { - callbackCalled = true - check() -}) - -setTimeout(function () { - rs.push(null) - rs.emit('close') -}, 1000) - -var timeout = setTimeout(function () { - check() - throw new Error('timeout') -}, 5000) diff --git a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/test-node.js b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/test-node.js deleted file mode 100644 index 034a65414d..0000000000 --- a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/node_modules/pump/test-node.js +++ /dev/null @@ -1,53 +0,0 @@ -var pump = require('./index') - -var rs = require('fs').createReadStream('/dev/random') -var ws = require('fs').createWriteStream('/dev/null') - -var toHex = function () { - var reverse = new (require('stream').Transform)() - - reverse._transform = function (chunk, enc, callback) { - reverse.push(chunk.toString('hex')) - callback() - } - - return reverse -} - -var wsClosed = false -var rsClosed = false -var callbackCalled = false - -var check = function () { - if (wsClosed && rsClosed && callbackCalled) { - console.log('test-node.js passes') - clearTimeout(timeout) - } -} - -ws.on('close', function () { - wsClosed = true - check() -}) - -rs.on('close', function () { - rsClosed = true - check() -}) - -var res = pump(rs, toHex(), toHex(), toHex(), ws, function () { - callbackCalled = true - check() -}) - -if (res) { - process.exit(1) -} - -setTimeout(function () { - rs.destroy() -}, 1000) - -var timeout = setTimeout(function () { - throw new Error('timeout') -}, 5000) diff --git a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/package.json b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/package.json deleted file mode 100644 index 36f52a8817..0000000000 --- a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "_from": "pumpify@^1.3.3", - "_id": "pumpify@1.4.0", - "_inBundle": false, - "_integrity": "sha512-2kmNR9ry+Pf45opRVirpNuIFotsxUGLaYqxIwuR77AYrYRMuFCz9eryHBS52L360O+NcR383CL4QYlMKPq4zYA==", - "_location": "/pacote/make-fetch-happen/mississippi/pumpify", - "_phantomChildren": { - "end-of-stream": "1.4.1", - "once": "1.4.0" - }, - "_requested": { - "type": "range", - "registry": true, - "raw": "pumpify@^1.3.3", - "name": "pumpify", - "escapedName": "pumpify", - "rawSpec": "^1.3.3", - "saveSpec": null, - "fetchSpec": "^1.3.3" - }, - "_requiredBy": [ - "/pacote/make-fetch-happen/mississippi" - ], - "_resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.4.0.tgz", - "_shasum": "80b7c5df7e24153d03f0e7ac8a05a5d068bd07fb", - "_spec": "pumpify@^1.3.3", - "_where": "/Users/zkat/Documents/code/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi", - "author": { - "name": "Mathias Buus" - }, - "bugs": { - "url": "https://github.com/mafintosh/pumpify/issues" - }, - "bundleDependencies": false, - "dependencies": { - "duplexify": "^3.5.3", - "inherits": "^2.0.3", - "pump": "^2.0.0" - }, - "deprecated": false, - "description": "Combine an array of streams into a single duplex stream using pump and duplexify", - "devDependencies": { - "tape": "^4.8.0", - "through2": "^2.0.3" - }, - "homepage": "https://github.com/mafintosh/pumpify", - "keywords": [ - "pump", - "duplexify", - "duplex", - "streams", - "stream", - "pipeline", - "combine" - ], - "license": "MIT", - "main": "index.js", - "name": "pumpify", - "repository": { - "type": "git", - "url": "git://github.com/mafintosh/pumpify.git" - }, - "scripts": { - "test": "tape test.js" - }, - "version": "1.4.0" -} diff --git a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/test.js b/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/test.js deleted file mode 100644 index de6b16e346..0000000000 --- a/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/pumpify/test.js +++ /dev/null @@ -1,181 +0,0 @@ -var tape = require('tape') -var through = require('through2') -var pumpify = require('./') -var stream = require('stream') - -tape('basic', function(t) { - t.plan(3) - - var pipeline = pumpify( - through(function(data, enc, cb) { - t.same(data.toString(), 'hello') - cb(null, data.toString().toUpperCase()) - }), - through(function(data, enc, cb) { - t.same(data.toString(), 'HELLO') - cb(null, data.toString().toLowerCase()) - }) - ) - - pipeline.write('hello') - pipeline.on('data', function(data) { - t.same(data.toString(), 'hello') - t.end() - }) -}) - -tape('3 times', function(t) { - t.plan(4) - - var pipeline = pumpify( - through(function(data, enc, cb) { - t.same(data.toString(), 'hello') - cb(null, data.toString().toUpperCase()) - }), - through(function(data, enc, cb) { - t.same(data.toString(), 'HELLO') - cb(null, data.toString().toLowerCase()) - }), - through(function(data, enc, cb) { - t.same(data.toString(), 'hello') - cb(null, data.toString().toUpperCase()) - }) - ) - - pipeline.write('hello') - pipeline.on('data', function(data) { - t.same(data.toString(), 'HELLO') - t.end() - }) -}) - -tape('destroy', function(t) { - var test = through() - test.destroy = function() { - t.ok(true) - t.end() - } - - var pipeline = pumpify(through(), test) - - pipeline.destroy() -}) - -tape('close', function(t) { - var test = through() - var pipeline = pumpify(through(), test) - - pipeline.on('error', function(err) { - t.same(err.message, 'lol') - t.end() - }) - - test.emit('error', new Error('lol')) -}) - -tape('end waits for last one', function(t) { - var ran = false - - var a = through() - var b = through() - var c = through(function(data, enc, cb) { - setTimeout(function() { - ran = true - cb() - }, 100) - }) - - var pipeline = pumpify(a, b, c) - - pipeline.write('foo') - pipeline.end(function() { - t.ok(ran) - t.end() - }) - - t.ok(!ran) -}) - -tape('always wait for finish', function(t) { - var a = new stream.Readable() - a._read = function() {} - a.push('hello') - - var pipeline = pumpify(a, through(), through()) - var ran = false - - pipeline.on('finish', function() { - t.ok(ran) - t.end() - }) - - setTimeout(function() { - ran = true - a.push(null) - }, 100) -}) - -tape('async', function(t) { - var pipeline = pumpify() - - t.plan(4) - - pipeline.write('hello') - pipeline.on('data', function(data) { - t.same(data.toString(), 'HELLO') - t.end() - }) - - setTimeout(function() { - pipeline.setPipeline( - through(function(data, enc, cb) { - t.same(data.toString(), 'hello') - cb(null, data.toString().toUpperCase()) - }), - through(function(data, enc, cb) { - t.same(data.toString(), 'HELLO') - cb(null, data.toString().toLowerCase()) - }), - through(function(data, enc, cb) { - t.same(data.toString(), 'hello') - cb(null, data.toString().toUpperCase()) - }) - ) - }, 100) -}) - -tape('early destroy', function(t) { - var a = through() - var b = through() - var c = through() - - b.destroy = function() { - t.ok(true) - t.end() - } - - var pipeline = pumpify() - - pipeline.destroy() - setTimeout(function() { - pipeline.setPipeline(a, b, c) - }, 100) -}) - -tape('preserves error', function (t) { - var a = through() - var b = through(function (data, enc, cb) { - cb(new Error('stop')) - }) - var c = through() - var s = pumpify() - - s.on('error', function (err) { - t.same(err.message, 'stop') - t.end() - }) - - s.setPipeline(a, b, c) - s.resume() - s.write('hi') -}) |