This commit is contained in:
Stephen Franceschelli 2019-07-30 13:41:05 -04:00
parent 596a6da241
commit c1a589c5b6
7078 changed files with 1882834 additions and 319 deletions

1
node_modules/delayed-stream/.npmignore generated vendored Normal file
View file

@ -0,0 +1 @@
test

19
node_modules/delayed-stream/License generated vendored Normal file
View file

@ -0,0 +1,19 @@
Copyright (c) 2011 Debuggable Limited <felix@debuggable.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.

7
node_modules/delayed-stream/Makefile generated vendored Normal file
View file

@ -0,0 +1,7 @@
SHELL := /bin/bash
test:
@./test/run.js
.PHONY: test

141
node_modules/delayed-stream/Readme.md generated vendored Normal file
View file

@ -0,0 +1,141 @@
# delayed-stream
Buffers events from a stream until you are ready to handle them.
## Installation
``` bash
npm install delayed-stream
```
## Usage
The following example shows how to write a http echo server that delays its
response by 1000 ms.
``` javascript
var DelayedStream = require('delayed-stream');
var http = require('http');
http.createServer(function(req, res) {
var delayed = DelayedStream.create(req);
setTimeout(function() {
res.writeHead(200);
delayed.pipe(res);
}, 1000);
});
```
If you are not using `Stream#pipe`, you can also manually release the buffered
events by calling `delayedStream.resume()`:
``` javascript
var delayed = DelayedStream.create(req);
setTimeout(function() {
// Emit all buffered events and resume underlaying source
delayed.resume();
}, 1000);
```
## Implementation
In order to use this meta stream properly, here are a few things you should
know about the implementation.
### Event Buffering / Proxying
All events of the `source` stream are hijacked by overwriting the `source.emit`
method. Until node implements a catch-all event listener, this is the only way.
However, delayed-stream still continues to emit all events it captures on the
`source`, regardless of whether you have released the delayed stream yet or
not.
Upon creation, delayed-stream captures all `source` events and stores them in
an internal event buffer. Once `delayedStream.release()` is called, all
buffered events are emitted on the `delayedStream`, and the event buffer is
cleared. After that, delayed-stream merely acts as a proxy for the underlaying
source.
### Error handling
Error events on `source` are buffered / proxied just like any other events.
However, `delayedStream.create` attaches a no-op `'error'` listener to the
`source`. This way you only have to handle errors on the `delayedStream`
object, rather than in two places.
### Buffer limits
delayed-stream provides a `maxDataSize` property that can be used to limit
the amount of data being buffered. In order to protect you from bad `source`
streams that don't react to `source.pause()`, this feature is enabled by
default.
## API
### DelayedStream.create(source, [options])
Returns a new `delayedStream`. Available options are:
* `pauseStream`
* `maxDataSize`
The description for those properties can be found below.
### delayedStream.source
The `source` stream managed by this object. This is useful if you are
passing your `delayedStream` around, and you still want to access properties
on the `source` object.
### delayedStream.pauseStream = true
Whether to pause the underlaying `source` when calling
`DelayedStream.create()`. Modifying this property afterwards has no effect.
### delayedStream.maxDataSize = 1024 * 1024
The amount of data to buffer before emitting an `error`.
If the underlaying source is emitting `Buffer` objects, the `maxDataSize`
refers to bytes.
If the underlaying source is emitting JavaScript strings, the size refers to
characters.
If you know what you are doing, you can set this property to `Infinity` to
disable this feature. You can also modify this property during runtime.
### delayedStream.dataSize = 0
The amount of data buffered so far.
### delayedStream.readable
An ECMA5 getter that returns the value of `source.readable`.
### delayedStream.resume()
If the `delayedStream` has not been released so far, `delayedStream.release()`
is called.
In either case, `source.resume()` is called.
### delayedStream.pause()
Calls `source.pause()`.
### delayedStream.pipe(dest)
Calls `delayedStream.resume()` and then proxies the arguments to `source.pipe`.
### delayedStream.release()
Emits and clears all events that have been buffered up so far. This does not
resume the underlaying source, use `delayedStream.resume()` instead.
## License
delayed-stream is licensed under the MIT license.

