aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify')
-rw-r--r--deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/.travis.yml8
-rw-r--r--deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/LICENSE21
-rw-r--r--deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/README.md56
-rw-r--r--deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/index.js56
-rw-r--r--deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/package.json64
-rw-r--r--deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/test.js181
6 files changed, 386 insertions, 0 deletions
diff --git a/deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/.travis.yml b/deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/.travis.yml
new file mode 100644
index 0000000000..32e71a6b55
--- /dev/null
+++ b/deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/.travis.yml
@@ -0,0 +1,8 @@
+language: node_js
+
+node_js:
+ - "0.10"
+ - "4"
+ - "5"
+
+sudo: false
diff --git a/deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/LICENSE b/deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/LICENSE
new file mode 100644
index 0000000000..757562ec59
--- /dev/null
+++ b/deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/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/deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/README.md b/deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/README.md
new file mode 100644
index 0000000000..4988f7b126
--- /dev/null
+++ b/deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/README.md
@@ -0,0 +1,56 @@
+# 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/cacache/node_modules/mississippi/node_modules/pumpify/index.js b/deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/index.js
new file mode 100644
index 0000000000..45bb987e85
--- /dev/null
+++ b/deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/index.js
@@ -0,0 +1,56 @@
+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/cacache/node_modules/mississippi/node_modules/pumpify/package.json b/deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/package.json
new file mode 100644
index 0000000000..a678869bc1
--- /dev/null
+++ b/deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/package.json
@@ -0,0 +1,64 @@
+{
+ "_from": "pumpify@^1.3.3",
+ "_id": "pumpify@1.4.0",
+ "_inBundle": false,
+ "_integrity": "sha512-2kmNR9ry+Pf45opRVirpNuIFotsxUGLaYqxIwuR77AYrYRMuFCz9eryHBS52L360O+NcR383CL4QYlMKPq4zYA==",
+ "_location": "/cacache/mississippi/pumpify",
+ "_phantomChildren": {},
+ "_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": [
+ "/cacache/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/cacache/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/cacache/node_modules/mississippi/node_modules/pumpify/test.js b/deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/test.js
new file mode 100644
index 0000000000..de6b16e346
--- /dev/null
+++ b/deps/npm/node_modules/cacache/node_modules/mississippi/node_modules/pumpify/test.js
@@ -0,0 +1,181 @@
+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')
+})