mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-17 01:16:00 +00:00
Modules
This commit is contained in:
6
node_modules/duplexify/.travis.yml
generated
vendored
Normal file
6
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/duplexify/LICENSE
generated
vendored
Normal file
21
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/duplexify/README.md
generated
vendored
Normal file
97
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/duplexify/example.js
generated
vendored
Normal file
21
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)
|
234
node_modules/duplexify/index.js
generated
vendored
Normal file
234
node_modules/duplexify/index.js
generated
vendored
Normal file
@ -0,0 +1,234 @@
|
||||
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 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) {
|
||||
if (this.destroyed) return
|
||||
this.destroyed = true
|
||||
|
||||
var self = this
|
||||
process.nextTick(function() {
|
||||
self._destroy(err)
|
||||
})
|
||||
}
|
||||
|
||||
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 cb()
|
||||
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 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
|
1
node_modules/duplexify/node_modules/isarray/.npmignore
generated
vendored
Normal file
1
node_modules/duplexify/node_modules/isarray/.npmignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
4
node_modules/duplexify/node_modules/isarray/.travis.yml
generated
vendored
Normal file
4
node_modules/duplexify/node_modules/isarray/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.8"
|
||||
- "0.10"
|
6
node_modules/duplexify/node_modules/isarray/Makefile
generated
vendored
Normal file
6
node_modules/duplexify/node_modules/isarray/Makefile
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
test:
|
||||
@node_modules/.bin/tape test.js
|
||||
|
||||
.PHONY: test
|
||||
|
60
node_modules/duplexify/node_modules/isarray/README.md
generated
vendored
Normal file
60
node_modules/duplexify/node_modules/isarray/README.md
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
|
||||
# isarray
|
||||
|
||||
`Array#isArray` for older browsers.
|
||||
|
||||
[](http://travis-ci.org/juliangruber/isarray)
|
||||
[](https://www.npmjs.org/package/isarray)
|
||||
|
||||
[
|
||||
](https://ci.testling.com/juliangruber/isarray)
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var isArray = require('isarray');
|
||||
|
||||
console.log(isArray([])); // => true
|
||||
console.log(isArray({})); // => false
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
With [npm](http://npmjs.org) do
|
||||
|
||||
```bash
|
||||
$ npm install isarray
|
||||
```
|
||||
|
||||
Then bundle for the browser with
|
||||
[browserify](https://github.com/substack/browserify).
|
||||
|
||||
With [component](http://component.io) do
|
||||
|
||||
```bash
|
||||
$ component install juliangruber/isarray
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
(MIT)
|
||||
|
||||
Copyright (c) 2013 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.
|
19
node_modules/duplexify/node_modules/isarray/component.json
generated
vendored
Normal file
19
node_modules/duplexify/node_modules/isarray/component.json
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name" : "isarray",
|
||||
"description" : "Array#isArray for older browsers",
|
||||
"version" : "0.0.1",
|
||||
"repository" : "juliangruber/isarray",
|
||||
"homepage": "https://github.com/juliangruber/isarray",
|
||||
"main" : "index.js",
|
||||
"scripts" : [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies" : {},
|
||||
"keywords": ["browser","isarray","array"],
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
"url": "http://juliangruber.com"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
5
node_modules/duplexify/node_modules/isarray/index.js
generated
vendored
Normal file
5
node_modules/duplexify/node_modules/isarray/index.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
var toString = {}.toString;
|
||||
|
||||
module.exports = Array.isArray || function (arr) {
|
||||
return toString.call(arr) == '[object Array]';
|
||||
};
|
73
node_modules/duplexify/node_modules/isarray/package.json
generated
vendored
Normal file
73
node_modules/duplexify/node_modules/isarray/package.json
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
{
|
||||
"_from": "isarray@~1.0.0",
|
||||
"_id": "isarray@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
|
||||
"_location": "/duplexify/isarray",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "isarray@~1.0.0",
|
||||
"name": "isarray",
|
||||
"escapedName": "isarray",
|
||||
"rawSpec": "~1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/duplexify/readable-stream"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
||||
"_shasum": "bb935d48582cba168c06834957a54a3e07124f11",
|
||||
"_spec": "isarray@~1.0.0",
|
||||
"_where": "C:\\Users\\matia\\Documents\\GitHub\\Musix-V3\\node_modules\\duplexify\\node_modules\\readable-stream",
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
"url": "http://juliangruber.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/juliangruber/isarray/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Array#isArray for older browsers",
|
||||
"devDependencies": {
|
||||
"tape": "~2.13.4"
|
||||
},
|
||||
"homepage": "https://github.com/juliangruber/isarray",
|
||||
"keywords": [
|
||||
"browser",
|
||||
"isarray",
|
||||
"array"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "isarray",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/juliangruber/isarray.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tape test.js"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test.js",
|
||||
"browsers": [
|
||||
"ie/8..latest",
|
||||
"firefox/17..latest",
|
||||
"firefox/nightly",
|
||||
"chrome/22..latest",
|
||||
"chrome/canary",
|
||||
"opera/12..latest",
|
||||
"opera/next",
|
||||
"safari/5.1..latest",
|
||||
"ipad/6.0..latest",
|
||||
"iphone/6.0..latest",
|
||||
"android-browser/4.2..latest"
|
||||
]
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
20
node_modules/duplexify/node_modules/isarray/test.js
generated
vendored
Normal file
20
node_modules/duplexify/node_modules/isarray/test.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
var isArray = require('./');
|
||||
var test = require('tape');
|
||||
|
||||
test('is array', function(t){
|
||||
t.ok(isArray([]));
|
||||
t.notOk(isArray({}));
|
||||
t.notOk(isArray(null));
|
||||
t.notOk(isArray(false));
|
||||
|
||||
var obj = {};
|
||||
obj[0] = true;
|
||||
t.notOk(isArray(obj));
|
||||
|
||||
var arr = [];
|
||||
arr.foo = 'bar';
|
||||
t.ok(isArray(arr));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
34
node_modules/duplexify/node_modules/readable-stream/.travis.yml
generated
vendored
Normal file
34
node_modules/duplexify/node_modules/readable-stream/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
before_install:
|
||||
- (test $NPM_LEGACY && npm install -g npm@2 && npm install -g npm@3) || true
|
||||
notifications:
|
||||
email: false
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- node_js: '0.8'
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: '0.10'
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: '0.11'
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: '0.12'
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: 1
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: 2
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: 3
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: 4
|
||||
- node_js: 5
|
||||
- node_js: 6
|
||||
- node_js: 7
|
||||
- node_js: 8
|
||||
- node_js: 9
|
||||
script: "npm run test"
|
||||
env:
|
||||
global:
|
||||
- secure: rE2Vvo7vnjabYNULNyLFxOyt98BoJexDqsiOnfiD6kLYYsiQGfr/sbZkPMOFm9qfQG7pjqx+zZWZjGSswhTt+626C0t/njXqug7Yps4c3dFblzGfreQHp7wNX5TFsvrxd6dAowVasMp61sJcRnB2w8cUzoe3RAYUDHyiHktwqMc=
|
||||
- secure: g9YINaKAdMatsJ28G9jCGbSaguXCyxSTy+pBO6Ch0Cf57ZLOTka3HqDj8p3nV28LUIHZ3ut5WO43CeYKwt4AUtLpBS3a0dndHdY6D83uY6b2qh5hXlrcbeQTq2cvw2y95F7hm4D1kwrgZ7ViqaKggRcEupAL69YbJnxeUDKWEdI=
|
38
node_modules/duplexify/node_modules/readable-stream/CONTRIBUTING.md
generated
vendored
Normal file
38
node_modules/duplexify/node_modules/readable-stream/CONTRIBUTING.md
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
# Developer's Certificate of Origin 1.1
|
||||
|
||||
By making a contribution to this project, I certify that:
|
||||
|
||||
* (a) The contribution was created in whole or in part by me and I
|
||||
have the right to submit it under the open source license
|
||||
indicated in the file; or
|
||||
|
||||
* (b) The contribution is based upon previous work that, to the best
|
||||
of my knowledge, is covered under an appropriate open source
|
||||
license and I have the right under that license to submit that
|
||||
work with modifications, whether created in whole or in part
|
||||
by me, under the same open source license (unless I am
|
||||
permitted to submit under a different license), as indicated
|
||||
in the file; or
|
||||
|
||||
* (c) The contribution was provided directly to me by some other
|
||||
person who certified (a), (b) or (c) and I have not modified
|
||||
it.
|
||||
|
||||
* (d) I understand and agree that this project and the contribution
|
||||
are public and that a record of the contribution (including all
|
||||
personal information I submit with it, including my sign-off) is
|
||||
maintained indefinitely and may be redistributed consistent with
|
||||
this project or the open source license(s) involved.
|
||||
|
||||
## Moderation Policy
|
||||
|
||||
The [Node.js Moderation Policy] applies to this WG.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
The [Node.js Code of Conduct][] applies to this WG.
|
||||
|
||||
[Node.js Code of Conduct]:
|
||||
https://github.com/nodejs/node/blob/master/CODE_OF_CONDUCT.md
|
||||
[Node.js Moderation Policy]:
|
||||
https://github.com/nodejs/TSC/blob/master/Moderation-Policy.md
|
136
node_modules/duplexify/node_modules/readable-stream/GOVERNANCE.md
generated
vendored
Normal file
136
node_modules/duplexify/node_modules/readable-stream/GOVERNANCE.md
generated
vendored
Normal file
@ -0,0 +1,136 @@
|
||||
### Streams Working Group
|
||||
|
||||
The Node.js Streams is jointly governed by a Working Group
|
||||
(WG)
|
||||
that is responsible for high-level guidance of the project.
|
||||
|
||||
The WG has final authority over this project including:
|
||||
|
||||
* Technical direction
|
||||
* Project governance and process (including this policy)
|
||||
* Contribution policy
|
||||
* GitHub repository hosting
|
||||
* Conduct guidelines
|
||||
* Maintaining the list of additional Collaborators
|
||||
|
||||
For the current list of WG members, see the project
|
||||
[README.md](./README.md#current-project-team-members).
|
||||
|
||||
### Collaborators
|
||||
|
||||
The readable-stream GitHub repository is
|
||||
maintained by the WG and additional Collaborators who are added by the
|
||||
WG on an ongoing basis.
|
||||
|
||||
Individuals making significant and valuable contributions are made
|
||||
Collaborators and given commit-access to the project. These
|
||||
individuals are identified by the WG and their addition as
|
||||
Collaborators is discussed during the WG meeting.
|
||||
|
||||
_Note:_ If you make a significant contribution and are not considered
|
||||
for commit-access log an issue or contact a WG member directly and it
|
||||
will be brought up in the next WG meeting.
|
||||
|
||||
Modifications of the contents of the readable-stream repository are
|
||||
made on
|
||||
a collaborative basis. Anybody with a GitHub account may propose a
|
||||
modification via pull request and it will be considered by the project
|
||||
Collaborators. All pull requests must be reviewed and accepted by a
|
||||
Collaborator with sufficient expertise who is able to take full
|
||||
responsibility for the change. In the case of pull requests proposed
|
||||
by an existing Collaborator, an additional Collaborator is required
|
||||
for sign-off. Consensus should be sought if additional Collaborators
|
||||
participate and there is disagreement around a particular
|
||||
modification. See _Consensus Seeking Process_ below for further detail
|
||||
on the consensus model used for governance.
|
||||
|
||||
Collaborators may opt to elevate significant or controversial
|
||||
modifications, or modifications that have not found consensus to the
|
||||
WG for discussion by assigning the ***WG-agenda*** tag to a pull
|
||||
request or issue. The WG should serve as the final arbiter where
|
||||
required.
|
||||
|
||||
For the current list of Collaborators, see the project
|
||||
[README.md](./README.md#members).
|
||||
|
||||
### WG Membership
|
||||
|
||||
WG seats are not time-limited. There is no fixed size of the WG.
|
||||
However, the expected target is between 6 and 12, to ensure adequate
|
||||
coverage of important areas of expertise, balanced with the ability to
|
||||
make decisions efficiently.
|
||||
|
||||
There is no specific set of requirements or qualifications for WG
|
||||
membership beyond these rules.
|
||||
|
||||
The WG may add additional members to the WG by unanimous consensus.
|
||||
|
||||
A WG member may be removed from the WG by voluntary resignation, or by
|
||||
unanimous consensus of all other WG members.
|
||||
|
||||
Changes to WG membership should be posted in the agenda, and may be
|
||||
suggested as any other agenda item (see "WG Meetings" below).
|
||||
|
||||
If an addition or removal is proposed during a meeting, and the full
|
||||
WG is not in attendance to participate, then the addition or removal
|
||||
is added to the agenda for the subsequent meeting. This is to ensure
|
||||
that all members are given the opportunity to participate in all
|
||||
membership decisions. If a WG member is unable to attend a meeting
|
||||
where a planned membership decision is being made, then their consent
|
||||
is assumed.
|
||||
|
||||
No more than 1/3 of the WG members may be affiliated with the same
|
||||
employer. If removal or resignation of a WG member, or a change of
|
||||
employment by a WG member, creates a situation where more than 1/3 of
|
||||
the WG membership shares an employer, then the situation must be
|
||||
immediately remedied by the resignation or removal of one or more WG
|
||||
members affiliated with the over-represented employer(s).
|
||||
|
||||
### WG Meetings
|
||||
|
||||
The WG meets occasionally on a Google Hangout On Air. A designated moderator
|
||||
approved by the WG runs the meeting. Each meeting should be
|
||||
published to YouTube.
|
||||
|
||||
Items are added to the WG agenda that are considered contentious or
|
||||
are modifications of governance, contribution policy, WG membership,
|
||||
or release process.
|
||||
|
||||
The intention of the agenda is not to approve or review all patches;
|
||||
that should happen continuously on GitHub and be handled by the larger
|
||||
group of Collaborators.
|
||||
|
||||
Any community member or contributor can ask that something be added to
|
||||
the next meeting's agenda by logging a GitHub Issue. Any Collaborator,
|
||||
WG member or the moderator can add the item to the agenda by adding
|
||||
the ***WG-agenda*** tag to the issue.
|
||||
|
||||
Prior to each WG meeting the moderator will share the Agenda with
|
||||
members of the WG. WG members can add any items they like to the
|
||||
agenda at the beginning of each meeting. The moderator and the WG
|
||||
cannot veto or remove items.
|
||||
|
||||
The WG may invite persons or representatives from certain projects to
|
||||
participate in a non-voting capacity.
|
||||
|
||||
The moderator is responsible for summarizing the discussion of each
|
||||
agenda item and sends it as a pull request after the meeting.
|
||||
|
||||
### Consensus Seeking Process
|
||||
|
||||
The WG follows a
|
||||
[Consensus
|
||||
Seeking](http://en.wikipedia.org/wiki/Consensus-seeking_decision-making)
|
||||
decision-making model.
|
||||
|
||||
When an agenda item has appeared to reach a consensus the moderator
|
||||
will ask "Does anyone object?" as a final call for dissent from the
|
||||
consensus.
|
||||
|
||||
If an agenda item cannot reach a consensus a WG member can call for
|
||||
either a closing vote or a vote to table the issue to the next
|
||||
meeting. The call for a vote must be seconded by a majority of the WG
|
||||
or else the discussion will continue. Simple majority wins.
|
||||
|
||||
Note that changes to WG membership require a majority consensus. See
|
||||
"WG Membership" above.
|
47
node_modules/duplexify/node_modules/readable-stream/LICENSE
generated
vendored
Normal file
47
node_modules/duplexify/node_modules/readable-stream/LICENSE
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
Node.js is licensed for use as follows:
|
||||
|
||||
"""
|
||||
Copyright Node.js contributors. All rights reserved.
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
This license applies to parts of Node.js originating from the
|
||||
https://github.com/joyent/node repository:
|
||||
|
||||
"""
|
||||
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
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.
|
||||
"""
|
58
node_modules/duplexify/node_modules/readable-stream/README.md
generated
vendored
Normal file
58
node_modules/duplexify/node_modules/readable-stream/README.md
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
# readable-stream
|
||||
|
||||
***Node-core v8.11.1 streams for userland*** [](https://travis-ci.org/nodejs/readable-stream)
|
||||
|
||||
|
||||
[](https://nodei.co/npm/readable-stream/)
|
||||
[](https://nodei.co/npm/readable-stream/)
|
||||
|
||||
|
||||
[](https://saucelabs.com/u/readable-stream)
|
||||
|
||||
```bash
|
||||
npm install --save readable-stream
|
||||
```
|
||||
|
||||
***Node-core streams for userland***
|
||||
|
||||
This package is a mirror of the Streams2 and Streams3 implementations in
|
||||
Node-core.
|
||||
|
||||
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.11.1/docs/api/stream.html).
|
||||
|
||||
If you want to guarantee a stable streams base, regardless of what version of
|
||||
Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html).
|
||||
|
||||
As of version 2.0.0 **readable-stream** uses semantic versioning.
|
||||
|
||||
# Streams Working Group
|
||||
|
||||
`readable-stream` is maintained by the Streams Working Group, which
|
||||
oversees the development and maintenance of the Streams API within
|
||||
Node.js. The responsibilities of the Streams Working Group include:
|
||||
|
||||
* Addressing stream issues on the Node.js issue tracker.
|
||||
* Authoring and editing stream documentation within the Node.js project.
|
||||
* Reviewing changes to stream subclasses within the Node.js project.
|
||||
* Redirecting changes to streams from the Node.js project to this
|
||||
project.
|
||||
* Assisting in the implementation of stream providers within Node.js.
|
||||
* Recommending versions of `readable-stream` to be included in Node.js.
|
||||
* Messaging about the future of streams to give the community advance
|
||||
notice of changes.
|
||||
|
||||
<a name="members"></a>
|
||||
## Team Members
|
||||
|
||||
* **Chris Dickinson** ([@chrisdickinson](https://github.com/chrisdickinson)) <christopher.s.dickinson@gmail.com>
|
||||
- Release GPG key: 9554F04D7259F04124DE6B476D5A82AC7E37093B
|
||||
* **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) <calvin.metcalf@gmail.com>
|
||||
- Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242
|
||||
* **Rod Vagg** ([@rvagg](https://github.com/rvagg)) <rod@vagg.org>
|
||||
- Release GPG key: DD8F2338BAE7501E3DD5AC78C273792F7D83545D
|
||||
* **Sam Newman** ([@sonewman](https://github.com/sonewman)) <newmansam@outlook.com>
|
||||
* **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) <mathiasbuus@gmail.com>
|
||||
* **Domenic Denicola** ([@domenic](https://github.com/domenic)) <d@domenic.me>
|
||||
* **Matteo Collina** ([@mcollina](https://github.com/mcollina)) <matteo.collina@gmail.com>
|
||||
- Release GPG key: 3ABC01543F22DD2239285CDD818674489FBC127E
|
||||
* **Irina Shestak** ([@lrlna](https://github.com/lrlna)) <shestak.irina@gmail.com>
|
60
node_modules/duplexify/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md
generated
vendored
Normal file
60
node_modules/duplexify/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
# streams WG Meeting 2015-01-30
|
||||
|
||||
## Links
|
||||
|
||||
* **Google Hangouts Video**: http://www.youtube.com/watch?v=I9nDOSGfwZg
|
||||
* **GitHub Issue**: https://github.com/iojs/readable-stream/issues/106
|
||||
* **Original Minutes Google Doc**: https://docs.google.com/document/d/17aTgLnjMXIrfjgNaTUnHQO7m3xgzHR2VXBTmi03Qii4/
|
||||
|
||||
## Agenda
|
||||
|
||||
Extracted from https://github.com/iojs/readable-stream/labels/wg-agenda prior to meeting.
|
||||
|
||||
* adopt a charter [#105](https://github.com/iojs/readable-stream/issues/105)
|
||||
* release and versioning strategy [#101](https://github.com/iojs/readable-stream/issues/101)
|
||||
* simpler stream creation [#102](https://github.com/iojs/readable-stream/issues/102)
|
||||
* proposal: deprecate implicit flowing of streams [#99](https://github.com/iojs/readable-stream/issues/99)
|
||||
|
||||
## Minutes
|
||||
|
||||
### adopt a charter
|
||||
|
||||
* group: +1's all around
|
||||
|
||||
### What versioning scheme should be adopted?
|
||||
* group: +1’s 3.0.0
|
||||
* domenic+group: pulling in patches from other sources where appropriate
|
||||
* mikeal: version independently, suggesting versions for io.js
|
||||
* mikeal+domenic: work with TC to notify in advance of changes
|
||||
simpler stream creation
|
||||
|
||||
### streamline creation of streams
|
||||
* sam: streamline creation of streams
|
||||
* domenic: nice simple solution posted
|
||||
but, we lose the opportunity to change the model
|
||||
may not be backwards incompatible (double check keys)
|
||||
|
||||
**action item:** domenic will check
|
||||
|
||||
### remove implicit flowing of streams on(‘data’)
|
||||
* add isFlowing / isPaused
|
||||
* mikeal: worrying that we’re documenting polyfill methods – confuses users
|
||||
* domenic: more reflective API is probably good, with warning labels for users
|
||||
* new section for mad scientists (reflective stream access)
|
||||
* calvin: name the “third state”
|
||||
* mikeal: maybe borrow the name from whatwg?
|
||||
* domenic: we’re missing the “third state”
|
||||
* consensus: kind of difficult to name the third state
|
||||
* mikeal: figure out differences in states / compat
|
||||
* mathias: always flow on data – eliminates third state
|
||||
* explore what it breaks
|
||||
|
||||
**action items:**
|
||||
* ask isaac for ability to list packages by what public io.js APIs they use (esp. Stream)
|
||||
* ask rod/build for infrastructure
|
||||
* **chris**: explore the “flow on data” approach
|
||||
* add isPaused/isFlowing
|
||||
* add new docs section
|
||||
* move isPaused to that section
|
||||
|
||||
|
1
node_modules/duplexify/node_modules/readable-stream/duplex-browser.js
generated
vendored
Normal file
1
node_modules/duplexify/node_modules/readable-stream/duplex-browser.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('./lib/_stream_duplex.js');
|
1
node_modules/duplexify/node_modules/readable-stream/duplex.js
generated
vendored
Normal file
1
node_modules/duplexify/node_modules/readable-stream/duplex.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('./readable').Duplex
|
131
node_modules/duplexify/node_modules/readable-stream/lib/_stream_duplex.js
generated
vendored
Normal file
131
node_modules/duplexify/node_modules/readable-stream/lib/_stream_duplex.js
generated
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
// a duplex stream is just a stream that is both readable and writable.
|
||||
// Since JS doesn't have multiple prototypal inheritance, this class
|
||||
// prototypally inherits from Readable, and then parasitically from
|
||||
// Writable.
|
||||
|
||||
'use strict';
|
||||
|
||||
/*<replacement>*/
|
||||
|
||||
var pna = require('process-nextick-args');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var objectKeys = Object.keys || function (obj) {
|
||||
var keys = [];
|
||||
for (var key in obj) {
|
||||
keys.push(key);
|
||||
}return keys;
|
||||
};
|
||||
/*</replacement>*/
|
||||
|
||||
module.exports = Duplex;
|
||||
|
||||
/*<replacement>*/
|
||||
var util = Object.create(require('core-util-is'));
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
var Readable = require('./_stream_readable');
|
||||
var Writable = require('./_stream_writable');
|
||||
|
||||
util.inherits(Duplex, Readable);
|
||||
|
||||
{
|
||||
// avoid scope creep, the keys array can then be collected
|
||||
var keys = objectKeys(Writable.prototype);
|
||||
for (var v = 0; v < keys.length; v++) {
|
||||
var method = keys[v];
|
||||
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
|
||||
}
|
||||
}
|
||||
|
||||
function Duplex(options) {
|
||||
if (!(this instanceof Duplex)) return new Duplex(options);
|
||||
|
||||
Readable.call(this, options);
|
||||
Writable.call(this, options);
|
||||
|
||||
if (options && options.readable === false) this.readable = false;
|
||||
|
||||
if (options && options.writable === false) this.writable = false;
|
||||
|
||||
this.allowHalfOpen = true;
|
||||
if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
|
||||
|
||||
this.once('end', onend);
|
||||
}
|
||||
|
||||
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
|
||||
// making it explicit this property is not enumerable
|
||||
// because otherwise some prototype manipulation in
|
||||
// userland will fail
|
||||
enumerable: false,
|
||||
get: function () {
|
||||
return this._writableState.highWaterMark;
|
||||
}
|
||||
});
|
||||
|
||||
// the no-half-open enforcer
|
||||
function onend() {
|
||||
// if we allow half-open state, or if the writable side ended,
|
||||
// then we're ok.
|
||||
if (this.allowHalfOpen || this._writableState.ended) return;
|
||||
|
||||
// no more data can be written.
|
||||
// But allow more writes to happen in this tick.
|
||||
pna.nextTick(onEndNT, this);
|
||||
}
|
||||
|
||||
function onEndNT(self) {
|
||||
self.end();
|
||||
}
|
||||
|
||||
Object.defineProperty(Duplex.prototype, 'destroyed', {
|
||||
get: function () {
|
||||
if (this._readableState === undefined || this._writableState === undefined) {
|
||||
return false;
|
||||
}
|
||||
return this._readableState.destroyed && this._writableState.destroyed;
|
||||
},
|
||||
set: function (value) {
|
||||
// we ignore the value if the stream
|
||||
// has not been initialized yet
|
||||
if (this._readableState === undefined || this._writableState === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
// backward compatibility, the user is explicitly
|
||||
// managing destroyed
|
||||
this._readableState.destroyed = value;
|
||||
this._writableState.destroyed = value;
|
||||
}
|
||||
});
|
||||
|
||||
Duplex.prototype._destroy = function (err, cb) {
|
||||
this.push(null);
|
||||
this.end();
|
||||
|
||||
pna.nextTick(cb, err);
|
||||
};
|
47
node_modules/duplexify/node_modules/readable-stream/lib/_stream_passthrough.js
generated
vendored
Normal file
47
node_modules/duplexify/node_modules/readable-stream/lib/_stream_passthrough.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
// a passthrough stream.
|
||||
// basically just the most minimal sort of Transform stream.
|
||||
// Every written chunk gets output as-is.
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = PassThrough;
|
||||
|
||||
var Transform = require('./_stream_transform');
|
||||
|
||||
/*<replacement>*/
|
||||
var util = Object.create(require('core-util-is'));
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
util.inherits(PassThrough, Transform);
|
||||
|
||||
function PassThrough(options) {
|
||||
if (!(this instanceof PassThrough)) return new PassThrough(options);
|
||||
|
||||
Transform.call(this, options);
|
||||
}
|
||||
|
||||
PassThrough.prototype._transform = function (chunk, encoding, cb) {
|
||||
cb(null, chunk);
|
||||
};
|
1019
node_modules/duplexify/node_modules/readable-stream/lib/_stream_readable.js
generated
vendored
Normal file
1019
node_modules/duplexify/node_modules/readable-stream/lib/_stream_readable.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
214
node_modules/duplexify/node_modules/readable-stream/lib/_stream_transform.js
generated
vendored
Normal file
214
node_modules/duplexify/node_modules/readable-stream/lib/_stream_transform.js
generated
vendored
Normal file
@ -0,0 +1,214 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
// a transform stream is a readable/writable stream where you do
|
||||
// something with the data. Sometimes it's called a "filter",
|
||||
// but that's not a great name for it, since that implies a thing where
|
||||
// some bits pass through, and others are simply ignored. (That would
|
||||
// be a valid example of a transform, of course.)
|
||||
//
|
||||
// While the output is causally related to the input, it's not a
|
||||
// necessarily symmetric or synchronous transformation. For example,
|
||||
// a zlib stream might take multiple plain-text writes(), and then
|
||||
// emit a single compressed chunk some time in the future.
|
||||
//
|
||||
// Here's how this works:
|
||||
//
|
||||
// The Transform stream has all the aspects of the readable and writable
|
||||
// stream classes. When you write(chunk), that calls _write(chunk,cb)
|
||||
// internally, and returns false if there's a lot of pending writes
|
||||
// buffered up. When you call read(), that calls _read(n) until
|
||||
// there's enough pending readable data buffered up.
|
||||
//
|
||||
// In a transform stream, the written data is placed in a buffer. When
|
||||
// _read(n) is called, it transforms the queued up data, calling the
|
||||
// buffered _write cb's as it consumes chunks. If consuming a single
|
||||
// written chunk would result in multiple output chunks, then the first
|
||||
// outputted bit calls the readcb, and subsequent chunks just go into
|
||||
// the read buffer, and will cause it to emit 'readable' if necessary.
|
||||
//
|
||||
// This way, back-pressure is actually determined by the reading side,
|
||||
// since _read has to be called to start processing a new chunk. However,
|
||||
// a pathological inflate type of transform can cause excessive buffering
|
||||
// here. For example, imagine a stream where every byte of input is
|
||||
// interpreted as an integer from 0-255, and then results in that many
|
||||
// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
|
||||
// 1kb of data being output. In this case, you could write a very small
|
||||
// amount of input, and end up with a very large amount of output. In
|
||||
// such a pathological inflating mechanism, there'd be no way to tell
|
||||
// the system to stop doing the transform. A single 4MB write could
|
||||
// cause the system to run out of memory.
|
||||
//
|
||||
// However, even in such a pathological case, only a single written chunk
|
||||
// would be consumed, and then the rest would wait (un-transformed) until
|
||||
// the results of the previous transformed chunk were consumed.
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = Transform;
|
||||
|
||||
var Duplex = require('./_stream_duplex');
|
||||
|
||||
/*<replacement>*/
|
||||
var util = Object.create(require('core-util-is'));
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
util.inherits(Transform, Duplex);
|
||||
|
||||
function afterTransform(er, data) {
|
||||
var ts = this._transformState;
|
||||
ts.transforming = false;
|
||||
|
||||
var cb = ts.writecb;
|
||||
|
||||
if (!cb) {
|
||||
return this.emit('error', new Error('write callback called multiple times'));
|
||||
}
|
||||
|
||||
ts.writechunk = null;
|
||||
ts.writecb = null;
|
||||
|
||||
if (data != null) // single equals check for both `null` and `undefined`
|
||||
this.push(data);
|
||||
|
||||
cb(er);
|
||||
|
||||
var rs = this._readableState;
|
||||
rs.reading = false;
|
||||
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
||||
this._read(rs.highWaterMark);
|
||||
}
|
||||
}
|
||||
|
||||
function Transform(options) {
|
||||
if (!(this instanceof Transform)) return new Transform(options);
|
||||
|
||||
Duplex.call(this, options);
|
||||
|
||||
this._transformState = {
|
||||
afterTransform: afterTransform.bind(this),
|
||||
needTransform: false,
|
||||
transforming: false,
|
||||
writecb: null,
|
||||
writechunk: null,
|
||||
writeencoding: null
|
||||
};
|
||||
|
||||
// start out asking for a readable event once data is transformed.
|
||||
this._readableState.needReadable = true;
|
||||
|
||||
// we have implemented the _read method, and done the other things
|
||||
// that Readable wants before the first _read call, so unset the
|
||||
// sync guard flag.
|
||||
this._readableState.sync = false;
|
||||
|
||||
if (options) {
|
||||
if (typeof options.transform === 'function') this._transform = options.transform;
|
||||
|
||||
if (typeof options.flush === 'function') this._flush = options.flush;
|
||||
}
|
||||
|
||||
// When the writable side finishes, then flush out anything remaining.
|
||||
this.on('prefinish', prefinish);
|
||||
}
|
||||
|
||||
function prefinish() {
|
||||
var _this = this;
|
||||
|
||||
if (typeof this._flush === 'function') {
|
||||
this._flush(function (er, data) {
|
||||
done(_this, er, data);
|
||||
});
|
||||
} else {
|
||||
done(this, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
Transform.prototype.push = function (chunk, encoding) {
|
||||
this._transformState.needTransform = false;
|
||||
return Duplex.prototype.push.call(this, chunk, encoding);
|
||||
};
|
||||
|
||||
// This is the part where you do stuff!
|
||||
// override this function in implementation classes.
|
||||
// 'chunk' is an input chunk.
|
||||
//
|
||||
// Call `push(newChunk)` to pass along transformed output
|
||||
// to the readable side. You may call 'push' zero or more times.
|
||||
//
|
||||
// Call `cb(err)` when you are done with this chunk. If you pass
|
||||
// an error, then that'll put the hurt on the whole operation. If you
|
||||
// never call cb(), then you'll never get another chunk.
|
||||
Transform.prototype._transform = function (chunk, encoding, cb) {
|
||||
throw new Error('_transform() is not implemented');
|
||||
};
|
||||
|
||||
Transform.prototype._write = function (chunk, encoding, cb) {
|
||||
var ts = this._transformState;
|
||||
ts.writecb = cb;
|
||||
ts.writechunk = chunk;
|
||||
ts.writeencoding = encoding;
|
||||
if (!ts.transforming) {
|
||||
var rs = this._readableState;
|
||||
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
|
||||
}
|
||||
};
|
||||
|
||||
// Doesn't matter what the args are here.
|
||||
// _transform does all the work.
|
||||
// That we got here means that the readable side wants more data.
|
||||
Transform.prototype._read = function (n) {
|
||||
var ts = this._transformState;
|
||||
|
||||
if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
|
||||
ts.transforming = true;
|
||||
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
||||
} else {
|
||||
// mark that we need a transform, so that any data that comes in
|
||||
// will get processed, now that we've asked for it.
|
||||
ts.needTransform = true;
|
||||
}
|
||||
};
|
||||
|
||||
Transform.prototype._destroy = function (err, cb) {
|
||||
var _this2 = this;
|
||||
|
||||
Duplex.prototype._destroy.call(this, err, function (err2) {
|
||||
cb(err2);
|
||||
_this2.emit('close');
|
||||
});
|
||||
};
|
||||
|
||||
function done(stream, er, data) {
|
||||
if (er) return stream.emit('error', er);
|
||||
|
||||
if (data != null) // single equals check for both `null` and `undefined`
|
||||
stream.push(data);
|
||||
|
||||
// if there's nothing in the write buffer, then that means
|
||||
// that nothing more will ever be provided
|
||||
if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
|
||||
|
||||
if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
|
||||
|
||||
return stream.push(null);
|
||||
}
|
687
node_modules/duplexify/node_modules/readable-stream/lib/_stream_writable.js
generated
vendored
Normal file
687
node_modules/duplexify/node_modules/readable-stream/lib/_stream_writable.js
generated
vendored
Normal file
@ -0,0 +1,687 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
// A bit simpler than readable streams.
|
||||
// Implement an async ._write(chunk, encoding, cb), and it'll handle all
|
||||
// the drain event emission and buffering.
|
||||
|
||||
'use strict';
|
||||
|
||||
/*<replacement>*/
|
||||
|
||||
var pna = require('process-nextick-args');
|
||||
/*</replacement>*/
|
||||
|
||||
module.exports = Writable;
|
||||
|
||||
/* <replacement> */
|
||||
function WriteReq(chunk, encoding, cb) {
|
||||
this.chunk = chunk;
|
||||
this.encoding = encoding;
|
||||
this.callback = cb;
|
||||
this.next = null;
|
||||
}
|
||||
|
||||
// It seems a linked list but it is not
|
||||
// there will be only 2 of these for each stream
|
||||
function CorkedRequest(state) {
|
||||
var _this = this;
|
||||
|
||||
this.next = null;
|
||||
this.entry = null;
|
||||
this.finish = function () {
|
||||
onCorkedFinish(_this, state);
|
||||
};
|
||||
}
|
||||
/* </replacement> */
|
||||
|
||||
/*<replacement>*/
|
||||
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var Duplex;
|
||||
/*</replacement>*/
|
||||
|
||||
Writable.WritableState = WritableState;
|
||||
|
||||
/*<replacement>*/
|
||||
var util = Object.create(require('core-util-is'));
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var internalUtil = {
|
||||
deprecate: require('util-deprecate')
|
||||
};
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var Stream = require('./internal/streams/stream');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
|
||||
var Buffer = require('safe-buffer').Buffer;
|
||||
var OurUint8Array = global.Uint8Array || function () {};
|
||||
function _uint8ArrayToBuffer(chunk) {
|
||||
return Buffer.from(chunk);
|
||||
}
|
||||
function _isUint8Array(obj) {
|
||||
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
||||
}
|
||||
|
||||
/*</replacement>*/
|
||||
|
||||
var destroyImpl = require('./internal/streams/destroy');
|
||||
|
||||
util.inherits(Writable, Stream);
|
||||
|
||||
function nop() {}
|
||||
|
||||
function WritableState(options, stream) {
|
||||
Duplex = Duplex || require('./_stream_duplex');
|
||||
|
||||
options = options || {};
|
||||
|
||||
// Duplex streams are both readable and writable, but share
|
||||
// the same options object.
|
||||
// However, some cases require setting options to different
|
||||
// values for the readable and the writable sides of the duplex stream.
|
||||
// These options can be provided separately as readableXXX and writableXXX.
|
||||
var isDuplex = stream instanceof Duplex;
|
||||
|
||||
// object stream flag to indicate whether or not this stream
|
||||
// contains buffers or objects.
|
||||
this.objectMode = !!options.objectMode;
|
||||
|
||||
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
|
||||
|
||||
// the point at which write() starts returning false
|
||||
// Note: 0 is a valid value, means that we always return false if
|
||||
// the entire buffer is not flushed immediately on write()
|
||||
var hwm = options.highWaterMark;
|
||||
var writableHwm = options.writableHighWaterMark;
|
||||
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
||||
|
||||
if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
|
||||
|
||||
// cast to ints.
|
||||
this.highWaterMark = Math.floor(this.highWaterMark);
|
||||
|
||||
// if _final has been called
|
||||
this.finalCalled = false;
|
||||
|
||||
// drain event flag.
|
||||
this.needDrain = false;
|
||||
// at the start of calling end()
|
||||
this.ending = false;
|
||||
// when end() has been called, and returned
|
||||
this.ended = false;
|
||||
// when 'finish' is emitted
|
||||
this.finished = false;
|
||||
|
||||
// has it been destroyed
|
||||
this.destroyed = false;
|
||||
|
||||
// should we decode strings into buffers before passing to _write?
|
||||
// this is here so that some node-core streams can optimize string
|
||||
// handling at a lower level.
|
||||
var noDecode = options.decodeStrings === false;
|
||||
this.decodeStrings = !noDecode;
|
||||
|
||||
// Crypto is kind of old and crusty. Historically, its default string
|
||||
// encoding is 'binary' so we have to make this configurable.
|
||||
// Everything else in the universe uses 'utf8', though.
|
||||
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
||||
|
||||
// not an actual buffer we keep track of, but a measurement
|
||||
// of how much we're waiting to get pushed to some underlying
|
||||
// socket or file.
|
||||
this.length = 0;
|
||||
|
||||
// a flag to see when we're in the middle of a write.
|
||||
this.writing = false;
|
||||
|
||||
// when true all writes will be buffered until .uncork() call
|
||||
this.corked = 0;
|
||||
|
||||
// a flag to be able to tell if the onwrite cb is called immediately,
|
||||
// or on a later tick. We set this to true at first, because any
|
||||
// actions that shouldn't happen until "later" should generally also
|
||||
// not happen before the first write call.
|
||||
this.sync = true;
|
||||
|
||||
// a flag to know if we're processing previously buffered items, which
|
||||
// may call the _write() callback in the same tick, so that we don't
|
||||
// end up in an overlapped onwrite situation.
|
||||
this.bufferProcessing = false;
|
||||
|
||||
// the callback that's passed to _write(chunk,cb)
|
||||
this.onwrite = function (er) {
|
||||
onwrite(stream, er);
|
||||
};
|
||||
|
||||
// the callback that the user supplies to write(chunk,encoding,cb)
|
||||
this.writecb = null;
|
||||
|
||||
// the amount that is being written when _write is called.
|
||||
this.writelen = 0;
|
||||
|
||||
this.bufferedRequest = null;
|
||||
this.lastBufferedRequest = null;
|
||||
|
||||
// number of pending user-supplied write callbacks
|
||||
// this must be 0 before 'finish' can be emitted
|
||||
this.pendingcb = 0;
|
||||
|
||||
// emit prefinish if the only thing we're waiting for is _write cbs
|
||||
// This is relevant for synchronous Transform streams
|
||||
this.prefinished = false;
|
||||
|
||||
// True if the error was already emitted and should not be thrown again
|
||||
this.errorEmitted = false;
|
||||
|
||||
// count buffered requests
|
||||
this.bufferedRequestCount = 0;
|
||||
|
||||
// allocate the first CorkedRequest, there is always
|
||||
// one allocated and free to use, and we maintain at most two
|
||||
this.corkedRequestsFree = new CorkedRequest(this);
|
||||
}
|
||||
|
||||
WritableState.prototype.getBuffer = function getBuffer() {
|
||||
var current = this.bufferedRequest;
|
||||
var out = [];
|
||||
while (current) {
|
||||
out.push(current);
|
||||
current = current.next;
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
||||
(function () {
|
||||
try {
|
||||
Object.defineProperty(WritableState.prototype, 'buffer', {
|
||||
get: internalUtil.deprecate(function () {
|
||||
return this.getBuffer();
|
||||
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
|
||||
});
|
||||
} catch (_) {}
|
||||
})();
|
||||
|
||||
// Test _writableState for inheritance to account for Duplex streams,
|
||||
// whose prototype chain only points to Readable.
|
||||
var realHasInstance;
|
||||
if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
|
||||
realHasInstance = Function.prototype[Symbol.hasInstance];
|
||||
Object.defineProperty(Writable, Symbol.hasInstance, {
|
||||
value: function (object) {
|
||||
if (realHasInstance.call(this, object)) return true;
|
||||
if (this !== Writable) return false;
|
||||
|
||||
return object && object._writableState instanceof WritableState;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
realHasInstance = function (object) {
|
||||
return object instanceof this;
|
||||
};
|
||||
}
|
||||
|
||||
function Writable(options) {
|
||||
Duplex = Duplex || require('./_stream_duplex');
|
||||
|
||||
// Writable ctor is applied to Duplexes, too.
|
||||
// `realHasInstance` is necessary because using plain `instanceof`
|
||||
// would return false, as no `_writableState` property is attached.
|
||||
|
||||
// Trying to use the custom `instanceof` for Writable here will also break the
|
||||
// Node.js LazyTransform implementation, which has a non-trivial getter for
|
||||
// `_writableState` that would lead to infinite recursion.
|
||||
if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
|
||||
return new Writable(options);
|
||||
}
|
||||
|
||||
this._writableState = new WritableState(options, this);
|
||||
|
||||
// legacy.
|
||||
this.writable = true;
|
||||
|
||||
if (options) {
|
||||
if (typeof options.write === 'function') this._write = options.write;
|
||||
|
||||
if (typeof options.writev === 'function') this._writev = options.writev;
|
||||
|
||||
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
||||
|
||||
if (typeof options.final === 'function') this._final = options.final;
|
||||
}
|
||||
|
||||
Stream.call(this);
|
||||
}
|
||||
|
||||
// Otherwise people can pipe Writable streams, which is just wrong.
|
||||
Writable.prototype.pipe = function () {
|
||||
this.emit('error', new Error('Cannot pipe, not readable'));
|
||||
};
|
||||
|
||||
function writeAfterEnd(stream, cb) {
|
||||
var er = new Error('write after end');
|
||||
// TODO: defer error events consistently everywhere, not just the cb
|
||||
stream.emit('error', er);
|
||||
pna.nextTick(cb, er);
|
||||
}
|
||||
|
||||
// Checks that a user-supplied chunk is valid, especially for the particular
|
||||
// mode the stream is in. Currently this means that `null` is never accepted
|
||||
// and undefined/non-string values are only allowed in object mode.
|
||||
function validChunk(stream, state, chunk, cb) {
|
||||
var valid = true;
|
||||
var er = false;
|
||||
|
||||
if (chunk === null) {
|
||||
er = new TypeError('May not write null values to stream');
|
||||
} else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
|
||||
er = new TypeError('Invalid non-string/buffer chunk');
|
||||
}
|
||||
if (er) {
|
||||
stream.emit('error', er);
|
||||
pna.nextTick(cb, er);
|
||||
valid = false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
Writable.prototype.write = function (chunk, encoding, cb) {
|
||||
var state = this._writableState;
|
||||
var ret = false;
|
||||
var isBuf = !state.objectMode && _isUint8Array(chunk);
|
||||
|
||||
if (isBuf && !Buffer.isBuffer(chunk)) {
|
||||
chunk = _uint8ArrayToBuffer(chunk);
|
||||
}
|
||||
|
||||
if (typeof encoding === 'function') {
|
||||
cb = encoding;
|
||||
encoding = null;
|
||||
}
|
||||
|
||||
if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
|
||||
|
||||
if (typeof cb !== 'function') cb = nop;
|
||||
|
||||
if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
|
||||
state.pendingcb++;
|
||||
ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
Writable.prototype.cork = function () {
|
||||
var state = this._writableState;
|
||||
|
||||
state.corked++;
|
||||
};
|
||||
|
||||
Writable.prototype.uncork = function () {
|
||||
var state = this._writableState;
|
||||
|
||||
if (state.corked) {
|
||||
state.corked--;
|
||||
|
||||
if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
|
||||
}
|
||||
};
|
||||
|
||||
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
||||
// node::ParseEncoding() requires lower case.
|
||||
if (typeof encoding === 'string') encoding = encoding.toLowerCase();
|
||||
if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
|
||||
this._writableState.defaultEncoding = encoding;
|
||||
return this;
|
||||
};
|
||||
|
||||
function decodeChunk(state, chunk, encoding) {
|
||||
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
|
||||
chunk = Buffer.from(chunk, encoding);
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
|
||||
// making it explicit this property is not enumerable
|
||||
// because otherwise some prototype manipulation in
|
||||
// userland will fail
|
||||
enumerable: false,
|
||||
get: function () {
|
||||
return this._writableState.highWaterMark;
|
||||
}
|
||||
});
|
||||
|
||||
// if we're already writing something, then just put this
|
||||
// in the queue, and wait our turn. Otherwise, call _write
|
||||
// If we return false, then we need a drain event, so set that flag.
|
||||
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
|
||||
if (!isBuf) {
|
||||
var newChunk = decodeChunk(state, chunk, encoding);
|
||||
if (chunk !== newChunk) {
|
||||
isBuf = true;
|
||||
encoding = 'buffer';
|
||||
chunk = newChunk;
|
||||
}
|
||||
}
|
||||
var len = state.objectMode ? 1 : chunk.length;
|
||||
|
||||
state.length += len;
|
||||
|
||||
var ret = state.length < state.highWaterMark;
|
||||
// we must ensure that previous needDrain will not be reset to false.
|
||||
if (!ret) state.needDrain = true;
|
||||
|
||||
if (state.writing || state.corked) {
|
||||
var last = state.lastBufferedRequest;
|
||||
state.lastBufferedRequest = {
|
||||
chunk: chunk,
|
||||
encoding: encoding,
|
||||
isBuf: isBuf,
|
||||
callback: cb,
|
||||
next: null
|
||||
};
|
||||
if (last) {
|
||||
last.next = state.lastBufferedRequest;
|
||||
} else {
|
||||
state.bufferedRequest = state.lastBufferedRequest;
|
||||
}
|
||||
state.bufferedRequestCount += 1;
|
||||
} else {
|
||||
doWrite(stream, state, false, len, chunk, encoding, cb);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
||||
state.writelen = len;
|
||||
state.writecb = cb;
|
||||
state.writing = true;
|
||||
state.sync = true;
|
||||
if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
|
||||
state.sync = false;
|
||||
}
|
||||
|
||||
function onwriteError(stream, state, sync, er, cb) {
|
||||
--state.pendingcb;
|
||||
|
||||
if (sync) {
|
||||
// defer the callback if we are being called synchronously
|
||||
// to avoid piling up things on the stack
|
||||
pna.nextTick(cb, er);
|
||||
// this can emit finish, and it will always happen
|
||||
// after error
|
||||
pna.nextTick(finishMaybe, stream, state);
|
||||
stream._writableState.errorEmitted = true;
|
||||
stream.emit('error', er);
|
||||
} else {
|
||||
// the caller expect this to happen before if
|
||||
// it is async
|
||||
cb(er);
|
||||
stream._writableState.errorEmitted = true;
|
||||
stream.emit('error', er);
|
||||
// this can emit finish, but finish must
|
||||
// always follow error
|
||||
finishMaybe(stream, state);
|
||||
}
|
||||
}
|
||||
|
||||
function onwriteStateUpdate(state) {
|
||||
state.writing = false;
|
||||
state.writecb = null;
|
||||
state.length -= state.writelen;
|
||||
state.writelen = 0;
|
||||
}
|
||||
|
||||
function onwrite(stream, er) {
|
||||
var state = stream._writableState;
|
||||
var sync = state.sync;
|
||||
var cb = state.writecb;
|
||||
|
||||
onwriteStateUpdate(state);
|
||||
|
||||
if (er) onwriteError(stream, state, sync, er, cb);else {
|
||||
// Check if we're actually ready to finish, but don't emit yet
|
||||
var finished = needFinish(state);
|
||||
|
||||
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
|
||||
clearBuffer(stream, state);
|
||||
}
|
||||
|
||||
if (sync) {
|
||||
/*<replacement>*/
|
||||
asyncWrite(afterWrite, stream, state, finished, cb);
|
||||
/*</replacement>*/
|
||||
} else {
|
||||
afterWrite(stream, state, finished, cb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function afterWrite(stream, state, finished, cb) {
|
||||
if (!finished) onwriteDrain(stream, state);
|
||||
state.pendingcb--;
|
||||
cb();
|
||||
finishMaybe(stream, state);
|
||||
}
|
||||
|
||||
// Must force callback to be called on nextTick, so that we don't
|
||||
// emit 'drain' before the write() consumer gets the 'false' return
|
||||
// value, and has a chance to attach a 'drain' listener.
|
||||
function onwriteDrain(stream, state) {
|
||||
if (state.length === 0 && state.needDrain) {
|
||||
state.needDrain = false;
|
||||
stream.emit('drain');
|
||||
}
|
||||
}
|
||||
|
||||
// if there's something in the buffer waiting, then process it
|
||||
function clearBuffer(stream, state) {
|
||||
state.bufferProcessing = true;
|
||||
var entry = state.bufferedRequest;
|
||||
|
||||
if (stream._writev && entry && entry.next) {
|
||||
// Fast case, write everything using _writev()
|
||||
var l = state.bufferedRequestCount;
|
||||
var buffer = new Array(l);
|
||||
var holder = state.corkedRequestsFree;
|
||||
holder.entry = entry;
|
||||
|
||||
var count = 0;
|
||||
var allBuffers = true;
|
||||
while (entry) {
|
||||
buffer[count] = entry;
|
||||
if (!entry.isBuf) allBuffers = false;
|
||||
entry = entry.next;
|
||||
count += 1;
|
||||
}
|
||||
buffer.allBuffers = allBuffers;
|
||||
|
||||
doWrite(stream, state, true, state.length, buffer, '', holder.finish);
|
||||
|
||||
// doWrite is almost always async, defer these to save a bit of time
|
||||
// as the hot path ends with doWrite
|
||||
state.pendingcb++;
|
||||
state.lastBufferedRequest = null;
|
||||
if (holder.next) {
|
||||
state.corkedRequestsFree = holder.next;
|
||||
holder.next = null;
|
||||
} else {
|
||||
state.corkedRequestsFree = new CorkedRequest(state);
|
||||
}
|
||||
state.bufferedRequestCount = 0;
|
||||
} else {
|
||||
// Slow case, write chunks one-by-one
|
||||
while (entry) {
|
||||
var chunk = entry.chunk;
|
||||
var encoding = entry.encoding;
|
||||
var cb = entry.callback;
|
||||
var len = state.objectMode ? 1 : chunk.length;
|
||||
|
||||
doWrite(stream, state, false, len, chunk, encoding, cb);
|
||||
entry = entry.next;
|
||||
state.bufferedRequestCount--;
|
||||
// if we didn't call the onwrite immediately, then
|
||||
// it means that we need to wait until it does.
|
||||
// also, that means that the chunk and cb are currently
|
||||
// being processed, so move the buffer counter past them.
|
||||
if (state.writing) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (entry === null) state.lastBufferedRequest = null;
|
||||
}
|
||||
|
||||
state.bufferedRequest = entry;
|
||||
state.bufferProcessing = false;
|
||||
}
|
||||
|
||||
Writable.prototype._write = function (chunk, encoding, cb) {
|
||||
cb(new Error('_write() is not implemented'));
|
||||
};
|
||||
|
||||
Writable.prototype._writev = null;
|
||||
|
||||
Writable.prototype.end = function (chunk, encoding, cb) {
|
||||
var state = this._writableState;
|
||||
|
||||
if (typeof chunk === 'function') {
|
||||
cb = chunk;
|
||||
chunk = null;
|
||||
encoding = null;
|
||||
} else if (typeof encoding === 'function') {
|
||||
cb = encoding;
|
||||
encoding = null;
|
||||
}
|
||||
|
||||
if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
|
||||
|
||||
// .end() fully uncorks
|
||||
if (state.corked) {
|
||||
state.corked = 1;
|
||||
this.uncork();
|
||||
}
|
||||
|
||||
// ignore unnecessary end() calls.
|
||||
if (!state.ending && !state.finished) endWritable(this, state, cb);
|
||||
};
|
||||
|
||||
function needFinish(state) {
|
||||
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
||||
}
|
||||
function callFinal(stream, state) {
|
||||
stream._final(function (err) {
|
||||
state.pendingcb--;
|
||||
if (err) {
|
||||
stream.emit('error', err);
|
||||
}
|
||||
state.prefinished = true;
|
||||
stream.emit('prefinish');
|
||||
finishMaybe(stream, state);
|
||||
});
|
||||
}
|
||||
function prefinish(stream, state) {
|
||||
if (!state.prefinished && !state.finalCalled) {
|
||||
if (typeof stream._final === 'function') {
|
||||
state.pendingcb++;
|
||||
state.finalCalled = true;
|
||||
pna.nextTick(callFinal, stream, state);
|
||||
} else {
|
||||
state.prefinished = true;
|
||||
stream.emit('prefinish');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function finishMaybe(stream, state) {
|
||||
var need = needFinish(state);
|
||||
if (need) {
|
||||
prefinish(stream, state);
|
||||
if (state.pendingcb === 0) {
|
||||
state.finished = true;
|
||||
stream.emit('finish');
|
||||
}
|
||||
}
|
||||
return need;
|
||||
}
|
||||
|
||||
function endWritable(stream, state, cb) {
|
||||
state.ending = true;
|
||||
finishMaybe(stream, state);
|
||||
if (cb) {
|
||||
if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
|
||||
}
|
||||
state.ended = true;
|
||||
stream.writable = false;
|
||||
}
|
||||
|
||||
function onCorkedFinish(corkReq, state, err) {
|
||||
var entry = corkReq.entry;
|
||||
corkReq.entry = null;
|
||||
while (entry) {
|
||||
var cb = entry.callback;
|
||||
state.pendingcb--;
|
||||
cb(err);
|
||||
entry = entry.next;
|
||||
}
|
||||
if (state.corkedRequestsFree) {
|
||||
state.corkedRequestsFree.next = corkReq;
|
||||
} else {
|
||||
state.corkedRequestsFree = corkReq;
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(Writable.prototype, 'destroyed', {
|
||||
get: function () {
|
||||
if (this._writableState === undefined) {
|
||||
return false;
|
||||
}
|
||||
return this._writableState.destroyed;
|
||||
},
|
||||
set: function (value) {
|
||||
// we ignore the value if the stream
|
||||
// has not been initialized yet
|
||||
if (!this._writableState) {
|
||||
return;
|
||||
}
|
||||
|
||||
// backward compatibility, the user is explicitly
|
||||
// managing destroyed
|
||||
this._writableState.destroyed = value;
|
||||
}
|
||||
});
|
||||
|
||||
Writable.prototype.destroy = destroyImpl.destroy;
|
||||
Writable.prototype._undestroy = destroyImpl.undestroy;
|
||||
Writable.prototype._destroy = function (err, cb) {
|
||||
this.end();
|
||||
cb(err);
|
||||
};
|
79
node_modules/duplexify/node_modules/readable-stream/lib/internal/streams/BufferList.js
generated
vendored
Normal file
79
node_modules/duplexify/node_modules/readable-stream/lib/internal/streams/BufferList.js
generated
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
'use strict';
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var Buffer = require('safe-buffer').Buffer;
|
||||
var util = require('util');
|
||||
|
||||
function copyBuffer(src, target, offset) {
|
||||
src.copy(target, offset);
|
||||
}
|
||||
|
||||
module.exports = function () {
|
||||
function BufferList() {
|
||||
_classCallCheck(this, BufferList);
|
||||
|
||||
this.head = null;
|
||||
this.tail = null;
|
||||
this.length = 0;
|
||||
}
|
||||
|
||||
BufferList.prototype.push = function push(v) {
|
||||
var entry = { data: v, next: null };
|
||||
if (this.length > 0) this.tail.next = entry;else this.head = entry;
|
||||
this.tail = entry;
|
||||
++this.length;
|
||||
};
|
||||
|
||||
BufferList.prototype.unshift = function unshift(v) {
|
||||
var entry = { data: v, next: this.head };
|
||||
if (this.length === 0) this.tail = entry;
|
||||
this.head = entry;
|
||||
++this.length;
|
||||
};
|
||||
|
||||
BufferList.prototype.shift = function shift() {
|
||||
if (this.length === 0) return;
|
||||
var ret = this.head.data;
|
||||
if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
|
||||
--this.length;
|
||||
return ret;
|
||||
};
|
||||
|
||||
BufferList.prototype.clear = function clear() {
|
||||
this.head = this.tail = null;
|
||||
this.length = 0;
|
||||
};
|
||||
|
||||
BufferList.prototype.join = function join(s) {
|
||||
if (this.length === 0) return '';
|
||||
var p = this.head;
|
||||
var ret = '' + p.data;
|
||||
while (p = p.next) {
|
||||
ret += s + p.data;
|
||||
}return ret;
|
||||
};
|
||||
|
||||
BufferList.prototype.concat = function concat(n) {
|
||||
if (this.length === 0) return Buffer.alloc(0);
|
||||
if (this.length === 1) return this.head.data;
|
||||
var ret = Buffer.allocUnsafe(n >>> 0);
|
||||
var p = this.head;
|
||||
var i = 0;
|
||||
while (p) {
|
||||
copyBuffer(p.data, ret, i);
|
||||
i += p.data.length;
|
||||
p = p.next;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
return BufferList;
|
||||
}();
|
||||
|
||||
if (util && util.inspect && util.inspect.custom) {
|
||||
module.exports.prototype[util.inspect.custom] = function () {
|
||||
var obj = util.inspect({ length: this.length });
|
||||
return this.constructor.name + ' ' + obj;
|
||||
};
|
||||
}
|
74
node_modules/duplexify/node_modules/readable-stream/lib/internal/streams/destroy.js
generated
vendored
Normal file
74
node_modules/duplexify/node_modules/readable-stream/lib/internal/streams/destroy.js
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
'use strict';
|
||||
|
||||
/*<replacement>*/
|
||||
|
||||
var pna = require('process-nextick-args');
|
||||
/*</replacement>*/
|
||||
|
||||
// undocumented cb() API, needed for core, not for public API
|
||||
function destroy(err, cb) {
|
||||
var _this = this;
|
||||
|
||||
var readableDestroyed = this._readableState && this._readableState.destroyed;
|
||||
var writableDestroyed = this._writableState && this._writableState.destroyed;
|
||||
|
||||
if (readableDestroyed || writableDestroyed) {
|
||||
if (cb) {
|
||||
cb(err);
|
||||
} else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
|
||||
pna.nextTick(emitErrorNT, this, err);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// we set destroyed to true before firing error callbacks in order
|
||||
// to make it re-entrance safe in case destroy() is called within callbacks
|
||||
|
||||
if (this._readableState) {
|
||||
this._readableState.destroyed = true;
|
||||
}
|
||||
|
||||
// if this is a duplex stream mark the writable part as destroyed as well
|
||||
if (this._writableState) {
|
||||
this._writableState.destroyed = true;
|
||||
}
|
||||
|
||||
this._destroy(err || null, function (err) {
|
||||
if (!cb && err) {
|
||||
pna.nextTick(emitErrorNT, _this, err);
|
||||
if (_this._writableState) {
|
||||
_this._writableState.errorEmitted = true;
|
||||
}
|
||||
} else if (cb) {
|
||||
cb(err);
|
||||
}
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
function undestroy() {
|
||||
if (this._readableState) {
|
||||
this._readableState.destroyed = false;
|
||||
this._readableState.reading = false;
|
||||
this._readableState.ended = false;
|
||||
this._readableState.endEmitted = false;
|
||||
}
|
||||
|
||||
if (this._writableState) {
|
||||
this._writableState.destroyed = false;
|
||||
this._writableState.ended = false;
|
||||
this._writableState.ending = false;
|
||||
this._writableState.finished = false;
|
||||
this._writableState.errorEmitted = false;
|
||||
}
|
||||
}
|
||||
|
||||
function emitErrorNT(self, err) {
|
||||
self.emit('error', err);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
destroy: destroy,
|
||||
undestroy: undestroy
|
||||
};
|
1
node_modules/duplexify/node_modules/readable-stream/lib/internal/streams/stream-browser.js
generated
vendored
Normal file
1
node_modules/duplexify/node_modules/readable-stream/lib/internal/streams/stream-browser.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('events').EventEmitter;
|
1
node_modules/duplexify/node_modules/readable-stream/lib/internal/streams/stream.js
generated
vendored
Normal file
1
node_modules/duplexify/node_modules/readable-stream/lib/internal/streams/stream.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('stream');
|
81
node_modules/duplexify/node_modules/readable-stream/package.json
generated
vendored
Normal file
81
node_modules/duplexify/node_modules/readable-stream/package.json
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
{
|
||||
"_from": "readable-stream@^2.0.0",
|
||||
"_id": "readable-stream@2.3.7",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
|
||||
"_location": "/duplexify/readable-stream",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "readable-stream@^2.0.0",
|
||||
"name": "readable-stream",
|
||||
"escapedName": "readable-stream",
|
||||
"rawSpec": "^2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/duplexify"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
|
||||
"_shasum": "1eca1cf711aef814c04f62252a36a62f6cb23b57",
|
||||
"_spec": "readable-stream@^2.0.0",
|
||||
"_where": "C:\\Users\\matia\\Documents\\GitHub\\Musix-V3\\node_modules\\duplexify",
|
||||
"browser": {
|
||||
"util": false,
|
||||
"./readable.js": "./readable-browser.js",
|
||||
"./writable.js": "./writable-browser.js",
|
||||
"./duplex.js": "./duplex-browser.js",
|
||||
"./lib/internal/streams/stream.js": "./lib/internal/streams/stream-browser.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/nodejs/readable-stream/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~2.0.0",
|
||||
"safe-buffer": "~5.1.1",
|
||||
"string_decoder": "~1.1.1",
|
||||
"util-deprecate": "~1.0.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Streams3, a user-land copy of the stream library from Node.js",
|
||||
"devDependencies": {
|
||||
"assert": "^1.4.0",
|
||||
"babel-polyfill": "^6.9.1",
|
||||
"buffer": "^4.9.0",
|
||||
"lolex": "^2.3.2",
|
||||
"nyc": "^6.4.0",
|
||||
"tap": "^0.7.0",
|
||||
"tape": "^4.8.0"
|
||||
},
|
||||
"homepage": "https://github.com/nodejs/readable-stream#readme",
|
||||
"keywords": [
|
||||
"readable",
|
||||
"stream",
|
||||
"pipe"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "readable.js",
|
||||
"name": "readable-stream",
|
||||
"nyc": {
|
||||
"include": [
|
||||
"lib/**.js"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/nodejs/readable-stream.git"
|
||||
},
|
||||
"scripts": {
|
||||
"ci": "tap test/parallel/*.js test/ours/*.js --tap | tee test.tap && node test/verify-dependencies.js",
|
||||
"cover": "nyc npm test",
|
||||
"report": "nyc report --reporter=lcov",
|
||||
"test": "tap test/parallel/*.js test/ours/*.js && node test/verify-dependencies.js"
|
||||
},
|
||||
"version": "2.3.7"
|
||||
}
|
1
node_modules/duplexify/node_modules/readable-stream/passthrough.js
generated
vendored
Normal file
1
node_modules/duplexify/node_modules/readable-stream/passthrough.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('./readable').PassThrough
|
7
node_modules/duplexify/node_modules/readable-stream/readable-browser.js
generated
vendored
Normal file
7
node_modules/duplexify/node_modules/readable-stream/readable-browser.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
exports = module.exports = require('./lib/_stream_readable.js');
|
||||
exports.Stream = exports;
|
||||
exports.Readable = exports;
|
||||
exports.Writable = require('./lib/_stream_writable.js');
|
||||
exports.Duplex = require('./lib/_stream_duplex.js');
|
||||
exports.Transform = require('./lib/_stream_transform.js');
|
||||
exports.PassThrough = require('./lib/_stream_passthrough.js');
|
19
node_modules/duplexify/node_modules/readable-stream/readable.js
generated
vendored
Normal file
19
node_modules/duplexify/node_modules/readable-stream/readable.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
var Stream = require('stream');
|
||||
if (process.env.READABLE_STREAM === 'disable' && Stream) {
|
||||
module.exports = Stream;
|
||||
exports = module.exports = Stream.Readable;
|
||||
exports.Readable = Stream.Readable;
|
||||
exports.Writable = Stream.Writable;
|
||||
exports.Duplex = Stream.Duplex;
|
||||
exports.Transform = Stream.Transform;
|
||||
exports.PassThrough = Stream.PassThrough;
|
||||
exports.Stream = Stream;
|
||||
} else {
|
||||
exports = module.exports = require('./lib/_stream_readable.js');
|
||||
exports.Stream = Stream || exports;
|
||||
exports.Readable = exports;
|
||||
exports.Writable = require('./lib/_stream_writable.js');
|
||||
exports.Duplex = require('./lib/_stream_duplex.js');
|
||||
exports.Transform = require('./lib/_stream_transform.js');
|
||||
exports.PassThrough = require('./lib/_stream_passthrough.js');
|
||||
}
|
1
node_modules/duplexify/node_modules/readable-stream/transform.js
generated
vendored
Normal file
1
node_modules/duplexify/node_modules/readable-stream/transform.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('./readable').Transform
|
1
node_modules/duplexify/node_modules/readable-stream/writable-browser.js
generated
vendored
Normal file
1
node_modules/duplexify/node_modules/readable-stream/writable-browser.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('./lib/_stream_writable.js');
|
8
node_modules/duplexify/node_modules/readable-stream/writable.js
generated
vendored
Normal file
8
node_modules/duplexify/node_modules/readable-stream/writable.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
var Stream = require("stream")
|
||||
var Writable = require("./lib/_stream_writable.js")
|
||||
|
||||
if (process.env.READABLE_STREAM === 'disable') {
|
||||
module.exports = Stream && Stream.Writable || Writable
|
||||
} else {
|
||||
module.exports = Writable
|
||||
}
|
21
node_modules/duplexify/node_modules/safe-buffer/LICENSE
generated
vendored
Normal file
21
node_modules/duplexify/node_modules/safe-buffer/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Feross Aboukhadijeh
|
||||
|
||||
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.
|
584
node_modules/duplexify/node_modules/safe-buffer/README.md
generated
vendored
Normal file
584
node_modules/duplexify/node_modules/safe-buffer/README.md
generated
vendored
Normal file
@ -0,0 +1,584 @@
|
||||
# safe-buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
|
||||
|
||||
[travis-image]: https://img.shields.io/travis/feross/safe-buffer/master.svg
|
||||
[travis-url]: https://travis-ci.org/feross/safe-buffer
|
||||
[npm-image]: https://img.shields.io/npm/v/safe-buffer.svg
|
||||
[npm-url]: https://npmjs.org/package/safe-buffer
|
||||
[downloads-image]: https://img.shields.io/npm/dm/safe-buffer.svg
|
||||
[downloads-url]: https://npmjs.org/package/safe-buffer
|
||||
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
|
||||
[standard-url]: https://standardjs.com
|
||||
|
||||
#### Safer Node.js Buffer API
|
||||
|
||||
**Use the new Node.js Buffer APIs (`Buffer.from`, `Buffer.alloc`,
|
||||
`Buffer.allocUnsafe`, `Buffer.allocUnsafeSlow`) in all versions of Node.js.**
|
||||
|
||||
**Uses the built-in implementation when available.**
|
||||
|
||||
## install
|
||||
|
||||
```
|
||||
npm install safe-buffer
|
||||
```
|
||||
|
||||
## usage
|
||||
|
||||
The goal of this package is to provide a safe replacement for the node.js `Buffer`.
|
||||
|
||||
It's a drop-in replacement for `Buffer`. You can use it by adding one `require` line to
|
||||
the top of your node.js modules:
|
||||
|
||||
```js
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
|
||||
// Existing buffer code will continue to work without issues:
|
||||
|
||||
new Buffer('hey', 'utf8')
|
||||
new Buffer([1, 2, 3], 'utf8')
|
||||
new Buffer(obj)
|
||||
new Buffer(16) // create an uninitialized buffer (potentially unsafe)
|
||||
|
||||
// But you can use these new explicit APIs to make clear what you want:
|
||||
|
||||
Buffer.from('hey', 'utf8') // convert from many types to a Buffer
|
||||
Buffer.alloc(16) // create a zero-filled buffer (safe)
|
||||
Buffer.allocUnsafe(16) // create an uninitialized buffer (potentially unsafe)
|
||||
```
|
||||
|
||||
## api
|
||||
|
||||
### Class Method: Buffer.from(array)
|
||||
<!-- YAML
|
||||
added: v3.0.0
|
||||
-->
|
||||
|
||||
* `array` {Array}
|
||||
|
||||
Allocates a new `Buffer` using an `array` of octets.
|
||||
|
||||
```js
|
||||
const buf = Buffer.from([0x62,0x75,0x66,0x66,0x65,0x72]);
|
||||
// creates a new Buffer containing ASCII bytes
|
||||
// ['b','u','f','f','e','r']
|
||||
```
|
||||
|
||||
A `TypeError` will be thrown if `array` is not an `Array`.
|
||||
|
||||
### Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]])
|
||||
<!-- YAML
|
||||
added: v5.10.0
|
||||
-->
|
||||
|
||||
* `arrayBuffer` {ArrayBuffer} The `.buffer` property of a `TypedArray` or
|
||||
a `new ArrayBuffer()`
|
||||
* `byteOffset` {Number} Default: `0`
|
||||
* `length` {Number} Default: `arrayBuffer.length - byteOffset`
|
||||
|
||||
When passed a reference to the `.buffer` property of a `TypedArray` instance,
|
||||
the newly created `Buffer` will share the same allocated memory as the
|
||||
TypedArray.
|
||||
|
||||
```js
|
||||
const arr = new Uint16Array(2);
|
||||
arr[0] = 5000;
|
||||
arr[1] = 4000;
|
||||
|
||||
const buf = Buffer.from(arr.buffer); // shares the memory with arr;
|
||||
|
||||
console.log(buf);
|
||||
// Prints: <Buffer 88 13 a0 0f>
|
||||
|
||||
// changing the TypedArray changes the Buffer also
|
||||
arr[1] = 6000;
|
||||
|
||||
console.log(buf);
|
||||
// Prints: <Buffer 88 13 70 17>
|
||||
```
|
||||
|
||||
The optional `byteOffset` and `length` arguments specify a memory range within
|
||||
the `arrayBuffer` that will be shared by the `Buffer`.
|
||||
|
||||
```js
|
||||
const ab = new ArrayBuffer(10);
|
||||
const buf = Buffer.from(ab, 0, 2);
|
||||
console.log(buf.length);
|
||||
// Prints: 2
|
||||
```
|
||||
|
||||
A `TypeError` will be thrown if `arrayBuffer` is not an `ArrayBuffer`.
|
||||
|
||||
### Class Method: Buffer.from(buffer)
|
||||
<!-- YAML
|
||||
added: v3.0.0
|
||||
-->
|
||||
|
||||
* `buffer` {Buffer}
|
||||
|
||||
Copies the passed `buffer` data onto a new `Buffer` instance.
|
||||
|
||||
```js
|
||||
const buf1 = Buffer.from('buffer');
|
||||
const buf2 = Buffer.from(buf1);
|
||||
|
||||
buf1[0] = 0x61;
|
||||
console.log(buf1.toString());
|
||||
// 'auffer'
|
||||
console.log(buf2.toString());
|
||||
// 'buffer' (copy is not changed)
|
||||
```
|
||||
|
||||
A `TypeError` will be thrown if `buffer` is not a `Buffer`.
|
||||
|
||||
### Class Method: Buffer.from(str[, encoding])
|
||||
<!-- YAML
|
||||
added: v5.10.0
|
||||
-->
|
||||
|
||||
* `str` {String} String to encode.
|
||||
* `encoding` {String} Encoding to use, Default: `'utf8'`
|
||||
|
||||
Creates a new `Buffer` containing the given JavaScript string `str`. If
|
||||
provided, the `encoding` parameter identifies the character encoding.
|
||||
If not provided, `encoding` defaults to `'utf8'`.
|
||||
|
||||
```js
|
||||
const buf1 = Buffer.from('this is a tést');
|
||||
console.log(buf1.toString());
|
||||
// prints: this is a tést
|
||||
console.log(buf1.toString('ascii'));
|
||||
// prints: this is a tC)st
|
||||
|
||||
const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');
|
||||
console.log(buf2.toString());
|
||||
// prints: this is a tést
|
||||
```
|
||||
|
||||
A `TypeError` will be thrown if `str` is not a string.
|
||||
|
||||
### Class Method: Buffer.alloc(size[, fill[, encoding]])
|
||||
<!-- YAML
|
||||
added: v5.10.0
|
||||
-->
|
||||
|
||||
* `size` {Number}
|
||||
* `fill` {Value} Default: `undefined`
|
||||
* `encoding` {String} Default: `utf8`
|
||||
|
||||
Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the
|
||||
`Buffer` will be *zero-filled*.
|
||||
|
||||
```js
|
||||
const buf = Buffer.alloc(5);
|
||||
console.log(buf);
|
||||
// <Buffer 00 00 00 00 00>
|
||||
```
|
||||
|
||||
The `size` must be less than or equal to the value of
|
||||
`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is
|
||||
`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. A zero-length Buffer will
|
||||
be created if a `size` less than or equal to 0 is specified.
|
||||
|
||||
If `fill` is specified, the allocated `Buffer` will be initialized by calling
|
||||
`buf.fill(fill)`. See [`buf.fill()`][] for more information.
|
||||
|
||||
```js
|
||||
const buf = Buffer.alloc(5, 'a');
|
||||
console.log(buf);
|
||||
// <Buffer 61 61 61 61 61>
|
||||
```
|
||||
|
||||
If both `fill` and `encoding` are specified, the allocated `Buffer` will be
|
||||
initialized by calling `buf.fill(fill, encoding)`. For example:
|
||||
|
||||
```js
|
||||
const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
|
||||
console.log(buf);
|
||||
// <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
|
||||
```
|
||||
|
||||
Calling `Buffer.alloc(size)` can be significantly slower than the alternative
|
||||
`Buffer.allocUnsafe(size)` but ensures that the newly created `Buffer` instance
|
||||
contents will *never contain sensitive data*.
|
||||
|
||||
A `TypeError` will be thrown if `size` is not a number.
|
||||
|
||||
### Class Method: Buffer.allocUnsafe(size)
|
||||
<!-- YAML
|
||||
added: v5.10.0
|
||||
-->
|
||||
|
||||
* `size` {Number}
|
||||
|
||||
Allocates a new *non-zero-filled* `Buffer` of `size` bytes. The `size` must
|
||||
be less than or equal to the value of `require('buffer').kMaxLength` (on 64-bit
|
||||
architectures, `kMaxLength` is `(2^31)-1`). Otherwise, a [`RangeError`][] is
|
||||
thrown. A zero-length Buffer will be created if a `size` less than or equal to
|
||||
0 is specified.
|
||||
|
||||
The underlying memory for `Buffer` instances created in this way is *not
|
||||
initialized*. The contents of the newly created `Buffer` are unknown and
|
||||
*may contain sensitive data*. Use [`buf.fill(0)`][] to initialize such
|
||||
`Buffer` instances to zeroes.
|
||||
|
||||
```js
|
||||
const buf = Buffer.allocUnsafe(5);
|
||||
console.log(buf);
|
||||
// <Buffer 78 e0 82 02 01>
|
||||
// (octets will be different, every time)
|
||||
buf.fill(0);
|
||||
console.log(buf);
|
||||
// <Buffer 00 00 00 00 00>
|
||||
```
|
||||
|
||||
A `TypeError` will be thrown if `size` is not a number.
|
||||
|
||||
Note that the `Buffer` module pre-allocates an internal `Buffer` instance of
|
||||
size `Buffer.poolSize` that is used as a pool for the fast allocation of new
|
||||
`Buffer` instances created using `Buffer.allocUnsafe(size)` (and the deprecated
|
||||
`new Buffer(size)` constructor) only when `size` is less than or equal to
|
||||
`Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two). The default
|
||||
value of `Buffer.poolSize` is `8192` but can be modified.
|
||||
|
||||
Use of this pre-allocated internal memory pool is a key difference between
|
||||
calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
|
||||
Specifically, `Buffer.alloc(size, fill)` will *never* use the internal Buffer
|
||||
pool, while `Buffer.allocUnsafe(size).fill(fill)` *will* use the internal
|
||||
Buffer pool if `size` is less than or equal to half `Buffer.poolSize`. The
|
||||
difference is subtle but can be important when an application requires the
|
||||
additional performance that `Buffer.allocUnsafe(size)` provides.
|
||||
|
||||
### Class Method: Buffer.allocUnsafeSlow(size)
|
||||
<!-- YAML
|
||||
added: v5.10.0
|
||||
-->
|
||||
|
||||
* `size` {Number}
|
||||
|
||||
Allocates a new *non-zero-filled* and non-pooled `Buffer` of `size` bytes. The
|
||||
`size` must be less than or equal to the value of
|
||||
`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is
|
||||
`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. A zero-length Buffer will
|
||||
be created if a `size` less than or equal to 0 is specified.
|
||||
|
||||
The underlying memory for `Buffer` instances created in this way is *not
|
||||
initialized*. The contents of the newly created `Buffer` are unknown and
|
||||
*may contain sensitive data*. Use [`buf.fill(0)`][] to initialize such
|
||||
`Buffer` instances to zeroes.
|
||||
|
||||
When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
|
||||
allocations under 4KB are, by default, sliced from a single pre-allocated
|
||||
`Buffer`. This allows applications to avoid the garbage collection overhead of
|
||||
creating many individually allocated Buffers. This approach improves both
|
||||
performance and memory usage by eliminating the need to track and cleanup as
|
||||
many `Persistent` objects.
|
||||
|
||||
However, in the case where a developer may need to retain a small chunk of
|
||||
memory from a pool for an indeterminate amount of time, it may be appropriate
|
||||
to create an un-pooled Buffer instance using `Buffer.allocUnsafeSlow()` then
|
||||
copy out the relevant bits.
|
||||
|
||||
```js
|
||||
// need to keep around a few small chunks of memory
|
||||
const store = [];
|
||||
|
||||
socket.on('readable', () => {
|
||||
const data = socket.read();
|
||||
// allocate for retained data
|
||||
const sb = Buffer.allocUnsafeSlow(10);
|
||||
// copy the data into the new allocation
|
||||
data.copy(sb, 0, 0, 10);
|
||||
store.push(sb);
|
||||
});
|
||||
```
|
||||
|
||||
Use of `Buffer.allocUnsafeSlow()` should be used only as a last resort *after*
|
||||
a developer has observed undue memory retention in their applications.
|
||||
|
||||
A `TypeError` will be thrown if `size` is not a number.
|
||||
|
||||
### All the Rest
|
||||
|
||||
The rest of the `Buffer` API is exactly the same as in node.js.
|
||||
[See the docs](https://nodejs.org/api/buffer.html).
|
||||
|
||||
|
||||
## Related links
|
||||
|
||||
- [Node.js issue: Buffer(number) is unsafe](https://github.com/nodejs/node/issues/4660)
|
||||
- [Node.js Enhancement Proposal: Buffer.from/Buffer.alloc/Buffer.zalloc/Buffer() soft-deprecate](https://github.com/nodejs/node-eps/pull/4)
|
||||
|
||||
## Why is `Buffer` unsafe?
|
||||
|
||||
Today, the node.js `Buffer` constructor is overloaded to handle many different argument
|
||||
types like `String`, `Array`, `Object`, `TypedArrayView` (`Uint8Array`, etc.),
|
||||
`ArrayBuffer`, and also `Number`.
|
||||
|
||||
The API is optimized for convenience: you can throw any type at it, and it will try to do
|
||||
what you want.
|
||||
|
||||
Because the Buffer constructor is so powerful, you often see code like this:
|
||||
|
||||
```js
|
||||
// Convert UTF-8 strings to hex
|
||||
function toHex (str) {
|
||||
return new Buffer(str).toString('hex')
|
||||
}
|
||||
```
|
||||
|
||||
***But what happens if `toHex` is called with a `Number` argument?***
|
||||
|
||||
### Remote Memory Disclosure
|
||||
|
||||
If an attacker can make your program call the `Buffer` constructor with a `Number`
|
||||
argument, then they can make it allocate uninitialized memory from the node.js process.
|
||||
This could potentially disclose TLS private keys, user data, or database passwords.
|
||||
|
||||
When the `Buffer` constructor is passed a `Number` argument, it returns an
|
||||
**UNINITIALIZED** block of memory of the specified `size`. When you create a `Buffer` like
|
||||
this, you **MUST** overwrite the contents before returning it to the user.
|
||||
|
||||
From the [node.js docs](https://nodejs.org/api/buffer.html#buffer_new_buffer_size):
|
||||
|
||||
> `new Buffer(size)`
|
||||
>
|
||||
> - `size` Number
|
||||
>
|
||||
> The underlying memory for `Buffer` instances created in this way is not initialized.
|
||||
> **The contents of a newly created `Buffer` are unknown and could contain sensitive
|
||||
> data.** Use `buf.fill(0)` to initialize a Buffer to zeroes.
|
||||
|
||||
(Emphasis our own.)
|
||||
|
||||
Whenever the programmer intended to create an uninitialized `Buffer` you often see code
|
||||
like this:
|
||||
|
||||
```js
|
||||
var buf = new Buffer(16)
|
||||
|
||||
// Immediately overwrite the uninitialized buffer with data from another buffer
|
||||
for (var i = 0; i < buf.length; i++) {
|
||||
buf[i] = otherBuf[i]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Would this ever be a problem in real code?
|
||||
|
||||
Yes. It's surprisingly common to forget to check the type of your variables in a
|
||||
dynamically-typed language like JavaScript.
|
||||
|
||||
Usually the consequences of assuming the wrong type is that your program crashes with an
|
||||
uncaught exception. But the failure mode for forgetting to check the type of arguments to
|
||||
the `Buffer` constructor is more catastrophic.
|
||||
|
||||
Here's an example of a vulnerable service that takes a JSON payload and converts it to
|
||||
hex:
|
||||
|
||||
```js
|
||||
// Take a JSON payload {str: "some string"} and convert it to hex
|
||||
var server = http.createServer(function (req, res) {
|
||||
var data = ''
|
||||
req.setEncoding('utf8')
|
||||
req.on('data', function (chunk) {
|
||||
data += chunk
|
||||
})
|
||||
req.on('end', function () {
|
||||
var body = JSON.parse(data)
|
||||
res.end(new Buffer(body.str).toString('hex'))
|
||||
})
|
||||
})
|
||||
|
||||
server.listen(8080)
|
||||
```
|
||||
|
||||
In this example, an http client just has to send:
|
||||
|
||||
```json
|
||||
{
|
||||
"str": 1000
|
||||
}
|
||||
```
|
||||
|
||||
and it will get back 1,000 bytes of uninitialized memory from the server.
|
||||
|
||||
This is a very serious bug. It's similar in severity to the
|
||||
[the Heartbleed bug](http://heartbleed.com/) that allowed disclosure of OpenSSL process
|
||||
memory by remote attackers.
|
||||
|
||||
|
||||
### Which real-world packages were vulnerable?
|
||||
|
||||
#### [`bittorrent-dht`](https://www.npmjs.com/package/bittorrent-dht)
|
||||
|
||||
[Mathias Buus](https://github.com/mafintosh) and I
|
||||
([Feross Aboukhadijeh](http://feross.org/)) found this issue in one of our own packages,
|
||||
[`bittorrent-dht`](https://www.npmjs.com/package/bittorrent-dht). The bug would allow
|
||||
anyone on the internet to send a series of messages to a user of `bittorrent-dht` and get
|
||||
them to reveal 20 bytes at a time of uninitialized memory from the node.js process.
|
||||
|
||||
Here's
|
||||
[the commit](https://github.com/feross/bittorrent-dht/commit/6c7da04025d5633699800a99ec3fbadf70ad35b8)
|
||||
that fixed it. We released a new fixed version, created a
|
||||
[Node Security Project disclosure](https://nodesecurity.io/advisories/68), and deprecated all
|
||||
vulnerable versions on npm so users will get a warning to upgrade to a newer version.
|
||||
|
||||
#### [`ws`](https://www.npmjs.com/package/ws)
|
||||
|
||||
That got us wondering if there were other vulnerable packages. Sure enough, within a short
|
||||
period of time, we found the same issue in [`ws`](https://www.npmjs.com/package/ws), the
|
||||
most popular WebSocket implementation in node.js.
|
||||
|
||||
If certain APIs were called with `Number` parameters instead of `String` or `Buffer` as
|
||||
expected, then uninitialized server memory would be disclosed to the remote peer.
|
||||
|
||||
These were the vulnerable methods:
|
||||
|
||||
```js
|
||||
socket.send(number)
|
||||
socket.ping(number)
|
||||
socket.pong(number)
|
||||
```
|
||||
|
||||
Here's a vulnerable socket server with some echo functionality:
|
||||
|
||||
```js
|
||||
server.on('connection', function (socket) {
|
||||
socket.on('message', function (message) {
|
||||
message = JSON.parse(message)
|
||||
if (message.type === 'echo') {
|
||||
socket.send(message.data) // send back the user's message
|
||||
}
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
`socket.send(number)` called on the server, will disclose server memory.
|
||||
|
||||
Here's [the release](https://github.com/websockets/ws/releases/tag/1.0.1) where the issue
|
||||
was fixed, with a more detailed explanation. Props to
|
||||
[Arnout Kazemier](https://github.com/3rd-Eden) for the quick fix. Here's the
|
||||
[Node Security Project disclosure](https://nodesecurity.io/advisories/67).
|
||||
|
||||
|
||||
### What's the solution?
|
||||
|
||||
It's important that node.js offers a fast way to get memory otherwise performance-critical
|
||||
applications would needlessly get a lot slower.
|
||||
|
||||
But we need a better way to *signal our intent* as programmers. **When we want
|
||||
uninitialized memory, we should request it explicitly.**
|
||||
|
||||
Sensitive functionality should not be packed into a developer-friendly API that loosely
|
||||
accepts many different types. This type of API encourages the lazy practice of passing
|
||||
variables in without checking the type very carefully.
|
||||
|
||||
#### A new API: `Buffer.allocUnsafe(number)`
|
||||
|
||||
The functionality of creating buffers with uninitialized memory should be part of another
|
||||
API. We propose `Buffer.allocUnsafe(number)`. This way, it's not part of an API that
|
||||
frequently gets user input of all sorts of different types passed into it.
|
||||
|
||||
```js
|
||||
var buf = Buffer.allocUnsafe(16) // careful, uninitialized memory!
|
||||
|
||||
// Immediately overwrite the uninitialized buffer with data from another buffer
|
||||
for (var i = 0; i < buf.length; i++) {
|
||||
buf[i] = otherBuf[i]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### How do we fix node.js core?
|
||||
|
||||
We sent [a PR to node.js core](https://github.com/nodejs/node/pull/4514) (merged as
|
||||
`semver-major`) which defends against one case:
|
||||
|
||||
```js
|
||||
var str = 16
|
||||
new Buffer(str, 'utf8')
|
||||
```
|
||||
|
||||
In this situation, it's implied that the programmer intended the first argument to be a
|
||||
string, since they passed an encoding as a second argument. Today, node.js will allocate
|
||||
uninitialized memory in the case of `new Buffer(number, encoding)`, which is probably not
|
||||
what the programmer intended.
|
||||
|
||||
But this is only a partial solution, since if the programmer does `new Buffer(variable)`
|
||||
(without an `encoding` parameter) there's no way to know what they intended. If `variable`
|
||||
is sometimes a number, then uninitialized memory will sometimes be returned.
|
||||
|
||||
### What's the real long-term fix?
|
||||
|
||||
We could deprecate and remove `new Buffer(number)` and use `Buffer.allocUnsafe(number)` when
|
||||
we need uninitialized memory. But that would break 1000s of packages.
|
||||
|
||||
~~We believe the best solution is to:~~
|
||||
|
||||
~~1. Change `new Buffer(number)` to return safe, zeroed-out memory~~
|
||||
|
||||
~~2. Create a new API for creating uninitialized Buffers. We propose: `Buffer.allocUnsafe(number)`~~
|
||||
|
||||
#### Update
|
||||
|
||||
We now support adding three new APIs:
|
||||
|
||||
- `Buffer.from(value)` - convert from any type to a buffer
|
||||
- `Buffer.alloc(size)` - create a zero-filled buffer
|
||||
- `Buffer.allocUnsafe(size)` - create an uninitialized buffer with given size
|
||||
|
||||
This solves the core problem that affected `ws` and `bittorrent-dht` which is
|
||||
`Buffer(variable)` getting tricked into taking a number argument.
|
||||
|
||||
This way, existing code continues working and the impact on the npm ecosystem will be
|
||||
minimal. Over time, npm maintainers can migrate performance-critical code to use
|
||||
`Buffer.allocUnsafe(number)` instead of `new Buffer(number)`.
|
||||
|
||||
|
||||
### Conclusion
|
||||
|
||||
We think there's a serious design issue with the `Buffer` API as it exists today. It
|
||||
promotes insecure software by putting high-risk functionality into a convenient API
|
||||
with friendly "developer ergonomics".
|
||||
|
||||
This wasn't merely a theoretical exercise because we found the issue in some of the
|
||||
most popular npm packages.
|
||||
|
||||
Fortunately, there's an easy fix that can be applied today. Use `safe-buffer` in place of
|
||||
`buffer`.
|
||||
|
||||
```js
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
```
|
||||
|
||||
Eventually, we hope that node.js core can switch to this new, safer behavior. We believe
|
||||
the impact on the ecosystem would be minimal since it's not a breaking change.
|
||||
Well-maintained, popular packages would be updated to use `Buffer.alloc` quickly, while
|
||||
older, insecure packages would magically become safe from this attack vector.
|
||||
|
||||
|
||||
## links
|
||||
|
||||
- [Node.js PR: buffer: throw if both length and enc are passed](https://github.com/nodejs/node/pull/4514)
|
||||
- [Node Security Project disclosure for `ws`](https://nodesecurity.io/advisories/67)
|
||||
- [Node Security Project disclosure for`bittorrent-dht`](https://nodesecurity.io/advisories/68)
|
||||
|
||||
|
||||
## credit
|
||||
|
||||
The original issues in `bittorrent-dht`
|
||||
([disclosure](https://nodesecurity.io/advisories/68)) and
|
||||
`ws` ([disclosure](https://nodesecurity.io/advisories/67)) were discovered by
|
||||
[Mathias Buus](https://github.com/mafintosh) and
|
||||
[Feross Aboukhadijeh](http://feross.org/).
|
||||
|
||||
Thanks to [Adam Baldwin](https://github.com/evilpacket) for helping disclose these issues
|
||||
and for his work running the [Node Security Project](https://nodesecurity.io/).
|
||||
|
||||
Thanks to [John Hiesey](https://github.com/jhiesey) for proofreading this README and
|
||||
auditing the code.
|
||||
|
||||
|
||||
## license
|
||||
|
||||
MIT. Copyright (C) [Feross Aboukhadijeh](http://feross.org)
|
187
node_modules/duplexify/node_modules/safe-buffer/index.d.ts
generated
vendored
Normal file
187
node_modules/duplexify/node_modules/safe-buffer/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,187 @@
|
||||
declare module "safe-buffer" {
|
||||
export class Buffer {
|
||||
length: number
|
||||
write(string: string, offset?: number, length?: number, encoding?: string): number;
|
||||
toString(encoding?: string, start?: number, end?: number): string;
|
||||
toJSON(): { type: 'Buffer', data: any[] };
|
||||
equals(otherBuffer: Buffer): boolean;
|
||||
compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
|
||||
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
|
||||
slice(start?: number, end?: number): Buffer;
|
||||
writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readUInt8(offset: number, noAssert?: boolean): number;
|
||||
readUInt16LE(offset: number, noAssert?: boolean): number;
|
||||
readUInt16BE(offset: number, noAssert?: boolean): number;
|
||||
readUInt32LE(offset: number, noAssert?: boolean): number;
|
||||
readUInt32BE(offset: number, noAssert?: boolean): number;
|
||||
readInt8(offset: number, noAssert?: boolean): number;
|
||||
readInt16LE(offset: number, noAssert?: boolean): number;
|
||||
readInt16BE(offset: number, noAssert?: boolean): number;
|
||||
readInt32LE(offset: number, noAssert?: boolean): number;
|
||||
readInt32BE(offset: number, noAssert?: boolean): number;
|
||||
readFloatLE(offset: number, noAssert?: boolean): number;
|
||||
readFloatBE(offset: number, noAssert?: boolean): number;
|
||||
readDoubleLE(offset: number, noAssert?: boolean): number;
|
||||
readDoubleBE(offset: number, noAssert?: boolean): number;
|
||||
swap16(): Buffer;
|
||||
swap32(): Buffer;
|
||||
swap64(): Buffer;
|
||||
writeUInt8(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt8(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
|
||||
fill(value: any, offset?: number, end?: number): this;
|
||||
indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
|
||||
lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
|
||||
includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean;
|
||||
|
||||
/**
|
||||
* Allocates a new buffer containing the given {str}.
|
||||
*
|
||||
* @param str String to store in buffer.
|
||||
* @param encoding encoding to use, optional. Default is 'utf8'
|
||||
*/
|
||||
constructor (str: string, encoding?: string);
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets.
|
||||
*
|
||||
* @param size count of octets to allocate.
|
||||
*/
|
||||
constructor (size: number);
|
||||
/**
|
||||
* Allocates a new buffer containing the given {array} of octets.
|
||||
*
|
||||
* @param array The octets to store.
|
||||
*/
|
||||
constructor (array: Uint8Array);
|
||||
/**
|
||||
* Produces a Buffer backed by the same allocated memory as
|
||||
* the given {ArrayBuffer}.
|
||||
*
|
||||
*
|
||||
* @param arrayBuffer The ArrayBuffer with which to share memory.
|
||||
*/
|
||||
constructor (arrayBuffer: ArrayBuffer);
|
||||
/**
|
||||
* Allocates a new buffer containing the given {array} of octets.
|
||||
*
|
||||
* @param array The octets to store.
|
||||
*/
|
||||
constructor (array: any[]);
|
||||
/**
|
||||
* Copies the passed {buffer} data onto a new {Buffer} instance.
|
||||
*
|
||||
* @param buffer The buffer to copy.
|
||||
*/
|
||||
constructor (buffer: Buffer);
|
||||
prototype: Buffer;
|
||||
/**
|
||||
* Allocates a new Buffer using an {array} of octets.
|
||||
*
|
||||
* @param array
|
||||
*/
|
||||
static from(array: any[]): Buffer;
|
||||
/**
|
||||
* When passed a reference to the .buffer property of a TypedArray instance,
|
||||
* the newly created Buffer will share the same allocated memory as the TypedArray.
|
||||
* The optional {byteOffset} and {length} arguments specify a memory range
|
||||
* within the {arrayBuffer} that will be shared by the Buffer.
|
||||
*
|
||||
* @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer()
|
||||
* @param byteOffset
|
||||
* @param length
|
||||
*/
|
||||
static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
|
||||
/**
|
||||
* Copies the passed {buffer} data onto a new Buffer instance.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
static from(buffer: Buffer): Buffer;
|
||||
/**
|
||||
* Creates a new Buffer containing the given JavaScript string {str}.
|
||||
* If provided, the {encoding} parameter identifies the character encoding.
|
||||
* If not provided, {encoding} defaults to 'utf8'.
|
||||
*
|
||||
* @param str
|
||||
*/
|
||||
static from(str: string, encoding?: string): Buffer;
|
||||
/**
|
||||
* Returns true if {obj} is a Buffer
|
||||
*
|
||||
* @param obj object to test.
|
||||
*/
|
||||
static isBuffer(obj: any): obj is Buffer;
|
||||
/**
|
||||
* Returns true if {encoding} is a valid encoding argument.
|
||||
* Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
|
||||
*
|
||||
* @param encoding string to test.
|
||||
*/
|
||||
static isEncoding(encoding: string): boolean;
|
||||
/**
|
||||
* Gives the actual byte length of a string. encoding defaults to 'utf8'.
|
||||
* This is not the same as String.prototype.length since that returns the number of characters in a string.
|
||||
*
|
||||
* @param string string to test.
|
||||
* @param encoding encoding used to evaluate (defaults to 'utf8')
|
||||
*/
|
||||
static byteLength(string: string, encoding?: string): number;
|
||||
/**
|
||||
* Returns a buffer which is the result of concatenating all the buffers in the list together.
|
||||
*
|
||||
* If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
|
||||
* If the list has exactly one item, then the first item of the list is returned.
|
||||
* If the list has more than one item, then a new Buffer is created.
|
||||
*
|
||||
* @param list An array of Buffer objects to concatenate
|
||||
* @param totalLength Total length of the buffers when concatenated.
|
||||
* If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
|
||||
*/
|
||||
static concat(list: Buffer[], totalLength?: number): Buffer;
|
||||
/**
|
||||
* The same as buf1.compare(buf2).
|
||||
*/
|
||||
static compare(buf1: Buffer, buf2: Buffer): number;
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets.
|
||||
*
|
||||
* @param size count of octets to allocate.
|
||||
* @param fill if specified, buffer will be initialized by calling buf.fill(fill).
|
||||
* If parameter is omitted, buffer will be filled with zeros.
|
||||
* @param encoding encoding used for call to buf.fill while initalizing
|
||||
*/
|
||||
static alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer;
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
|
||||
* of the newly created Buffer are unknown and may contain sensitive data.
|
||||
*
|
||||
* @param size count of octets to allocate
|
||||
*/
|
||||
static allocUnsafe(size: number): Buffer;
|
||||
/**
|
||||
* Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
|
||||
* of the newly created Buffer are unknown and may contain sensitive data.
|
||||
*
|
||||
* @param size count of octets to allocate
|
||||
*/
|
||||
static allocUnsafeSlow(size: number): Buffer;
|
||||
}
|
||||
}
|
62
node_modules/duplexify/node_modules/safe-buffer/index.js
generated
vendored
Normal file
62
node_modules/duplexify/node_modules/safe-buffer/index.js
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
/* eslint-disable node/no-deprecated-api */
|
||||
var buffer = require('buffer')
|
||||
var Buffer = buffer.Buffer
|
||||
|
||||
// alternative to using Object.keys for old browsers
|
||||
function copyProps (src, dst) {
|
||||
for (var key in src) {
|
||||
dst[key] = src[key]
|
||||
}
|
||||
}
|
||||
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
||||
module.exports = buffer
|
||||
} else {
|
||||
// Copy properties from require('buffer')
|
||||
copyProps(buffer, exports)
|
||||
exports.Buffer = SafeBuffer
|
||||
}
|
||||
|
||||
function SafeBuffer (arg, encodingOrOffset, length) {
|
||||
return Buffer(arg, encodingOrOffset, length)
|
||||
}
|
||||
|
||||
// Copy static methods from Buffer
|
||||
copyProps(Buffer, SafeBuffer)
|
||||
|
||||
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
||||
if (typeof arg === 'number') {
|
||||
throw new TypeError('Argument must not be a number')
|
||||
}
|
||||
return Buffer(arg, encodingOrOffset, length)
|
||||
}
|
||||
|
||||
SafeBuffer.alloc = function (size, fill, encoding) {
|
||||
if (typeof size !== 'number') {
|
||||
throw new TypeError('Argument must be a number')
|
||||
}
|
||||
var buf = Buffer(size)
|
||||
if (fill !== undefined) {
|
||||
if (typeof encoding === 'string') {
|
||||
buf.fill(fill, encoding)
|
||||
} else {
|
||||
buf.fill(fill)
|
||||
}
|
||||
} else {
|
||||
buf.fill(0)
|
||||
}
|
||||
return buf
|
||||
}
|
||||
|
||||
SafeBuffer.allocUnsafe = function (size) {
|
||||
if (typeof size !== 'number') {
|
||||
throw new TypeError('Argument must be a number')
|
||||
}
|
||||
return Buffer(size)
|
||||
}
|
||||
|
||||
SafeBuffer.allocUnsafeSlow = function (size) {
|
||||
if (typeof size !== 'number') {
|
||||
throw new TypeError('Argument must be a number')
|
||||
}
|
||||
return buffer.SlowBuffer(size)
|
||||
}
|
62
node_modules/duplexify/node_modules/safe-buffer/package.json
generated
vendored
Normal file
62
node_modules/duplexify/node_modules/safe-buffer/package.json
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"_from": "safe-buffer@~5.1.1",
|
||||
"_id": "safe-buffer@5.1.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
|
||||
"_location": "/duplexify/safe-buffer",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "safe-buffer@~5.1.1",
|
||||
"name": "safe-buffer",
|
||||
"escapedName": "safe-buffer",
|
||||
"rawSpec": "~5.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~5.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/duplexify/readable-stream"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"_shasum": "991ec69d296e0313747d59bdfd2b745c35f8828d",
|
||||
"_spec": "safe-buffer@~5.1.1",
|
||||
"_where": "C:\\Users\\matia\\Documents\\GitHub\\Musix-V3\\node_modules\\duplexify\\node_modules\\readable-stream",
|
||||
"author": {
|
||||
"name": "Feross Aboukhadijeh",
|
||||
"email": "feross@feross.org",
|
||||
"url": "http://feross.org"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/feross/safe-buffer/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Safer Node.js Buffer API",
|
||||
"devDependencies": {
|
||||
"standard": "*",
|
||||
"tape": "^4.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/feross/safe-buffer",
|
||||
"keywords": [
|
||||
"buffer",
|
||||
"buffer allocate",
|
||||
"node security",
|
||||
"safe",
|
||||
"safe-buffer",
|
||||
"security",
|
||||
"uninitialized"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "safe-buffer",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/feross/safe-buffer.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && tape test/*.js"
|
||||
},
|
||||
"types": "index.d.ts",
|
||||
"version": "5.1.2"
|
||||
}
|
78
node_modules/duplexify/package.json
generated
vendored
Normal file
78
node_modules/duplexify/package.json
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"duplexify@3.7.1",
|
||||
"C:\\Users\\matia\\Musix"
|
||||
]
|
||||
],
|
||||
"_from": "duplexify@3.7.1",
|
||||
"_id": "duplexify@3.7.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==",
|
||||
"_location": "/duplexify",
|
||||
"_optional": true,
|
||||
"_phantomChildren": {
|
||||
"core-util-is": "1.0.2",
|
||||
"inherits": "2.0.4",
|
||||
"process-nextick-args": "2.0.1",
|
||||
"safe-buffer": "5.1.2",
|
||||
"util-deprecate": "1.0.2"
|
||||
},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "duplexify@3.7.1",
|
||||
"name": "duplexify",
|
||||
"escapedName": "duplexify",
|
||||
"rawSpec": "3.7.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "3.7.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@google-cloud/common",
|
||||
"/@google-cloud/storage",
|
||||
"/google-gax"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz",
|
||||
"_spec": "3.7.1",
|
||||
"_where": "C:\\Users\\matia\\Musix",
|
||||
"author": {
|
||||
"name": "Mathias Buus"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mafintosh/duplexify/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"end-of-stream": "^1.0.0",
|
||||
"inherits": "^2.0.1",
|
||||
"readable-stream": "^2.0.0",
|
||||
"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": "3.7.1"
|
||||
}
|
295
node_modules/duplexify/test.js
generated
vendored
Normal file
295
node_modules/duplexify/test.js
generated
vendored
Normal file
@ -0,0 +1,295 @@
|
||||
var tape = require('tape')
|
||||
var through = require('through2')
|
||||
var concat = require('concat-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('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)
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user