107
node_modules/delayed-stream/lib/delayed_stream.js generated vendored Normal file
View file

@ -0,0 +1,107 @@
var Stream = require('stream').Stream;
var util = require('util');
module.exports = DelayedStream;
function DelayedStream() {
this.source = null;
this.dataSize = 0;
this.maxDataSize = 1024 * 1024;
this.pauseStream = true;
this._maxDataSizeExceeded = false;
this._released = false;
this._bufferedEvents = [];
}
util.inherits(DelayedStream, Stream);
DelayedStream.create = function(source, options) {
var delayedStream = new this();
options = options || {};
for (var option in options) {
delayedStream[option] = options[option];
}
delayedStream.source = source;
var realEmit = source.emit;
source.emit = function() {
delayedStream._handleEmit(arguments);
return realEmit.apply(source, arguments);
};
source.on('error', function() {});
if (delayedStream.pauseStream) {
source.pause();
}
return delayedStream;
};
Object.defineProperty(DelayedStream.prototype, 'readable', {
configurable: true,
enumerable: true,
get: function() {
return this.source.readable;
}
});
DelayedStream.prototype.setEncoding = function() {
return this.source.setEncoding.apply(this.source, arguments);
};
DelayedStream.prototype.resume = function() {
if (!this._released) {
this.release();
}
this.source.resume();
};
DelayedStream.prototype.pause = function() {
this.source.pause();
};
DelayedStream.prototype.release = function() {
this._released = true;
this._bufferedEvents.forEach(function(args) {
this.emit.apply(this, args);
}.bind(this));
this._bufferedEvents = [];
};
DelayedStream.prototype.pipe = function() {
var r = Stream.prototype.pipe.apply(this, arguments);
this.resume();
return r;
};
DelayedStream.prototype._handleEmit = function(args) {
if (this._released) {
this.emit.apply(this, args);
return;
}
if (args[0] === 'data') {
this.dataSize += args[1].length;
this._checkIfMaxDataSizeExceeded();
}
this._bufferedEvents.push(args);
};
DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
if (this._maxDataSizeExceeded) {
return;
}
if (this.dataSize <= this.maxDataSize) {
return;
}
this._maxDataSizeExceeded = true;
var message =
'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.'
this.emit('error', new Error(message));
};

62
node_modules/delayed-stream/package.json generated vendored Normal file
View file

@ -0,0 +1,62 @@
{
"_from": "delayed-stream@~1.0.0",
"_id": "delayed-stream@1.0.0",
"_inBundle": false,
"_integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
"_location": "/delayed-stream",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "delayed-stream@~1.0.0",
"name": "delayed-stream",
"escapedName": "delayed-stream",
"rawSpec": "~1.0.0",
"saveSpec": null,
"fetchSpec": "~1.0.0"
},
"_requiredBy": [
"/combined-stream"
],
"_resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"_shasum": "df3ae199acadfb7d440aaae0b29e2272b24ec619",
"_spec": "delayed-stream@~1.0.0",
"_where": "E:\\github\\setup-java\\node_modules\\combined-stream",
"author": {
"name": "Felix Geisendörfer",
"email": "felix@debuggable.com",
"url": "http://debuggable.com/"
},
"bugs": {
"url": "https://github.com/felixge/node-delayed-stream/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Mike Atkins",
"email": "apeherder@gmail.com"
}
],
"dependencies": {},
"deprecated": false,
"description": "Buffers events from a stream until you are ready to handle them.",
"devDependencies": {
"fake": "0.2.0",
"far": "0.0.1"
},
"engines": {
"node": ">=0.4.0"
},
"homepage": "https://github.com/felixge/node-delayed-stream",
"license": "MIT",
"main": "./lib/delayed_stream",
"name": "delayed-stream",
"repository": {
"type": "git",
"url": "git://github.com/felixge/node-delayed-stream.git"
},
"scripts": {
"test": "make test"
},
"version": "1.0.0"
}