| 15488 | // node_modules/delayed-stream/lib/delayed_stream.js |
| 15489 | var require_delayed_stream = __commonJS({ |
| 15490 | "node_modules/delayed-stream/lib/delayed_stream.js"(exports2, module2) { |
| 15491 | var Stream3 = require("stream").Stream; |
| 15492 | var util4 = require("util"); |
| 15493 | module2.exports = DelayedStream; |
| 15494 | function DelayedStream() { |
| 15495 | this.source = null; |
| 15496 | this.dataSize = 0; |
| 15497 | this.maxDataSize = 1024 * 1024; |
| 15498 | this.pauseStream = true; |
| 15499 | this._maxDataSizeExceeded = false; |
| 15500 | this._released = false; |
| 15501 | this._bufferedEvents = []; |
| 15502 | } |
| 15503 | util4.inherits(DelayedStream, Stream3); |
| 15504 | DelayedStream.create = function(source, options) { |
| 15505 | var delayedStream = new this(); |
| 15506 | options = options || {}; |
| 15507 | for (var option in options) { |
| 15508 | delayedStream[option] = options[option]; |
| 15509 | } |
| 15510 | delayedStream.source = source; |
| 15511 | var realEmit = source.emit; |
| 15512 | source.emit = function() { |
| 15513 | delayedStream._handleEmit(arguments); |
| 15514 | return realEmit.apply(source, arguments); |
| 15515 | }; |
| 15516 | source.on("error", function() { |
| 15517 | }); |
| 15518 | if (delayedStream.pauseStream) { |
| 15519 | source.pause(); |
| 15520 | } |
| 15521 | return delayedStream; |
| 15522 | }; |
| 15523 | Object.defineProperty(DelayedStream.prototype, "readable", { |
| 15524 | configurable: true, |
| 15525 | enumerable: true, |
| 15526 | get: function() { |
| 15527 | return this.source.readable; |
| 15528 | } |
| 15529 | }); |
| 15530 | DelayedStream.prototype.setEncoding = function() { |
| 15531 | return this.source.setEncoding.apply(this.source, arguments); |
| 15532 | }; |
| 15533 | DelayedStream.prototype.resume = function() { |
| 15534 | if (!this._released) { |
| 15535 | this.release(); |
| 15536 | } |
| 15537 | this.source.resume(); |
| 15538 | }; |
| 15539 | DelayedStream.prototype.pause = function() { |
| 15540 | this.source.pause(); |
| 15541 | }; |
| 15542 | DelayedStream.prototype.release = function() { |
| 15543 | this._released = true; |
| 15544 | this._bufferedEvents.forEach(function(args) { |
| 15545 | this.emit.apply(this, args); |
| 15546 | }.bind(this)); |
| 15547 | this._bufferedEvents = []; |