mirror of
https://github.com/azure/login.git
synced 2026-06-06 12:17:07 +00:00
* Bump lodash from 4.17.15 to 4.17.19 (#52) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Amruta Kawade <65217380+AmrutaKawade@users.noreply.github.com> * Bump @actions/core from 1.1.3 to 1.2.6 (#60) Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.1.3 to 1.2.6. - [Release notes](https://github.com/actions/toolkit/releases) - [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Amruta Kawade <65217380+AmrutaKawade@users.noreply.github.com> * updating node_nodules * updated package-lock Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
107 lines
2.3 KiB
JavaScript
107 lines
2.3 KiB
JavaScript
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));
|
|
};
|