mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-17 01:16:00 +00:00
Modules
This commit is contained in:
7
node_modules/pumpify/.travis.yml
generated
vendored
Normal file
7
node_modules/pumpify/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- '10'
|
||||
- '12'
|
||||
|
||||
sudo: false
|
21
node_modules/pumpify/LICENSE
generated
vendored
Normal file
21
node_modules/pumpify/LICENSE
generated
vendored
Normal file
@ -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.
|
56
node_modules/pumpify/README.md
generated
vendored
Normal file
56
node_modules/pumpify/README.md
generated
vendored
Normal file
@ -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
|
||||
```
|
||||
|
||||
[](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.
|
60
node_modules/pumpify/index.js
generated
vendored
Normal file
60
node_modules/pumpify/index.js
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
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.message === 'premature close' ? null : err)
|
||||
ended = true
|
||||
// pump ends after the last stream is not writable *but*
|
||||
// pumpify still forwards the readable part so we need to catch errors
|
||||
// still, so reenable autoDestroy in this case
|
||||
if (self._autoDestroy === false) self._autoDestroy = true
|
||||
self.uncork()
|
||||
})
|
||||
|
||||
if (this.destroyed) return onclose()
|
||||
this.setWritable(w)
|
||||
this.setReadable(r)
|
||||
}
|
||||
|
||||
return Pumpify
|
||||
}
|
||||
|
||||
module.exports = define({autoDestroy:false, destroy:false})
|
||||
module.exports.obj = define({autoDestroy: false, destroy:false, objectMode:true, highWaterMark:16})
|
||||
module.exports.ctor = define
|
6
node_modules/pumpify/node_modules/duplexify/.travis.yml
generated
vendored
Normal file
6
node_modules/pumpify/node_modules/duplexify/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "4"
|
||||
- "6"
|
||||
- "8"
|
||||
- "10"
|
21
node_modules/pumpify/node_modules/duplexify/LICENSE
generated
vendored
Normal file
21
node_modules/pumpify/node_modules/duplexify/LICENSE
generated
vendored
Normal file
@ -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.
|
97
node_modules/pumpify/node_modules/duplexify/README.md
generated
vendored
Normal file
97
node_modules/pumpify/node_modules/duplexify/README.md
generated
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
# duplexify
|
||||
|
||||
Turn a writeable and readable stream into a single streams2 duplex stream.
|
||||
|
||||
Similar to [duplexer2](https://github.com/deoxxa/duplexer2) except it supports both streams2 and streams1 as input
|
||||
and it allows you to set the readable and writable part asynchronously using `setReadable(stream)` and `setWritable(stream)`
|
||||
|
||||
```
|
||||
npm install duplexify
|
||||
```
|
||||
|
||||
[](http://travis-ci.org/mafintosh/duplexify)
|
||||
|
||||
## Usage
|
||||
|
||||
Use `duplexify(writable, readable, streamOptions)` (or `duplexify.obj(writable, readable)` to create an object stream)
|
||||
|
||||
``` js
|
||||
var duplexify = require('duplexify')
|
||||
|
||||
// turn writableStream and readableStream into a single duplex stream
|
||||
var dup = duplexify(writableStream, readableStream)
|
||||
|
||||
dup.write('hello world') // will write to writableStream
|
||||
dup.on('data', function(data) {
|
||||
// will read from readableStream
|
||||
})
|
||||
```
|
||||
|
||||
You can also set the readable and writable parts asynchronously
|
||||
|
||||
``` js
|
||||
var dup = duplexify()
|
||||
|
||||
dup.write('hello world') // write will buffer until the writable
|
||||
// part has been set
|
||||
|
||||
// wait a bit ...
|
||||
dup.setReadable(readableStream)
|
||||
|
||||
// maybe wait some more?
|
||||
dup.setWritable(writableStream)
|
||||
```
|
||||
|
||||
If you call `setReadable` or `setWritable` multiple times it will unregister the previous readable/writable stream.
|
||||
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
|
||||
error object as argument, in which case the error is emitted as part of the `error` event.
|
||||
|
||||
``` js
|
||||
dup.on('error', function(err) {
|
||||
console.log('readable or writable emitted an error - close will follow')
|
||||
})
|
||||
|
||||
dup.on('close', function() {
|
||||
console.log('the duplex stream is destroyed')
|
||||
})
|
||||
|
||||
dup.destroy() // calls destroy on the readable and writable part (if present)
|
||||
```
|
||||
|
||||
## HTTP request example
|
||||
|
||||
Turn a node core http request into a duplex stream is as easy as
|
||||
|
||||
``` js
|
||||
var duplexify = require('duplexify')
|
||||
var http = require('http')
|
||||
|
||||
var request = function(opts) {
|
||||
var req = http.request(opts)
|
||||
var dup = duplexify(req)
|
||||
req.on('response', function(res) {
|
||||
dup.setReadable(res)
|
||||
})
|
||||
return dup
|
||||
}
|
||||
|
||||
var req = request({
|
||||
method: 'GET',
|
||||
host: 'www.google.com',
|
||||
port: 80
|
||||
})
|
||||
|
||||
req.end()
|
||||
req.pipe(process.stdout)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
## Related
|
||||
|
||||
`duplexify` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one.
|
21
node_modules/pumpify/node_modules/duplexify/example.js
generated
vendored
Normal file
21
node_modules/pumpify/node_modules/duplexify/example.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
var duplexify = require('duplexify')
|
||||
var http = require('http')
|
||||
|
||||
var request = function(opts) {
|
||||
var req = http.request(opts)
|
||||
var dup = duplexify()
|
||||
dup.setWritable(req)
|
||||
req.on('response', function(res) {
|
||||
dup.setReadable(res)
|
||||
})
|
||||
return dup
|
||||
}
|
||||
|
||||
var req = request({
|
||||
method: 'GET',
|
||||
host: 'www.google.com',
|
||||
port: 80
|
||||
})
|
||||
|
||||
req.end()
|
||||
req.pipe(process.stdout)
|
238
node_modules/pumpify/node_modules/duplexify/index.js
generated
vendored
Normal file
238
node_modules/pumpify/node_modules/duplexify/index.js
generated
vendored
Normal file
@ -0,0 +1,238 @@
|
||||
var stream = require('readable-stream')
|
||||
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 onuncork = function(self, fn) {
|
||||
if (self._corked) self.once('uncork', fn)
|
||||
else fn()
|
||||
}
|
||||
|
||||
var autoDestroy = function (self, err) {
|
||||
if (self._autoDestroy) self.destroy(err)
|
||||
}
|
||||
|
||||
var destroyer = function(self, end) {
|
||||
return function(err) {
|
||||
if (err) autoDestroy(self, err.message === 'premature close' ? null : err)
|
||||
else if (end && !self._ended) self.end()
|
||||
}
|
||||
}
|
||||
|
||||
var end = function(ws, fn) {
|
||||
if (!ws) return fn()
|
||||
if (ws._writableState && ws._writableState.finished) return fn()
|
||||
if (ws._writableState) return ws.end(fn)
|
||||
ws.end()
|
||||
fn()
|
||||
}
|
||||
|
||||
var noop = function() {}
|
||||
|
||||
var toStreams2 = function(rs) {
|
||||
return new (stream.Readable)({objectMode:true, highWaterMark:16}).wrap(rs)
|
||||
}
|
||||
|
||||
var Duplexify = function(writable, readable, opts) {
|
||||
if (!(this instanceof Duplexify)) return new Duplexify(writable, readable, opts)
|
||||
stream.Duplex.call(this, opts)
|
||||
|
||||
this._writable = null
|
||||
this._readable = null
|
||||
this._readable2 = null
|
||||
|
||||
this._autoDestroy = !opts || opts.autoDestroy !== false
|
||||
this._forwardDestroy = !opts || opts.destroy !== false
|
||||
this._forwardEnd = !opts || opts.end !== false
|
||||
this._corked = 1 // start corked
|
||||
this._ondrain = null
|
||||
this._drained = false
|
||||
this._forwarding = false
|
||||
this._unwrite = null
|
||||
this._unread = null
|
||||
this._ended = false
|
||||
|
||||
this.destroyed = false
|
||||
|
||||
if (writable) this.setWritable(writable)
|
||||
if (readable) this.setReadable(readable)
|
||||
}
|
||||
|
||||
inherits(Duplexify, stream.Duplex)
|
||||
|
||||
Duplexify.obj = function(writable, readable, opts) {
|
||||
if (!opts) opts = {}
|
||||
opts.objectMode = true
|
||||
opts.highWaterMark = 16
|
||||
return new Duplexify(writable, readable, opts)
|
||||
}
|
||||
|
||||
Duplexify.prototype.cork = function() {
|
||||
if (++this._corked === 1) this.emit('cork')
|
||||
}
|
||||
|
||||
Duplexify.prototype.uncork = function() {
|
||||
if (this._corked && --this._corked === 0) this.emit('uncork')
|
||||
}
|
||||
|
||||
Duplexify.prototype.setWritable = function(writable) {
|
||||
if (this._unwrite) this._unwrite()
|
||||
|
||||
if (this.destroyed) {
|
||||
if (writable && writable.destroy) writable.destroy()
|
||||
return
|
||||
}
|
||||
|
||||
if (writable === null || writable === false) {
|
||||
this.end()
|
||||
return
|
||||
}
|
||||
|
||||
var self = this
|
||||
var unend = eos(writable, {writable:true, readable:false}, destroyer(this, this._forwardEnd))
|
||||
|
||||
var ondrain = function() {
|
||||
var ondrain = self._ondrain
|
||||
self._ondrain = null
|
||||
if (ondrain) ondrain()
|
||||
}
|
||||
|
||||
var clear = function() {
|
||||
self._writable.removeListener('drain', ondrain)
|
||||
unend()
|
||||
}
|
||||
|
||||
if (this._unwrite) process.nextTick(ondrain) // force a drain on stream reset to avoid livelocks
|
||||
|
||||
this._writable = writable
|
||||
this._writable.on('drain', ondrain)
|
||||
this._unwrite = clear
|
||||
|
||||
this.uncork() // always uncork setWritable
|
||||
}
|
||||
|
||||
Duplexify.prototype.setReadable = function(readable) {
|
||||
if (this._unread) this._unread()
|
||||
|
||||
if (this.destroyed) {
|
||||
if (readable && readable.destroy) readable.destroy()
|
||||
return
|
||||
}
|
||||
|
||||
if (readable === null || readable === false) {
|
||||
this.push(null)
|
||||
this.resume()
|
||||
return
|
||||
}
|
||||
|
||||
var self = this
|
||||
var unend = eos(readable, {writable:false, readable:true}, destroyer(this))
|
||||
|
||||
var onreadable = function() {
|
||||
self._forward()
|
||||
}
|
||||
|
||||
var onend = function() {
|
||||
self.push(null)
|
||||
}
|
||||
|
||||
var clear = function() {
|
||||
self._readable2.removeListener('readable', onreadable)
|
||||
self._readable2.removeListener('end', onend)
|
||||
unend()
|
||||
}
|
||||
|
||||
this._drained = true
|
||||
this._readable = readable
|
||||
this._readable2 = readable._readableState ? readable : toStreams2(readable)
|
||||
this._readable2.on('readable', onreadable)
|
||||
this._readable2.on('end', onend)
|
||||
this._unread = clear
|
||||
|
||||
this._forward()
|
||||
}
|
||||
|
||||
Duplexify.prototype._read = function() {
|
||||
this._drained = true
|
||||
this._forward()
|
||||
}
|
||||
|
||||
Duplexify.prototype._forward = function() {
|
||||
if (this._forwarding || !this._readable2 || !this._drained) return
|
||||
this._forwarding = true
|
||||
|
||||
var data
|
||||
|
||||
while (this._drained && (data = shift(this._readable2)) !== null) {
|
||||
if (this.destroyed) continue
|
||||
this._drained = this.push(data)
|
||||
}
|
||||
|
||||
this._forwarding = false
|
||||
}
|
||||
|
||||
Duplexify.prototype.destroy = function(err, cb) {
|
||||
if (!cb) cb = noop
|
||||
if (this.destroyed) return cb(null)
|
||||
this.destroyed = true
|
||||
|
||||
var self = this
|
||||
process.nextTick(function() {
|
||||
self._destroy(err)
|
||||
cb(null)
|
||||
})
|
||||
}
|
||||
|
||||
Duplexify.prototype._destroy = function(err) {
|
||||
if (err) {
|
||||
var ondrain = this._ondrain
|
||||
this._ondrain = null
|
||||
if (ondrain) ondrain(err)
|
||||
else this.emit('error', err)
|
||||
}
|
||||
|
||||
if (this._forwardDestroy) {
|
||||
if (this._readable && this._readable.destroy) this._readable.destroy()
|
||||
if (this._writable && this._writable.destroy) this._writable.destroy()
|
||||
}
|
||||
|
||||
this.emit('close')
|
||||
}
|
||||
|
||||
Duplexify.prototype._write = function(data, enc, cb) {
|
||||
if (this.destroyed) return
|
||||
if (this._corked) return onuncork(this, this._write.bind(this, data, enc, cb))
|
||||
if (data === SIGNAL_FLUSH) return this._finish(cb)
|
||||
if (!this._writable) return cb()
|
||||
|
||||
if (this._writable.write(data) === false) this._ondrain = cb
|
||||
else if (!this.destroyed) cb()
|
||||
}
|
||||
|
||||
Duplexify.prototype._finish = function(cb) {
|
||||
var self = this
|
||||
this.emit('preend')
|
||||
onuncork(this, function() {
|
||||
end(self._forwardEnd && self._writable, function() {
|
||||
// haxx to not emit prefinish twice
|
||||
if (self._writableState.prefinished === false) self._writableState.prefinished = true
|
||||
self.emit('prefinish')
|
||||
onuncork(self, cb)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Duplexify.prototype.end = function(data, enc, cb) {
|
||||
if (typeof data === 'function') return this.end(null, null, data)
|
||||
if (typeof enc === 'function') return this.end(data, null, enc)
|
||||
this._ended = true
|
||||
if (data) this.write(data)
|
||||
if (!this._writableState.ending) this.write(SIGNAL_FLUSH)
|
||||
return stream.Writable.prototype.end.call(this, cb)
|
||||
}
|
||||
|
||||
module.exports = Duplexify
|
70
node_modules/pumpify/node_modules/duplexify/package.json
generated
vendored
Normal file
70
node_modules/pumpify/node_modules/duplexify/package.json
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"duplexify@4.1.1",
|
||||
"C:\\Users\\matia\\Musix"
|
||||
]
|
||||
],
|
||||
"_from": "duplexify@4.1.1",
|
||||
"_id": "duplexify@4.1.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-DY3xVEmVHTv1wSzKNbwoU6nVjzI369Y6sPoqfYr0/xlx3IdX2n94xIszTcjPO8W8ZIv0Wb0PXNcjuZyT4wiICA==",
|
||||
"_location": "/pumpify/duplexify",
|
||||
"_optional": true,
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "duplexify@4.1.1",
|
||||
"name": "duplexify",
|
||||
"escapedName": "duplexify",
|
||||
"rawSpec": "4.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "4.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/pumpify"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/duplexify/-/duplexify-4.1.1.tgz",
|
||||
"_spec": "4.1.1",
|
||||
"_where": "C:\\Users\\matia\\Musix",
|
||||
"author": {
|
||||
"name": "Mathias Buus"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mafintosh/duplexify/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"end-of-stream": "^1.4.1",
|
||||
"inherits": "^2.0.3",
|
||||
"readable-stream": "^3.1.1",
|
||||
"stream-shift": "^1.0.0"
|
||||
},
|
||||
"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"
|
||||
},
|
||||
"homepage": "https://github.com/mafintosh/duplexify",
|
||||
"keywords": [
|
||||
"duplex",
|
||||
"streams2",
|
||||
"streams",
|
||||
"stream",
|
||||
"writable",
|
||||
"readable",
|
||||
"async"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "duplexify",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/mafintosh/duplexify.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tape test.js"
|
||||
},
|
||||
"version": "4.1.1"
|
||||
}
|
338
node_modules/pumpify/node_modules/duplexify/test.js
generated
vendored
Normal file
338
node_modules/pumpify/node_modules/duplexify/test.js
generated
vendored
Normal file
@ -0,0 +1,338 @@
|
||||
var tape = require('tape')
|
||||
var through = require('through2')
|
||||
var concat = require('concat-stream')
|
||||
var stream = require('readable-stream')
|
||||
var net = require('net')
|
||||
var duplexify = require('./')
|
||||
|
||||
var HELLO_WORLD = (Buffer.from && Buffer.from !== Uint8Array.from)
|
||||
? Buffer.from('hello world')
|
||||
: new Buffer('hello world')
|
||||
|
||||
tape('passthrough', function(t) {
|
||||
t.plan(2)
|
||||
|
||||
var pt = through()
|
||||
var dup = duplexify(pt, pt)
|
||||
|
||||
dup.end('hello world')
|
||||
dup.on('finish', function() {
|
||||
t.ok(true, 'should finish')
|
||||
})
|
||||
dup.pipe(concat(function(data) {
|
||||
t.same(data.toString(), 'hello world', 'same in as out')
|
||||
}))
|
||||
})
|
||||
|
||||
tape('passthrough + double end', function(t) {
|
||||
t.plan(2)
|
||||
|
||||
var pt = through()
|
||||
var dup = duplexify(pt, pt)
|
||||
|
||||
dup.end('hello world')
|
||||
dup.end()
|
||||
|
||||
dup.on('finish', function() {
|
||||
t.ok(true, 'should finish')
|
||||
})
|
||||
dup.pipe(concat(function(data) {
|
||||
t.same(data.toString(), 'hello world', 'same in as out')
|
||||
}))
|
||||
})
|
||||
|
||||
tape('async passthrough + end', function(t) {
|
||||
t.plan(2)
|
||||
|
||||
var pt = through.obj({highWaterMark:1}, function(data, enc, cb) {
|
||||
setTimeout(function() {
|
||||
cb(null, data)
|
||||
}, 100)
|
||||
})
|
||||
|
||||
var dup = duplexify(pt, pt)
|
||||
|
||||
dup.write('hello ')
|
||||
dup.write('world')
|
||||
dup.end()
|
||||
|
||||
dup.on('finish', function() {
|
||||
t.ok(true, 'should finish')
|
||||
})
|
||||
dup.pipe(concat(function(data) {
|
||||
t.same(data.toString(), 'hello world', 'same in as out')
|
||||
}))
|
||||
})
|
||||
|
||||
tape('duplex', function(t) {
|
||||
var readExpected = ['read-a', 'read-b', 'read-c']
|
||||
var writeExpected = ['write-a', 'write-b', 'write-c']
|
||||
|
||||
t.plan(readExpected.length+writeExpected.length+2)
|
||||
|
||||
var readable = through.obj()
|
||||
var writable = through.obj(function(data, enc, cb) {
|
||||
t.same(data, writeExpected.shift(), 'onwrite should match')
|
||||
cb()
|
||||
})
|
||||
|
||||
var dup = duplexify.obj(writable, readable)
|
||||
|
||||
readExpected.slice().forEach(function(data) {
|
||||
readable.write(data)
|
||||
})
|
||||
readable.end()
|
||||
|
||||
writeExpected.slice().forEach(function(data) {
|
||||
dup.write(data)
|
||||
})
|
||||
dup.end()
|
||||
|
||||
dup.on('data', function(data) {
|
||||
t.same(data, readExpected.shift(), 'ondata should match')
|
||||
})
|
||||
dup.on('end', function() {
|
||||
t.ok(true, 'should end')
|
||||
})
|
||||
dup.on('finish', function() {
|
||||
t.ok(true, 'should finish')
|
||||
})
|
||||
})
|
||||
|
||||
tape('async', function(t) {
|
||||
var dup = duplexify()
|
||||
var pt = through()
|
||||
|
||||
dup.pipe(concat(function(data) {
|
||||
t.same(data.toString(), 'i was async', 'same in as out')
|
||||
t.end()
|
||||
}))
|
||||
|
||||
dup.write('i')
|
||||
dup.write(' was ')
|
||||
dup.end('async')
|
||||
|
||||
setTimeout(function() {
|
||||
dup.setWritable(pt)
|
||||
setTimeout(function() {
|
||||
dup.setReadable(pt)
|
||||
}, 50)
|
||||
}, 50)
|
||||
})
|
||||
|
||||
tape('destroy', function(t) {
|
||||
t.plan(2)
|
||||
|
||||
var write = through()
|
||||
var read = through()
|
||||
var dup = duplexify(write, read)
|
||||
|
||||
write.destroy = function() {
|
||||
t.ok(true, 'write destroyed')
|
||||
}
|
||||
|
||||
dup.on('close', function() {
|
||||
t.ok(true, 'close emitted')
|
||||
})
|
||||
|
||||
dup.destroy()
|
||||
dup.destroy() // should only work once
|
||||
})
|
||||
|
||||
tape('destroy both', function(t) {
|
||||
t.plan(3)
|
||||
|
||||
var write = through()
|
||||
var read = through()
|
||||
var dup = duplexify(write, read)
|
||||
|
||||
write.destroy = function() {
|
||||
t.ok(true, 'write destroyed')
|
||||
}
|
||||
|
||||
read.destroy = function() {
|
||||
t.ok(true, 'read destroyed')
|
||||
}
|
||||
|
||||
dup.on('close', function() {
|
||||
t.ok(true, 'close emitted')
|
||||
})
|
||||
|
||||
dup.destroy()
|
||||
dup.destroy() // should only work once
|
||||
})
|
||||
|
||||
tape('bubble read errors', function(t) {
|
||||
t.plan(2)
|
||||
|
||||
var write = through()
|
||||
var read = through()
|
||||
var dup = duplexify(write, read)
|
||||
|
||||
dup.on('error', function(err) {
|
||||
t.same(err.message, 'read-error', 'received read error')
|
||||
})
|
||||
dup.on('close', function() {
|
||||
t.ok(true, 'close emitted')
|
||||
})
|
||||
|
||||
read.emit('error', new Error('read-error'))
|
||||
write.emit('error', new Error('write-error')) // only emit first error
|
||||
})
|
||||
|
||||
tape('bubble write errors', function(t) {
|
||||
t.plan(2)
|
||||
|
||||
var write = through()
|
||||
var read = through()
|
||||
var dup = duplexify(write, read)
|
||||
|
||||
dup.on('error', function(err) {
|
||||
t.same(err.message, 'write-error', 'received write error')
|
||||
})
|
||||
dup.on('close', function() {
|
||||
t.ok(true, 'close emitted')
|
||||
})
|
||||
|
||||
write.emit('error', new Error('write-error'))
|
||||
read.emit('error', new Error('read-error')) // only emit first error
|
||||
})
|
||||
|
||||
tape('bubble errors from write()', function(t) {
|
||||
t.plan(3)
|
||||
|
||||
var errored = false
|
||||
var dup = duplexify(new stream.Writable({
|
||||
write: function(chunk, enc, next) {
|
||||
next(new Error('write-error'))
|
||||
}
|
||||
}))
|
||||
|
||||
dup.on('error', function(err) {
|
||||
errored = true
|
||||
t.same(err.message, 'write-error', 'received write error')
|
||||
})
|
||||
dup.on('close', function() {
|
||||
t.pass('close emitted')
|
||||
t.ok(errored, 'error was emitted before close')
|
||||
})
|
||||
dup.end('123')
|
||||
})
|
||||
|
||||
tape('destroy while waiting for drain', function(t) {
|
||||
t.plan(3)
|
||||
|
||||
var errored = false
|
||||
var dup = duplexify(new stream.Writable({
|
||||
highWaterMark: 0,
|
||||
write: function() {}
|
||||
}))
|
||||
|
||||
dup.on('error', function(err) {
|
||||
errored = true
|
||||
t.same(err.message, 'destroy-error', 'received destroy error')
|
||||
})
|
||||
dup.on('close', function() {
|
||||
t.pass('close emitted')
|
||||
t.ok(errored, 'error was emitted before close')
|
||||
})
|
||||
dup.write('123')
|
||||
dup.destroy(new Error('destroy-error'))
|
||||
})
|
||||
|
||||
tape('reset writable / readable', function(t) {
|
||||
t.plan(3)
|
||||
|
||||
var toUpperCase = function(data, enc, cb) {
|
||||
cb(null, data.toString().toUpperCase())
|
||||
}
|
||||
|
||||
var passthrough = through()
|
||||
var upper = through(toUpperCase)
|
||||
var dup = duplexify(passthrough, passthrough)
|
||||
|
||||
dup.once('data', function(data) {
|
||||
t.same(data.toString(), 'hello')
|
||||
dup.setWritable(upper)
|
||||
dup.setReadable(upper)
|
||||
dup.once('data', function(data) {
|
||||
t.same(data.toString(), 'HELLO')
|
||||
dup.once('data', function(data) {
|
||||
t.same(data.toString(), 'HI')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
dup.write('hello')
|
||||
dup.write('hi')
|
||||
})
|
||||
dup.write('hello')
|
||||
})
|
||||
|
||||
tape('cork', function(t) {
|
||||
var passthrough = through()
|
||||
var dup = duplexify(passthrough, passthrough)
|
||||
var ok = false
|
||||
|
||||
dup.on('prefinish', function() {
|
||||
dup.cork()
|
||||
setTimeout(function() {
|
||||
ok = true
|
||||
dup.uncork()
|
||||
}, 100)
|
||||
})
|
||||
dup.on('finish', function() {
|
||||
t.ok(ok)
|
||||
t.end()
|
||||
})
|
||||
dup.end()
|
||||
})
|
||||
|
||||
tape('prefinish not twice', function(t) {
|
||||
var passthrough = through()
|
||||
var dup = duplexify(passthrough, passthrough)
|
||||
var prefinished = false
|
||||
|
||||
dup.on('prefinish', function() {
|
||||
t.ok(!prefinished, 'only prefinish once')
|
||||
prefinished = true
|
||||
})
|
||||
|
||||
dup.on('finish', function() {
|
||||
t.end()
|
||||
})
|
||||
|
||||
dup.end()
|
||||
})
|
||||
|
||||
tape('close', function(t) {
|
||||
var passthrough = through()
|
||||
var dup = duplexify(passthrough, passthrough)
|
||||
|
||||
passthrough.emit('close')
|
||||
dup.on('close', function() {
|
||||
t.ok(true, 'should forward close')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
tape('works with node native streams (net)', function(t) {
|
||||
t.plan(1)
|
||||
|
||||
var server = net.createServer(function(socket) {
|
||||
var dup = duplexify(socket, socket)
|
||||
|
||||
dup.once('data', function(chunk) {
|
||||
t.same(chunk, HELLO_WORLD)
|
||||
server.close()
|
||||
socket.end()
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
server.listen(0, function () {
|
||||
var socket = net.connect(server.address().port)
|
||||
var dup = duplexify(socket, socket)
|
||||
|
||||
dup.write(HELLO_WORLD)
|
||||
})
|
||||
})
|
74
node_modules/pumpify/package.json
generated
vendored
Normal file
74
node_modules/pumpify/package.json
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"pumpify@2.0.1",
|
||||
"C:\\Users\\matia\\Musix"
|
||||
]
|
||||
],
|
||||
"_from": "pumpify@2.0.1",
|
||||
"_id": "pumpify@2.0.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-m7KOje7jZxrmutanlkS1daj1dS6z6BgslzOXmcSEpIlCxM3VJH7lG5QLeck/6hgF6F4crFf01UtQmNsJfweTAw==",
|
||||
"_location": "/pumpify",
|
||||
"_optional": true,
|
||||
"_phantomChildren": {
|
||||
"end-of-stream": "1.4.4",
|
||||
"inherits": "2.0.4",
|
||||
"stream-shift": "1.0.0",
|
||||
"util-deprecate": "1.0.2"
|
||||
},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "pumpify@2.0.1",
|
||||
"name": "pumpify",
|
||||
"escapedName": "pumpify",
|
||||
"rawSpec": "2.0.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.0.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@google-cloud/storage",
|
||||
"/gcs-resumable-upload"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/pumpify/-/pumpify-2.0.1.tgz",
|
||||
"_spec": "2.0.1",
|
||||
"_where": "C:\\Users\\matia\\Musix",
|
||||
"author": {
|
||||
"name": "Mathias Buus"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mafintosh/pumpify/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"duplexify": "^4.1.1",
|
||||
"inherits": "^2.0.3",
|
||||
"pump": "^3.0.0"
|
||||
},
|
||||
"description": "Combine an array of streams into a single duplex stream using pump and duplexify",
|
||||
"devDependencies": {
|
||||
"tape": "^4.10.2",
|
||||
"through2": "^3.0.1"
|
||||
},
|
||||
"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": "2.0.1"
|
||||
}
|
238
node_modules/pumpify/test.js
generated
vendored
Normal file
238
node_modules/pumpify/test.js
generated
vendored
Normal file
@ -0,0 +1,238 @@
|
||||
var tape = require('tape')
|
||||
var through = require('through2')
|
||||
var pumpify = require('./')
|
||||
var stream = require('stream')
|
||||
var duplexify = require('duplexify')
|
||||
|
||||
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')
|
||||
})
|
||||
|
||||
tape('preserves error again', function (t) {
|
||||
var ws = new stream.Writable()
|
||||
var rs = new stream.Readable({highWaterMark: 16})
|
||||
|
||||
ws._write = function (data, enc, cb) {
|
||||
cb(null)
|
||||
}
|
||||
|
||||
var once = true
|
||||
rs._read = function () {
|
||||
process.nextTick(function () {
|
||||
if (!once) return
|
||||
once = false
|
||||
rs.push('hello world')
|
||||
})
|
||||
}
|
||||
|
||||
var pumpifyErr = pumpify(
|
||||
through(),
|
||||
through(function(chunk, _, cb) {
|
||||
cb(new Error('test'))
|
||||
}),
|
||||
ws
|
||||
)
|
||||
|
||||
rs.pipe(pumpifyErr)
|
||||
.on('error', function (err) {
|
||||
t.ok(err)
|
||||
t.ok(err.message !== 'premature close', 'does not close with premature close')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
tape('returns error from duplexify', function (t) {
|
||||
var a = through()
|
||||
var b = duplexify()
|
||||
var s = pumpify()
|
||||
|
||||
s.setPipeline(a, b)
|
||||
|
||||
s.on('error', function (err) {
|
||||
t.same(err.message, 'stop')
|
||||
t.end()
|
||||
})
|
||||
|
||||
s.write('data')
|
||||
// Test passes if `.end()` is not called
|
||||
s.end()
|
||||
|
||||
b.setWritable(through())
|
||||
|
||||
setImmediate(function () {
|
||||
b.destroy(new Error('stop'))
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user