@scrabble-solver/scrabble-solver 2.10.8 → 2.10.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +15 -15
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/eslint/.cache_8dgz12 +1 -1
- package/.next/cache/next-server.js.nft.json +1 -1
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/edge-server-production/0.pack +0 -0
- package/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/images-manifest.json +1 -1
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/required-server-files.json +1 -1
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/131.js +24 -17
- package/.next/server/chunks/176.js +443 -288
- package/.next/server/chunks/50.js +712 -1025
- package/.next/server/chunks/664.js +27 -2414
- package/.next/server/chunks/859.js +29 -1
- package/.next/server/font-loader-manifest.js +1 -0
- package/.next/server/font-loader-manifest.json +6 -0
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +2 -2
- package/.next/server/pages/404.js.nft.json +1 -1
- package/.next/server/pages/500.html +1 -12
- package/.next/server/pages/_app.js +13 -133
- package/.next/server/pages/_app.js.nft.json +1 -1
- package/.next/server/pages/_document.js +1 -1
- package/.next/server/pages/_document.js.nft.json +1 -1
- package/.next/server/pages/_error.js +133 -17
- package/.next/server/pages/_error.js.nft.json +1 -1
- package/.next/server/pages/api/solve.js +5 -6
- package/.next/server/pages/index.html +1 -1
- package/.next/server/pages/index.js +34 -154
- package/.next/server/pages/index.js.nft.json +1 -1
- package/.next/server/pages/index.json +1 -1
- package/.next/server/pages-manifest.json +1 -1
- package/.next/static/chunks/main-74c4d6b2b5c362f3.js +1 -0
- package/.next/static/chunks/pages/{404-8cab6d62fe4ead73.js → 404-d5ff00df1c687977.js} +1 -1
- package/.next/static/chunks/pages/_app-3272e798504c40d8.js +28 -0
- package/.next/static/chunks/pages/index-5c2544930e46c5ce.js +1 -0
- package/.next/static/chunks/webpack-6ef43a8d4a395f49.js +1 -0
- package/.next/static/css/336e75db2b74b157.css +2 -0
- package/.next/static/css/{d1cc6b79b211b7b8.css → ec4e47a6b1866fe5.css} +1 -1
- package/.next/static/warzWo25tDxo_Eiv9T6f2/_buildManifest.js +1 -0
- package/.next/trace +55 -55
- package/package.json +12 -11
- package/src/components/Board/Board.module.scss +14 -0
- package/src/components/Board/Board.tsx +117 -19
- package/src/components/Board/BoardPure.tsx +7 -15
- package/src/components/Board/components/Actions/Actions.module.scss +64 -0
- package/src/components/Board/components/Actions/Actions.tsx +74 -0
- package/src/components/Board/components/Actions/index.ts +1 -0
- package/src/components/Board/components/Cell/Cell.module.scss +10 -121
- package/src/components/Board/components/Cell/Cell.tsx +0 -37
- package/src/components/Board/components/Cell/CellPure.tsx +5 -68
- package/src/components/Board/components/index.ts +1 -0
- package/src/components/Board/hooks/useGrid.ts +16 -16
- package/src/components/Modal/Modal.module.scss +3 -1
- package/src/components/Rack/Rack.module.scss +2 -1
- package/src/components/Solver/Solver.module.scss +0 -5
- package/src/components/Solver/Solver.tsx +1 -1
- package/src/components/Tile/Tile.module.scss +0 -26
- package/src/components/Tile/Tile.tsx +5 -3
- package/src/components/Tile/TilePure.tsx +16 -18
- package/src/hooks/useLocalStorage/useLocalStorageBoard.ts +6 -3
- package/src/hooks/useLocalStorage/useLocalStorageConfigId.ts +6 -3
- package/src/hooks/useLocalStorage/useLocalStorageLocale.ts +6 -3
- package/src/hooks/useLocalStorage/useLocalStorageRack.ts +6 -3
- package/src/modals/SettingsModal/components/ConfigSetting/ConfigSetting.module.scss +1 -1
- package/src/modals/SettingsModal/components/LocaleSetting/LocaleSetting.module.scss +2 -2
- package/src/parameters/index.ts +5 -3
- package/src/styles/animations.scss +10 -0
- package/src/styles/global.scss +2 -2
- package/src/styles/mixins.scss +56 -1
- package/src/styles/variables.scss +5 -2
- package/.next/server/chunks/210.js +0 -122
- package/.next/server/chunks/676.js +0 -32
- package/.next/static/Cs23uxWG6AxS72F2yrjHu/_buildManifest.js +0 -1
- package/.next/static/chunks/main-f11614d8aa7ee555.js +0 -1
- package/.next/static/chunks/pages/_app-dcbbb823dc93a031.js +0 -28
- package/.next/static/chunks/pages/index-df1ff01aa82d2d4d.js +0 -1
- package/.next/static/chunks/webpack-59c5c889f52620d6.js +0 -1
- package/.next/static/css/bf2e969b88c4e3dd.css +0 -2
- /package/.next/static/{Cs23uxWG6AxS72F2yrjHu → warzWo25tDxo_Eiv9T6f2}/_ssgManifest.js +0 -0
|
@@ -3183,9 +3183,9 @@ const { LEVEL, MESSAGE } = __webpack_require__(82068);
|
|
|
3183
3183
|
* If the `message` property of the `info` object is an instance of `Error`,
|
|
3184
3184
|
* replace the `Error` object its own `message` property.
|
|
3185
3185
|
*
|
|
3186
|
-
* Optionally, the Error's `stack`
|
|
3186
|
+
* Optionally, the Error's `stack` and/or `cause` properties can also be appended to the `info` object.
|
|
3187
3187
|
*/
|
|
3188
|
-
module.exports = format((einfo, { stack }) => {
|
|
3188
|
+
module.exports = format((einfo, { stack, cause }) => {
|
|
3189
3189
|
if (einfo instanceof Error) {
|
|
3190
3190
|
const info = Object.assign({}, einfo, {
|
|
3191
3191
|
level: einfo.level,
|
|
@@ -3195,6 +3195,7 @@ module.exports = format((einfo, { stack }) => {
|
|
|
3195
3195
|
});
|
|
3196
3196
|
|
|
3197
3197
|
if (stack) info.stack = einfo.stack;
|
|
3198
|
+
if (cause) info.cause = einfo.cause;
|
|
3198
3199
|
return info;
|
|
3199
3200
|
}
|
|
3200
3201
|
|
|
@@ -3207,8 +3208,9 @@ module.exports = format((einfo, { stack }) => {
|
|
|
3207
3208
|
einfo.message = err.message;
|
|
3208
3209
|
einfo[MESSAGE] = err.message;
|
|
3209
3210
|
|
|
3210
|
-
// Assign the stack if requested.
|
|
3211
|
+
// Assign the stack and/or cause if requested.
|
|
3211
3212
|
if (stack) einfo.stack = err.stack;
|
|
3213
|
+
if (cause) einfo.cause = err.cause;
|
|
3212
3214
|
return einfo;
|
|
3213
3215
|
});
|
|
3214
3216
|
|
|
@@ -4335,66 +4337,54 @@ module.exports.q = codes;
|
|
|
4335
4337
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
4336
4338
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
4337
4339
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
4340
|
+
|
|
4338
4341
|
// a duplex stream is just a stream that is both readable and writable.
|
|
4339
4342
|
// Since JS doesn't have multiple prototypal inheritance, this class
|
|
4340
4343
|
// prototypally inherits from Readable, and then parasitically from
|
|
4341
4344
|
// Writable.
|
|
4342
4345
|
|
|
4343
|
-
/*<replacement>*/
|
|
4344
4346
|
|
|
4347
|
+
|
|
4348
|
+
/*<replacement>*/
|
|
4345
4349
|
var objectKeys = Object.keys || function (obj) {
|
|
4346
4350
|
var keys = [];
|
|
4347
|
-
|
|
4348
|
-
for (var key in obj) {
|
|
4349
|
-
keys.push(key);
|
|
4350
|
-
}
|
|
4351
|
-
|
|
4351
|
+
for (var key in obj) keys.push(key);
|
|
4352
4352
|
return keys;
|
|
4353
4353
|
};
|
|
4354
4354
|
/*</replacement>*/
|
|
4355
4355
|
|
|
4356
|
-
|
|
4357
4356
|
module.exports = Duplex;
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
var Writable = __webpack_require__(28168);
|
|
4362
|
-
|
|
4357
|
+
const Readable = __webpack_require__(46560);
|
|
4358
|
+
const Writable = __webpack_require__(28168);
|
|
4363
4359
|
__webpack_require__(90838)(Duplex, Readable);
|
|
4364
|
-
|
|
4365
4360
|
{
|
|
4366
4361
|
// Allow the keys array to be GC'ed.
|
|
4367
|
-
|
|
4368
|
-
|
|
4362
|
+
const keys = objectKeys(Writable.prototype);
|
|
4369
4363
|
for (var v = 0; v < keys.length; v++) {
|
|
4370
|
-
|
|
4364
|
+
const method = keys[v];
|
|
4371
4365
|
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
|
|
4372
4366
|
}
|
|
4373
4367
|
}
|
|
4374
|
-
|
|
4375
4368
|
function Duplex(options) {
|
|
4376
4369
|
if (!(this instanceof Duplex)) return new Duplex(options);
|
|
4377
4370
|
Readable.call(this, options);
|
|
4378
4371
|
Writable.call(this, options);
|
|
4379
4372
|
this.allowHalfOpen = true;
|
|
4380
|
-
|
|
4381
4373
|
if (options) {
|
|
4382
4374
|
if (options.readable === false) this.readable = false;
|
|
4383
4375
|
if (options.writable === false) this.writable = false;
|
|
4384
|
-
|
|
4385
4376
|
if (options.allowHalfOpen === false) {
|
|
4386
4377
|
this.allowHalfOpen = false;
|
|
4387
4378
|
this.once('end', onend);
|
|
4388
4379
|
}
|
|
4389
4380
|
}
|
|
4390
4381
|
}
|
|
4391
|
-
|
|
4392
4382
|
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
|
|
4393
4383
|
// making it explicit this property is not enumerable
|
|
4394
4384
|
// because otherwise some prototype manipulation in
|
|
4395
4385
|
// userland will fail
|
|
4396
4386
|
enumerable: false,
|
|
4397
|
-
get
|
|
4387
|
+
get() {
|
|
4398
4388
|
return this._writableState.highWaterMark;
|
|
4399
4389
|
}
|
|
4400
4390
|
});
|
|
@@ -4412,44 +4402,43 @@ Object.defineProperty(Duplex.prototype, 'writableLength', {
|
|
|
4412
4402
|
// because otherwise some prototype manipulation in
|
|
4413
4403
|
// userland will fail
|
|
4414
4404
|
enumerable: false,
|
|
4415
|
-
get
|
|
4405
|
+
get() {
|
|
4416
4406
|
return this._writableState.length;
|
|
4417
4407
|
}
|
|
4418
|
-
});
|
|
4408
|
+
});
|
|
4419
4409
|
|
|
4410
|
+
// the no-half-open enforcer
|
|
4420
4411
|
function onend() {
|
|
4421
4412
|
// If the writable side ended, then we're ok.
|
|
4422
|
-
if (this._writableState.ended) return;
|
|
4423
|
-
// But allow more writes to happen in this tick.
|
|
4413
|
+
if (this._writableState.ended) return;
|
|
4424
4414
|
|
|
4415
|
+
// no more data can be written.
|
|
4416
|
+
// But allow more writes to happen in this tick.
|
|
4425
4417
|
process.nextTick(onEndNT, this);
|
|
4426
4418
|
}
|
|
4427
|
-
|
|
4428
4419
|
function onEndNT(self) {
|
|
4429
4420
|
self.end();
|
|
4430
4421
|
}
|
|
4431
|
-
|
|
4432
4422
|
Object.defineProperty(Duplex.prototype, 'destroyed', {
|
|
4433
4423
|
// making it explicit this property is not enumerable
|
|
4434
4424
|
// because otherwise some prototype manipulation in
|
|
4435
4425
|
// userland will fail
|
|
4436
4426
|
enumerable: false,
|
|
4437
|
-
get
|
|
4427
|
+
get() {
|
|
4438
4428
|
if (this._readableState === undefined || this._writableState === undefined) {
|
|
4439
4429
|
return false;
|
|
4440
4430
|
}
|
|
4441
|
-
|
|
4442
4431
|
return this._readableState.destroyed && this._writableState.destroyed;
|
|
4443
4432
|
},
|
|
4444
|
-
set
|
|
4433
|
+
set(value) {
|
|
4445
4434
|
// we ignore the value if the stream
|
|
4446
4435
|
// has not been initialized yet
|
|
4447
4436
|
if (this._readableState === undefined || this._writableState === undefined) {
|
|
4448
4437
|
return;
|
|
4449
|
-
}
|
|
4450
|
-
// managing destroyed
|
|
4451
|
-
|
|
4438
|
+
}
|
|
4452
4439
|
|
|
4440
|
+
// backward compatibility, the user is explicitly
|
|
4441
|
+
// managing destroyed
|
|
4453
4442
|
this._readableState.destroyed = value;
|
|
4454
4443
|
this._writableState.destroyed = value;
|
|
4455
4444
|
}
|
|
@@ -4481,22 +4470,20 @@ Object.defineProperty(Duplex.prototype, 'destroyed', {
|
|
|
4481
4470
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
4482
4471
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
4483
4472
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
4473
|
+
|
|
4484
4474
|
// a passthrough stream.
|
|
4485
4475
|
// basically just the most minimal sort of Transform stream.
|
|
4486
4476
|
// Every written chunk gets output as-is.
|
|
4487
4477
|
|
|
4488
4478
|
|
|
4489
|
-
module.exports = PassThrough;
|
|
4490
|
-
|
|
4491
|
-
var Transform = __webpack_require__(13969);
|
|
4492
4479
|
|
|
4480
|
+
module.exports = PassThrough;
|
|
4481
|
+
const Transform = __webpack_require__(13969);
|
|
4493
4482
|
__webpack_require__(90838)(PassThrough, Transform);
|
|
4494
|
-
|
|
4495
4483
|
function PassThrough(options) {
|
|
4496
4484
|
if (!(this instanceof PassThrough)) return new PassThrough(options);
|
|
4497
4485
|
Transform.call(this, options);
|
|
4498
4486
|
}
|
|
4499
|
-
|
|
4500
4487
|
PassThrough.prototype._transform = function (chunk, encoding, cb) {
|
|
4501
4488
|
cb(null, chunk);
|
|
4502
4489
|
};
|
|
@@ -4529,47 +4516,38 @@ PassThrough.prototype._transform = function (chunk, encoding, cb) {
|
|
|
4529
4516
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
4530
4517
|
|
|
4531
4518
|
|
|
4519
|
+
|
|
4532
4520
|
module.exports = Readable;
|
|
4533
|
-
/*<replacement>*/
|
|
4534
4521
|
|
|
4522
|
+
/*<replacement>*/
|
|
4535
4523
|
var Duplex;
|
|
4536
4524
|
/*</replacement>*/
|
|
4537
4525
|
|
|
4538
4526
|
Readable.ReadableState = ReadableState;
|
|
4539
|
-
/*<replacement>*/
|
|
4540
|
-
|
|
4541
|
-
var EE = (__webpack_require__(82361).EventEmitter);
|
|
4542
4527
|
|
|
4528
|
+
/*<replacement>*/
|
|
4529
|
+
const EE = (__webpack_require__(82361).EventEmitter);
|
|
4543
4530
|
var EElistenerCount = function EElistenerCount(emitter, type) {
|
|
4544
4531
|
return emitter.listeners(type).length;
|
|
4545
4532
|
};
|
|
4546
4533
|
/*</replacement>*/
|
|
4547
4534
|
|
|
4548
4535
|
/*<replacement>*/
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
4536
|
var Stream = __webpack_require__(2184);
|
|
4552
4537
|
/*</replacement>*/
|
|
4553
4538
|
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
var OurUint8Array = global.Uint8Array || function () {};
|
|
4558
|
-
|
|
4539
|
+
const Buffer = (__webpack_require__(60871).Buffer);
|
|
4540
|
+
const OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
|
|
4559
4541
|
function _uint8ArrayToBuffer(chunk) {
|
|
4560
4542
|
return Buffer.from(chunk);
|
|
4561
4543
|
}
|
|
4562
|
-
|
|
4563
4544
|
function _isUint8Array(obj) {
|
|
4564
4545
|
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
4565
4546
|
}
|
|
4566
|
-
/*<replacement>*/
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
var debugUtil = __webpack_require__(73837);
|
|
4570
|
-
|
|
4571
|
-
var debug;
|
|
4572
4547
|
|
|
4548
|
+
/*<replacement>*/
|
|
4549
|
+
const debugUtil = __webpack_require__(73837);
|
|
4550
|
+
let debug;
|
|
4573
4551
|
if (debugUtil && debugUtil.debuglog) {
|
|
4574
4552
|
debug = debugUtil.debuglog('stream');
|
|
4575
4553
|
} else {
|
|
@@ -4577,60 +4555,57 @@ if (debugUtil && debugUtil.debuglog) {
|
|
|
4577
4555
|
}
|
|
4578
4556
|
/*</replacement>*/
|
|
4579
4557
|
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
var StringDecoder;
|
|
4596
|
-
var createReadableStreamAsyncIterator;
|
|
4597
|
-
var from;
|
|
4598
|
-
|
|
4558
|
+
const BufferList = __webpack_require__(81474);
|
|
4559
|
+
const destroyImpl = __webpack_require__(52576);
|
|
4560
|
+
const _require = __webpack_require__(74479),
|
|
4561
|
+
getHighWaterMark = _require.getHighWaterMark;
|
|
4562
|
+
const _require$codes = (__webpack_require__(18128)/* .codes */ .q),
|
|
4563
|
+
ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
|
|
4564
|
+
ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF,
|
|
4565
|
+
ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
|
|
4566
|
+
ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;
|
|
4567
|
+
|
|
4568
|
+
// Lazy loaded to improve the startup performance.
|
|
4569
|
+
let StringDecoder;
|
|
4570
|
+
let createReadableStreamAsyncIterator;
|
|
4571
|
+
let from;
|
|
4599
4572
|
__webpack_require__(90838)(Readable, Stream);
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
|
|
4603
|
-
|
|
4573
|
+
const errorOrDestroy = destroyImpl.errorOrDestroy;
|
|
4574
|
+
const kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
|
|
4604
4575
|
function prependListener(emitter, event, fn) {
|
|
4605
4576
|
// Sadly this is not cacheable as some libraries bundle their own
|
|
4606
4577
|
// event emitter implementation with them.
|
|
4607
|
-
if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
|
|
4578
|
+
if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
|
|
4579
|
+
|
|
4580
|
+
// This is a hack to make sure that our error handler is attached before any
|
|
4608
4581
|
// userland ones. NEVER DO THIS. This is here only because this code needs
|
|
4609
4582
|
// to continue to work with older versions of Node.js that do not include
|
|
4610
4583
|
// the prependListener() method. The goal is to eventually remove this hack.
|
|
4611
|
-
|
|
4612
4584
|
if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
|
|
4613
4585
|
}
|
|
4614
|
-
|
|
4615
4586
|
function ReadableState(options, stream, isDuplex) {
|
|
4616
4587
|
Duplex = Duplex || __webpack_require__(57439);
|
|
4617
|
-
options = options || {};
|
|
4588
|
+
options = options || {};
|
|
4589
|
+
|
|
4590
|
+
// Duplex streams are both readable and writable, but share
|
|
4618
4591
|
// the same options object.
|
|
4619
4592
|
// However, some cases require setting options to different
|
|
4620
4593
|
// values for the readable and the writable sides of the duplex stream.
|
|
4621
4594
|
// These options can be provided separately as readableXXX and writableXXX.
|
|
4595
|
+
if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex;
|
|
4622
4596
|
|
|
4623
|
-
|
|
4597
|
+
// object stream flag. Used to make read(n) ignore n and to
|
|
4624
4598
|
// make all the buffer merging and length checks go away
|
|
4625
|
-
|
|
4626
4599
|
this.objectMode = !!options.objectMode;
|
|
4627
|
-
if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
|
|
4600
|
+
if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
|
|
4601
|
+
|
|
4602
|
+
// the point at which it stops calling _read() to fill the buffer
|
|
4628
4603
|
// Note: 0 is a valid value, means "don't call _read preemptively ever"
|
|
4604
|
+
this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex);
|
|
4629
4605
|
|
|
4630
|
-
|
|
4606
|
+
// A linked list is used to store data chunks instead of an array because the
|
|
4631
4607
|
// linked list can remove elements from the beginning faster than
|
|
4632
4608
|
// array.shift()
|
|
4633
|
-
|
|
4634
4609
|
this.buffer = new BufferList();
|
|
4635
4610
|
this.length = 0;
|
|
4636
4611
|
this.pipes = null;
|
|
@@ -4638,141 +4613,136 @@ function ReadableState(options, stream, isDuplex) {
|
|
|
4638
4613
|
this.flowing = null;
|
|
4639
4614
|
this.ended = false;
|
|
4640
4615
|
this.endEmitted = false;
|
|
4641
|
-
this.reading = false;
|
|
4616
|
+
this.reading = false;
|
|
4617
|
+
|
|
4618
|
+
// a flag to be able to tell if the event 'readable'/'data' is emitted
|
|
4642
4619
|
// immediately, or on a later tick. We set this to true at first, because
|
|
4643
4620
|
// any actions that shouldn't happen until "later" should generally also
|
|
4644
4621
|
// not happen before the first read call.
|
|
4622
|
+
this.sync = true;
|
|
4645
4623
|
|
|
4646
|
-
|
|
4624
|
+
// whenever we return null, then we set a flag to say
|
|
4647
4625
|
// that we're awaiting a 'readable' event emission.
|
|
4648
|
-
|
|
4649
4626
|
this.needReadable = false;
|
|
4650
4627
|
this.emittedReadable = false;
|
|
4651
4628
|
this.readableListening = false;
|
|
4652
4629
|
this.resumeScheduled = false;
|
|
4653
|
-
this.paused = true;
|
|
4630
|
+
this.paused = true;
|
|
4631
|
+
|
|
4632
|
+
// Should close be emitted on destroy. Defaults to true.
|
|
4633
|
+
this.emitClose = options.emitClose !== false;
|
|
4654
4634
|
|
|
4655
|
-
|
|
4635
|
+
// Should .destroy() be called after 'end' (and potentially 'finish')
|
|
4636
|
+
this.autoDestroy = !!options.autoDestroy;
|
|
4656
4637
|
|
|
4657
|
-
|
|
4638
|
+
// has it been destroyed
|
|
4639
|
+
this.destroyed = false;
|
|
4658
4640
|
|
|
4659
|
-
|
|
4641
|
+
// Crypto is kind of old and crusty. Historically, its default string
|
|
4660
4642
|
// encoding is 'binary' so we have to make this configurable.
|
|
4661
4643
|
// Everything else in the universe uses 'utf8', though.
|
|
4644
|
+
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
|
4662
4645
|
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled
|
|
4646
|
+
// the number of writers that are awaiting a drain event in .pipe()s
|
|
4647
|
+
this.awaitDrain = 0;
|
|
4666
4648
|
|
|
4649
|
+
// if true, a maybeReadMore has been scheduled
|
|
4667
4650
|
this.readingMore = false;
|
|
4668
4651
|
this.decoder = null;
|
|
4669
4652
|
this.encoding = null;
|
|
4670
|
-
|
|
4671
4653
|
if (options.encoding) {
|
|
4672
4654
|
if (!StringDecoder) StringDecoder = (__webpack_require__(60181)/* .StringDecoder */ .s);
|
|
4673
4655
|
this.decoder = new StringDecoder(options.encoding);
|
|
4674
4656
|
this.encoding = options.encoding;
|
|
4675
4657
|
}
|
|
4676
4658
|
}
|
|
4677
|
-
|
|
4678
4659
|
function Readable(options) {
|
|
4679
4660
|
Duplex = Duplex || __webpack_require__(57439);
|
|
4680
|
-
if (!(this instanceof Readable)) return new Readable(options);
|
|
4681
|
-
// the ReadableState constructor, at least with V8 6.5
|
|
4661
|
+
if (!(this instanceof Readable)) return new Readable(options);
|
|
4682
4662
|
|
|
4683
|
-
|
|
4684
|
-
|
|
4663
|
+
// Checking for a Stream.Duplex instance is faster here instead of inside
|
|
4664
|
+
// the ReadableState constructor, at least with V8 6.5
|
|
4665
|
+
const isDuplex = this instanceof Duplex;
|
|
4666
|
+
this._readableState = new ReadableState(options, this, isDuplex);
|
|
4685
4667
|
|
|
4668
|
+
// legacy
|
|
4686
4669
|
this.readable = true;
|
|
4687
|
-
|
|
4688
4670
|
if (options) {
|
|
4689
4671
|
if (typeof options.read === 'function') this._read = options.read;
|
|
4690
4672
|
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
|
4691
4673
|
}
|
|
4692
|
-
|
|
4693
4674
|
Stream.call(this);
|
|
4694
4675
|
}
|
|
4695
|
-
|
|
4696
4676
|
Object.defineProperty(Readable.prototype, 'destroyed', {
|
|
4697
4677
|
// making it explicit this property is not enumerable
|
|
4698
4678
|
// because otherwise some prototype manipulation in
|
|
4699
4679
|
// userland will fail
|
|
4700
4680
|
enumerable: false,
|
|
4701
|
-
get
|
|
4681
|
+
get() {
|
|
4702
4682
|
if (this._readableState === undefined) {
|
|
4703
4683
|
return false;
|
|
4704
4684
|
}
|
|
4705
|
-
|
|
4706
4685
|
return this._readableState.destroyed;
|
|
4707
4686
|
},
|
|
4708
|
-
set
|
|
4687
|
+
set(value) {
|
|
4709
4688
|
// we ignore the value if the stream
|
|
4710
4689
|
// has not been initialized yet
|
|
4711
4690
|
if (!this._readableState) {
|
|
4712
4691
|
return;
|
|
4713
|
-
}
|
|
4714
|
-
// managing destroyed
|
|
4715
|
-
|
|
4692
|
+
}
|
|
4716
4693
|
|
|
4694
|
+
// backward compatibility, the user is explicitly
|
|
4695
|
+
// managing destroyed
|
|
4717
4696
|
this._readableState.destroyed = value;
|
|
4718
4697
|
}
|
|
4719
4698
|
});
|
|
4720
4699
|
Readable.prototype.destroy = destroyImpl.destroy;
|
|
4721
4700
|
Readable.prototype._undestroy = destroyImpl.undestroy;
|
|
4722
|
-
|
|
4723
4701
|
Readable.prototype._destroy = function (err, cb) {
|
|
4724
4702
|
cb(err);
|
|
4725
|
-
};
|
|
4703
|
+
};
|
|
4704
|
+
|
|
4705
|
+
// Manually shove something into the read() buffer.
|
|
4726
4706
|
// This returns true if the highWaterMark has not been hit yet,
|
|
4727
4707
|
// similar to how Writable.write() returns true if you should
|
|
4728
4708
|
// write() some more.
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
4709
|
Readable.prototype.push = function (chunk, encoding) {
|
|
4732
4710
|
var state = this._readableState;
|
|
4733
4711
|
var skipChunkCheck;
|
|
4734
|
-
|
|
4735
4712
|
if (!state.objectMode) {
|
|
4736
4713
|
if (typeof chunk === 'string') {
|
|
4737
4714
|
encoding = encoding || state.defaultEncoding;
|
|
4738
|
-
|
|
4739
4715
|
if (encoding !== state.encoding) {
|
|
4740
4716
|
chunk = Buffer.from(chunk, encoding);
|
|
4741
4717
|
encoding = '';
|
|
4742
4718
|
}
|
|
4743
|
-
|
|
4744
4719
|
skipChunkCheck = true;
|
|
4745
4720
|
}
|
|
4746
4721
|
} else {
|
|
4747
4722
|
skipChunkCheck = true;
|
|
4748
4723
|
}
|
|
4749
|
-
|
|
4750
4724
|
return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
|
|
4751
|
-
};
|
|
4752
|
-
|
|
4725
|
+
};
|
|
4753
4726
|
|
|
4727
|
+
// Unshift should *always* be something directly out of read()
|
|
4754
4728
|
Readable.prototype.unshift = function (chunk) {
|
|
4755
4729
|
return readableAddChunk(this, chunk, null, true, false);
|
|
4756
4730
|
};
|
|
4757
|
-
|
|
4758
4731
|
function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
|
|
4759
4732
|
debug('readableAddChunk', chunk);
|
|
4760
4733
|
var state = stream._readableState;
|
|
4761
|
-
|
|
4762
4734
|
if (chunk === null) {
|
|
4763
4735
|
state.reading = false;
|
|
4764
4736
|
onEofChunk(stream, state);
|
|
4765
4737
|
} else {
|
|
4766
4738
|
var er;
|
|
4767
4739
|
if (!skipChunkCheck) er = chunkInvalid(state, chunk);
|
|
4768
|
-
|
|
4769
4740
|
if (er) {
|
|
4770
4741
|
errorOrDestroy(stream, er);
|
|
4771
4742
|
} else if (state.objectMode || chunk && chunk.length > 0) {
|
|
4772
4743
|
if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
|
|
4773
4744
|
chunk = _uint8ArrayToBuffer(chunk);
|
|
4774
4745
|
}
|
|
4775
|
-
|
|
4776
4746
|
if (addToFront) {
|
|
4777
4747
|
if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true);
|
|
4778
4748
|
} else if (state.ended) {
|
|
@@ -4781,7 +4751,6 @@ function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
|
|
|
4781
4751
|
return false;
|
|
4782
4752
|
} else {
|
|
4783
4753
|
state.reading = false;
|
|
4784
|
-
|
|
4785
4754
|
if (state.decoder && !encoding) {
|
|
4786
4755
|
chunk = state.decoder.write(chunk);
|
|
4787
4756
|
if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
|
|
@@ -4793,14 +4762,13 @@ function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
|
|
|
4793
4762
|
state.reading = false;
|
|
4794
4763
|
maybeReadMore(stream, state);
|
|
4795
4764
|
}
|
|
4796
|
-
}
|
|
4765
|
+
}
|
|
4766
|
+
|
|
4767
|
+
// We can push more data if we are below the highWaterMark.
|
|
4797
4768
|
// Also, if we have no data yet, we can stand some more bytes.
|
|
4798
4769
|
// This is to work around cases where hwm=0, such as the repl.
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
4770
|
return !state.ended && (state.length < state.highWaterMark || state.length === 0);
|
|
4802
4771
|
}
|
|
4803
|
-
|
|
4804
4772
|
function addChunk(stream, state, chunk, addToFront) {
|
|
4805
4773
|
if (state.flowing && state.length === 0 && !state.sync) {
|
|
4806
4774
|
state.awaitDrain = 0;
|
|
@@ -4811,50 +4779,42 @@ function addChunk(stream, state, chunk, addToFront) {
|
|
|
4811
4779
|
if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
|
|
4812
4780
|
if (state.needReadable) emitReadable(stream);
|
|
4813
4781
|
}
|
|
4814
|
-
|
|
4815
4782
|
maybeReadMore(stream, state);
|
|
4816
4783
|
}
|
|
4817
|
-
|
|
4818
4784
|
function chunkInvalid(state, chunk) {
|
|
4819
4785
|
var er;
|
|
4820
|
-
|
|
4821
4786
|
if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
|
|
4822
4787
|
er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk);
|
|
4823
4788
|
}
|
|
4824
|
-
|
|
4825
4789
|
return er;
|
|
4826
4790
|
}
|
|
4827
|
-
|
|
4828
4791
|
Readable.prototype.isPaused = function () {
|
|
4829
4792
|
return this._readableState.flowing === false;
|
|
4830
|
-
};
|
|
4831
|
-
|
|
4793
|
+
};
|
|
4832
4794
|
|
|
4795
|
+
// backwards compatibility.
|
|
4833
4796
|
Readable.prototype.setEncoding = function (enc) {
|
|
4834
4797
|
if (!StringDecoder) StringDecoder = (__webpack_require__(60181)/* .StringDecoder */ .s);
|
|
4835
|
-
|
|
4836
|
-
this._readableState.decoder = decoder;
|
|
4837
|
-
|
|
4838
|
-
this._readableState.encoding = this._readableState.decoder.encoding;
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4798
|
+
const decoder = new StringDecoder(enc);
|
|
4799
|
+
this._readableState.decoder = decoder;
|
|
4800
|
+
// If setEncoding(null), decoder.encoding equals utf8
|
|
4801
|
+
this._readableState.encoding = this._readableState.decoder.encoding;
|
|
4802
|
+
|
|
4803
|
+
// Iterate over current buffer to convert already stored Buffers:
|
|
4804
|
+
let p = this._readableState.buffer.head;
|
|
4805
|
+
let content = '';
|
|
4843
4806
|
while (p !== null) {
|
|
4844
4807
|
content += decoder.write(p.data);
|
|
4845
4808
|
p = p.next;
|
|
4846
4809
|
}
|
|
4847
|
-
|
|
4848
4810
|
this._readableState.buffer.clear();
|
|
4849
|
-
|
|
4850
4811
|
if (content !== '') this._readableState.buffer.push(content);
|
|
4851
4812
|
this._readableState.length = content.length;
|
|
4852
4813
|
return this;
|
|
4853
|
-
};
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
var MAX_HWM = 0x40000000;
|
|
4814
|
+
};
|
|
4857
4815
|
|
|
4816
|
+
// Don't raise the hwm > 1GB
|
|
4817
|
+
const MAX_HWM = 0x40000000;
|
|
4858
4818
|
function computeNewHighWaterMark(n) {
|
|
4859
4819
|
if (n >= MAX_HWM) {
|
|
4860
4820
|
// TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
|
|
@@ -4870,55 +4830,54 @@ function computeNewHighWaterMark(n) {
|
|
|
4870
4830
|
n |= n >>> 16;
|
|
4871
4831
|
n++;
|
|
4872
4832
|
}
|
|
4873
|
-
|
|
4874
4833
|
return n;
|
|
4875
|
-
}
|
|
4876
|
-
// changes to the function body.
|
|
4877
|
-
|
|
4834
|
+
}
|
|
4878
4835
|
|
|
4836
|
+
// This function is designed to be inlinable, so please take care when making
|
|
4837
|
+
// changes to the function body.
|
|
4879
4838
|
function howMuchToRead(n, state) {
|
|
4880
4839
|
if (n <= 0 || state.length === 0 && state.ended) return 0;
|
|
4881
4840
|
if (state.objectMode) return 1;
|
|
4882
|
-
|
|
4883
4841
|
if (n !== n) {
|
|
4884
4842
|
// Only flow one buffer at a time
|
|
4885
4843
|
if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
|
|
4886
|
-
}
|
|
4887
|
-
|
|
4888
|
-
|
|
4844
|
+
}
|
|
4845
|
+
// If we're asking for more than the current hwm, then raise the hwm.
|
|
4889
4846
|
if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
|
|
4890
|
-
if (n <= state.length) return n;
|
|
4891
|
-
|
|
4847
|
+
if (n <= state.length) return n;
|
|
4848
|
+
// Don't have enough
|
|
4892
4849
|
if (!state.ended) {
|
|
4893
4850
|
state.needReadable = true;
|
|
4894
4851
|
return 0;
|
|
4895
4852
|
}
|
|
4896
|
-
|
|
4897
4853
|
return state.length;
|
|
4898
|
-
}
|
|
4899
|
-
|
|
4854
|
+
}
|
|
4900
4855
|
|
|
4856
|
+
// you can override either this method, or the async _read(n) below.
|
|
4901
4857
|
Readable.prototype.read = function (n) {
|
|
4902
4858
|
debug('read', n);
|
|
4903
4859
|
n = parseInt(n, 10);
|
|
4904
4860
|
var state = this._readableState;
|
|
4905
4861
|
var nOrig = n;
|
|
4906
|
-
if (n !== 0) state.emittedReadable = false;
|
|
4862
|
+
if (n !== 0) state.emittedReadable = false;
|
|
4863
|
+
|
|
4864
|
+
// if we're doing read(0) to trigger a readable event, but we
|
|
4907
4865
|
// already have a bunch of data in the buffer, then just trigger
|
|
4908
4866
|
// the 'readable' event and move on.
|
|
4909
|
-
|
|
4910
4867
|
if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
|
|
4911
4868
|
debug('read: emitReadable', state.length, state.ended);
|
|
4912
4869
|
if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
|
|
4913
4870
|
return null;
|
|
4914
4871
|
}
|
|
4872
|
+
n = howMuchToRead(n, state);
|
|
4915
4873
|
|
|
4916
|
-
|
|
4917
|
-
|
|
4874
|
+
// if we've ended, and we're now clear, then finish it up.
|
|
4918
4875
|
if (n === 0 && state.ended) {
|
|
4919
4876
|
if (state.length === 0) endReadable(this);
|
|
4920
4877
|
return null;
|
|
4921
|
-
}
|
|
4878
|
+
}
|
|
4879
|
+
|
|
4880
|
+
// All the actual chunk generation logic needs to be
|
|
4922
4881
|
// *below* the call to _read. The reason is that in certain
|
|
4923
4882
|
// synthetic stream cases, such as passthrough streams, _read
|
|
4924
4883
|
// may be a completely synchronous operation which may change
|
|
@@ -4939,40 +4898,37 @@ Readable.prototype.read = function (n) {
|
|
|
4939
4898
|
// 'readable' etc.
|
|
4940
4899
|
//
|
|
4941
4900
|
// 3. Actually pull the requested chunks out of the buffer and return.
|
|
4942
|
-
// if we need a readable event, then we need to do some reading.
|
|
4943
|
-
|
|
4944
4901
|
|
|
4902
|
+
// if we need a readable event, then we need to do some reading.
|
|
4945
4903
|
var doRead = state.needReadable;
|
|
4946
|
-
debug('need readable', doRead);
|
|
4904
|
+
debug('need readable', doRead);
|
|
4947
4905
|
|
|
4906
|
+
// if we currently have less than the highWaterMark, then also read some
|
|
4948
4907
|
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
|
4949
4908
|
doRead = true;
|
|
4950
4909
|
debug('length less than watermark', doRead);
|
|
4951
|
-
}
|
|
4952
|
-
// reading, then it's unnecessary.
|
|
4953
|
-
|
|
4910
|
+
}
|
|
4954
4911
|
|
|
4912
|
+
// however, if we've ended, then there's no point, and if we're already
|
|
4913
|
+
// reading, then it's unnecessary.
|
|
4955
4914
|
if (state.ended || state.reading) {
|
|
4956
4915
|
doRead = false;
|
|
4957
4916
|
debug('reading or ended', doRead);
|
|
4958
4917
|
} else if (doRead) {
|
|
4959
4918
|
debug('do read');
|
|
4960
4919
|
state.reading = true;
|
|
4961
|
-
state.sync = true;
|
|
4962
|
-
|
|
4963
|
-
if (state.length === 0) state.needReadable = true;
|
|
4964
|
-
|
|
4920
|
+
state.sync = true;
|
|
4921
|
+
// if the length is currently zero, then we *need* a readable event.
|
|
4922
|
+
if (state.length === 0) state.needReadable = true;
|
|
4923
|
+
// call internal read method
|
|
4965
4924
|
this._read(state.highWaterMark);
|
|
4966
|
-
|
|
4967
|
-
|
|
4925
|
+
state.sync = false;
|
|
4926
|
+
// If _read pushed data synchronously, then `reading` will be false,
|
|
4968
4927
|
// and we need to re-evaluate how much data we can return to the user.
|
|
4969
|
-
|
|
4970
4928
|
if (!state.reading) n = howMuchToRead(nOrig, state);
|
|
4971
4929
|
}
|
|
4972
|
-
|
|
4973
4930
|
var ret;
|
|
4974
4931
|
if (n > 0) ret = fromList(n, state);else ret = null;
|
|
4975
|
-
|
|
4976
4932
|
if (ret === null) {
|
|
4977
4933
|
state.needReadable = state.length <= state.highWaterMark;
|
|
4978
4934
|
n = 0;
|
|
@@ -4980,34 +4936,28 @@ Readable.prototype.read = function (n) {
|
|
|
4980
4936
|
state.length -= n;
|
|
4981
4937
|
state.awaitDrain = 0;
|
|
4982
4938
|
}
|
|
4983
|
-
|
|
4984
4939
|
if (state.length === 0) {
|
|
4985
4940
|
// If we have nothing in the buffer, then we want to know
|
|
4986
4941
|
// as soon as we *do* get something into the buffer.
|
|
4987
|
-
if (!state.ended) state.needReadable = true;
|
|
4942
|
+
if (!state.ended) state.needReadable = true;
|
|
4988
4943
|
|
|
4944
|
+
// If we tried to read() past the EOF, then emit end on the next tick.
|
|
4989
4945
|
if (nOrig !== n && state.ended) endReadable(this);
|
|
4990
4946
|
}
|
|
4991
|
-
|
|
4992
4947
|
if (ret !== null) this.emit('data', ret);
|
|
4993
4948
|
return ret;
|
|
4994
4949
|
};
|
|
4995
|
-
|
|
4996
4950
|
function onEofChunk(stream, state) {
|
|
4997
4951
|
debug('onEofChunk');
|
|
4998
4952
|
if (state.ended) return;
|
|
4999
|
-
|
|
5000
4953
|
if (state.decoder) {
|
|
5001
4954
|
var chunk = state.decoder.end();
|
|
5002
|
-
|
|
5003
4955
|
if (chunk && chunk.length) {
|
|
5004
4956
|
state.buffer.push(chunk);
|
|
5005
4957
|
state.length += state.objectMode ? 1 : chunk.length;
|
|
5006
4958
|
}
|
|
5007
4959
|
}
|
|
5008
|
-
|
|
5009
4960
|
state.ended = true;
|
|
5010
|
-
|
|
5011
4961
|
if (state.sync) {
|
|
5012
4962
|
// if we are sync, wait until next tick to emit the data.
|
|
5013
4963
|
// Otherwise we risk emitting data in the flow()
|
|
@@ -5016,61 +4966,56 @@ function onEofChunk(stream, state) {
|
|
|
5016
4966
|
} else {
|
|
5017
4967
|
// emit 'readable' now to make sure it gets picked up.
|
|
5018
4968
|
state.needReadable = false;
|
|
5019
|
-
|
|
5020
4969
|
if (!state.emittedReadable) {
|
|
5021
4970
|
state.emittedReadable = true;
|
|
5022
4971
|
emitReadable_(stream);
|
|
5023
4972
|
}
|
|
5024
4973
|
}
|
|
5025
|
-
}
|
|
4974
|
+
}
|
|
4975
|
+
|
|
4976
|
+
// Don't emit readable right away in sync mode, because this can trigger
|
|
5026
4977
|
// another read() call => stack overflow. This way, it might trigger
|
|
5027
4978
|
// a nextTick recursion warning, but that's not so bad.
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
4979
|
function emitReadable(stream) {
|
|
5031
4980
|
var state = stream._readableState;
|
|
5032
4981
|
debug('emitReadable', state.needReadable, state.emittedReadable);
|
|
5033
4982
|
state.needReadable = false;
|
|
5034
|
-
|
|
5035
4983
|
if (!state.emittedReadable) {
|
|
5036
4984
|
debug('emitReadable', state.flowing);
|
|
5037
4985
|
state.emittedReadable = true;
|
|
5038
4986
|
process.nextTick(emitReadable_, stream);
|
|
5039
4987
|
}
|
|
5040
4988
|
}
|
|
5041
|
-
|
|
5042
4989
|
function emitReadable_(stream) {
|
|
5043
4990
|
var state = stream._readableState;
|
|
5044
4991
|
debug('emitReadable_', state.destroyed, state.length, state.ended);
|
|
5045
|
-
|
|
5046
4992
|
if (!state.destroyed && (state.length || state.ended)) {
|
|
5047
4993
|
stream.emit('readable');
|
|
5048
4994
|
state.emittedReadable = false;
|
|
5049
|
-
}
|
|
4995
|
+
}
|
|
4996
|
+
|
|
4997
|
+
// The stream needs another readable event if
|
|
5050
4998
|
// 1. It is not flowing, as the flow mechanism will take
|
|
5051
4999
|
// care of it.
|
|
5052
5000
|
// 2. It is not ended.
|
|
5053
5001
|
// 3. It is below the highWaterMark, so we can schedule
|
|
5054
5002
|
// another readable later.
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
5003
|
state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;
|
|
5058
5004
|
flow(stream);
|
|
5059
|
-
}
|
|
5005
|
+
}
|
|
5006
|
+
|
|
5007
|
+
// at this point, the user has presumably seen the 'readable' event,
|
|
5060
5008
|
// and called read() to consume some data. that may have triggered
|
|
5061
5009
|
// in turn another _read(n) call, in which case reading = true if
|
|
5062
5010
|
// it's in progress.
|
|
5063
5011
|
// However, if we're not ended, or reading, and the length < hwm,
|
|
5064
5012
|
// then go ahead and try to read some more preemptively.
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
5013
|
function maybeReadMore(stream, state) {
|
|
5068
5014
|
if (!state.readingMore) {
|
|
5069
5015
|
state.readingMore = true;
|
|
5070
5016
|
process.nextTick(maybeReadMore_, stream, state);
|
|
5071
5017
|
}
|
|
5072
5018
|
}
|
|
5073
|
-
|
|
5074
5019
|
function maybeReadMore_(stream, state) {
|
|
5075
5020
|
// Attempt to read more data if we should.
|
|
5076
5021
|
//
|
|
@@ -5096,52 +5041,45 @@ function maybeReadMore_(stream, state) {
|
|
|
5096
5041
|
// read()s. The execution ends in this method again after the _read() ends
|
|
5097
5042
|
// up calling push() with more data.
|
|
5098
5043
|
while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
|
|
5099
|
-
|
|
5044
|
+
const len = state.length;
|
|
5100
5045
|
debug('maybeReadMore read 0');
|
|
5101
5046
|
stream.read(0);
|
|
5102
|
-
if (len === state.length)
|
|
5047
|
+
if (len === state.length)
|
|
5048
|
+
// didn't get any data, stop spinning.
|
|
5103
5049
|
break;
|
|
5104
5050
|
}
|
|
5105
|
-
|
|
5106
5051
|
state.readingMore = false;
|
|
5107
|
-
}
|
|
5052
|
+
}
|
|
5053
|
+
|
|
5054
|
+
// abstract method. to be overridden in specific implementation classes.
|
|
5108
5055
|
// call cb(er, data) where data is <= n in length.
|
|
5109
5056
|
// for virtual (non-string, non-buffer) streams, "length" is somewhat
|
|
5110
5057
|
// arbitrary, and perhaps not very meaningful.
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
5058
|
Readable.prototype._read = function (n) {
|
|
5114
5059
|
errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()'));
|
|
5115
5060
|
};
|
|
5116
|
-
|
|
5117
5061
|
Readable.prototype.pipe = function (dest, pipeOpts) {
|
|
5118
5062
|
var src = this;
|
|
5119
5063
|
var state = this._readableState;
|
|
5120
|
-
|
|
5121
5064
|
switch (state.pipesCount) {
|
|
5122
5065
|
case 0:
|
|
5123
5066
|
state.pipes = dest;
|
|
5124
5067
|
break;
|
|
5125
|
-
|
|
5126
5068
|
case 1:
|
|
5127
5069
|
state.pipes = [state.pipes, dest];
|
|
5128
5070
|
break;
|
|
5129
|
-
|
|
5130
5071
|
default:
|
|
5131
5072
|
state.pipes.push(dest);
|
|
5132
5073
|
break;
|
|
5133
5074
|
}
|
|
5134
|
-
|
|
5135
5075
|
state.pipesCount += 1;
|
|
5136
5076
|
debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
|
|
5137
5077
|
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
|
|
5138
5078
|
var endFn = doEnd ? onend : unpipe;
|
|
5139
5079
|
if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn);
|
|
5140
5080
|
dest.on('unpipe', onunpipe);
|
|
5141
|
-
|
|
5142
5081
|
function onunpipe(readable, unpipeInfo) {
|
|
5143
5082
|
debug('onunpipe');
|
|
5144
|
-
|
|
5145
5083
|
if (readable === src) {
|
|
5146
5084
|
if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
|
|
5147
5085
|
unpipeInfo.hasUnpiped = true;
|
|
@@ -5149,23 +5087,21 @@ Readable.prototype.pipe = function (dest, pipeOpts) {
|
|
|
5149
5087
|
}
|
|
5150
5088
|
}
|
|
5151
5089
|
}
|
|
5152
|
-
|
|
5153
5090
|
function onend() {
|
|
5154
5091
|
debug('onend');
|
|
5155
5092
|
dest.end();
|
|
5156
|
-
}
|
|
5093
|
+
}
|
|
5094
|
+
|
|
5095
|
+
// when the dest drains, it reduces the awaitDrain counter
|
|
5157
5096
|
// on the source. This would be more elegant with a .once()
|
|
5158
5097
|
// handler in flow(), but adding and removing repeatedly is
|
|
5159
5098
|
// too slow.
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
5099
|
var ondrain = pipeOnDrain(src);
|
|
5163
5100
|
dest.on('drain', ondrain);
|
|
5164
5101
|
var cleanedUp = false;
|
|
5165
|
-
|
|
5166
5102
|
function cleanup() {
|
|
5167
|
-
debug('cleanup');
|
|
5168
|
-
|
|
5103
|
+
debug('cleanup');
|
|
5104
|
+
// cleanup event handlers once the pipe is broken
|
|
5169
5105
|
dest.removeListener('close', onclose);
|
|
5170
5106
|
dest.removeListener('finish', onfinish);
|
|
5171
5107
|
dest.removeListener('drain', ondrain);
|
|
@@ -5174,22 +5110,20 @@ Readable.prototype.pipe = function (dest, pipeOpts) {
|
|
|
5174
5110
|
src.removeListener('end', onend);
|
|
5175
5111
|
src.removeListener('end', unpipe);
|
|
5176
5112
|
src.removeListener('data', ondata);
|
|
5177
|
-
cleanedUp = true;
|
|
5113
|
+
cleanedUp = true;
|
|
5114
|
+
|
|
5115
|
+
// if the reader is waiting for a drain event from this
|
|
5178
5116
|
// specific writer, then it would cause it to never start
|
|
5179
5117
|
// flowing again.
|
|
5180
5118
|
// So, if this is awaiting a drain, then we just call it now.
|
|
5181
5119
|
// If we don't know, then assume that we are waiting for one.
|
|
5182
|
-
|
|
5183
5120
|
if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
|
|
5184
5121
|
}
|
|
5185
|
-
|
|
5186
5122
|
src.on('data', ondata);
|
|
5187
|
-
|
|
5188
5123
|
function ondata(chunk) {
|
|
5189
5124
|
debug('ondata');
|
|
5190
5125
|
var ret = dest.write(chunk);
|
|
5191
5126
|
debug('dest.write', ret);
|
|
5192
|
-
|
|
5193
5127
|
if (ret === false) {
|
|
5194
5128
|
// If the user unpiped during `dest.write()`, it is possible
|
|
5195
5129
|
// to get stuck in a permanently paused state if that write
|
|
@@ -5199,87 +5133,84 @@ Readable.prototype.pipe = function (dest, pipeOpts) {
|
|
|
5199
5133
|
debug('false write response, pause', state.awaitDrain);
|
|
5200
5134
|
state.awaitDrain++;
|
|
5201
5135
|
}
|
|
5202
|
-
|
|
5203
5136
|
src.pause();
|
|
5204
5137
|
}
|
|
5205
|
-
}
|
|
5206
|
-
// however, don't suppress the throwing behavior for this.
|
|
5207
|
-
|
|
5138
|
+
}
|
|
5208
5139
|
|
|
5140
|
+
// if the dest has an error, then stop piping into it.
|
|
5141
|
+
// however, don't suppress the throwing behavior for this.
|
|
5209
5142
|
function onerror(er) {
|
|
5210
5143
|
debug('onerror', er);
|
|
5211
5144
|
unpipe();
|
|
5212
5145
|
dest.removeListener('error', onerror);
|
|
5213
5146
|
if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er);
|
|
5214
|
-
}
|
|
5215
|
-
|
|
5147
|
+
}
|
|
5216
5148
|
|
|
5217
|
-
|
|
5149
|
+
// Make sure our error handler is attached before userland ones.
|
|
5150
|
+
prependListener(dest, 'error', onerror);
|
|
5218
5151
|
|
|
5152
|
+
// Both close and finish should trigger unpipe, but only once.
|
|
5219
5153
|
function onclose() {
|
|
5220
5154
|
dest.removeListener('finish', onfinish);
|
|
5221
5155
|
unpipe();
|
|
5222
5156
|
}
|
|
5223
|
-
|
|
5224
5157
|
dest.once('close', onclose);
|
|
5225
|
-
|
|
5226
5158
|
function onfinish() {
|
|
5227
5159
|
debug('onfinish');
|
|
5228
5160
|
dest.removeListener('close', onclose);
|
|
5229
5161
|
unpipe();
|
|
5230
5162
|
}
|
|
5231
|
-
|
|
5232
5163
|
dest.once('finish', onfinish);
|
|
5233
|
-
|
|
5234
5164
|
function unpipe() {
|
|
5235
5165
|
debug('unpipe');
|
|
5236
5166
|
src.unpipe(dest);
|
|
5237
|
-
}
|
|
5238
|
-
|
|
5167
|
+
}
|
|
5239
5168
|
|
|
5240
|
-
|
|
5169
|
+
// tell the dest that it's being piped to
|
|
5170
|
+
dest.emit('pipe', src);
|
|
5241
5171
|
|
|
5172
|
+
// start the flow if it hasn't been started already.
|
|
5242
5173
|
if (!state.flowing) {
|
|
5243
5174
|
debug('pipe resume');
|
|
5244
5175
|
src.resume();
|
|
5245
5176
|
}
|
|
5246
|
-
|
|
5247
5177
|
return dest;
|
|
5248
5178
|
};
|
|
5249
|
-
|
|
5250
5179
|
function pipeOnDrain(src) {
|
|
5251
5180
|
return function pipeOnDrainFunctionResult() {
|
|
5252
5181
|
var state = src._readableState;
|
|
5253
5182
|
debug('pipeOnDrain', state.awaitDrain);
|
|
5254
5183
|
if (state.awaitDrain) state.awaitDrain--;
|
|
5255
|
-
|
|
5256
5184
|
if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
|
|
5257
5185
|
state.flowing = true;
|
|
5258
5186
|
flow(src);
|
|
5259
5187
|
}
|
|
5260
5188
|
};
|
|
5261
5189
|
}
|
|
5262
|
-
|
|
5263
5190
|
Readable.prototype.unpipe = function (dest) {
|
|
5264
5191
|
var state = this._readableState;
|
|
5265
5192
|
var unpipeInfo = {
|
|
5266
5193
|
hasUnpiped: false
|
|
5267
|
-
};
|
|
5194
|
+
};
|
|
5268
5195
|
|
|
5269
|
-
if
|
|
5196
|
+
// if we're not piping anywhere, then do nothing.
|
|
5197
|
+
if (state.pipesCount === 0) return this;
|
|
5270
5198
|
|
|
5199
|
+
// just one destination. most common case.
|
|
5271
5200
|
if (state.pipesCount === 1) {
|
|
5272
5201
|
// passed in one, but it's not the right one.
|
|
5273
5202
|
if (dest && dest !== state.pipes) return this;
|
|
5274
|
-
if (!dest) dest = state.pipes;
|
|
5203
|
+
if (!dest) dest = state.pipes;
|
|
5275
5204
|
|
|
5205
|
+
// got a match.
|
|
5276
5206
|
state.pipes = null;
|
|
5277
5207
|
state.pipesCount = 0;
|
|
5278
5208
|
state.flowing = false;
|
|
5279
5209
|
if (dest) dest.emit('unpipe', this, unpipeInfo);
|
|
5280
5210
|
return this;
|
|
5281
|
-
}
|
|
5211
|
+
}
|
|
5282
5212
|
|
|
5213
|
+
// slow case. multiple pipe destinations.
|
|
5283
5214
|
|
|
5284
5215
|
if (!dest) {
|
|
5285
5216
|
// remove all.
|
|
@@ -5288,17 +5219,13 @@ Readable.prototype.unpipe = function (dest) {
|
|
|
5288
5219
|
state.pipes = null;
|
|
5289
5220
|
state.pipesCount = 0;
|
|
5290
5221
|
state.flowing = false;
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
hasUnpiped: false
|
|
5295
|
-
});
|
|
5296
|
-
}
|
|
5297
|
-
|
|
5222
|
+
for (var i = 0; i < len; i++) dests[i].emit('unpipe', this, {
|
|
5223
|
+
hasUnpiped: false
|
|
5224
|
+
});
|
|
5298
5225
|
return this;
|
|
5299
|
-
}
|
|
5300
|
-
|
|
5226
|
+
}
|
|
5301
5227
|
|
|
5228
|
+
// try to find the right one.
|
|
5302
5229
|
var index = indexOf(state.pipes, dest);
|
|
5303
5230
|
if (index === -1) return this;
|
|
5304
5231
|
state.pipes.splice(index, 1);
|
|
@@ -5306,19 +5233,19 @@ Readable.prototype.unpipe = function (dest) {
|
|
|
5306
5233
|
if (state.pipesCount === 1) state.pipes = state.pipes[0];
|
|
5307
5234
|
dest.emit('unpipe', this, unpipeInfo);
|
|
5308
5235
|
return this;
|
|
5309
|
-
};
|
|
5310
|
-
// Ensure readable listeners eventually get something
|
|
5311
|
-
|
|
5236
|
+
};
|
|
5312
5237
|
|
|
5238
|
+
// set up data events if they are asked for
|
|
5239
|
+
// Ensure readable listeners eventually get something
|
|
5313
5240
|
Readable.prototype.on = function (ev, fn) {
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5241
|
+
const res = Stream.prototype.on.call(this, ev, fn);
|
|
5242
|
+
const state = this._readableState;
|
|
5317
5243
|
if (ev === 'data') {
|
|
5318
5244
|
// update readableListening so that resume() may be a no-op
|
|
5319
5245
|
// a few lines down. This is needed to support once('readable').
|
|
5320
|
-
state.readableListening = this.listenerCount('readable') > 0;
|
|
5246
|
+
state.readableListening = this.listenerCount('readable') > 0;
|
|
5321
5247
|
|
|
5248
|
+
// Try start flowing on next tick if stream isn't explicitly paused
|
|
5322
5249
|
if (state.flowing !== false) this.resume();
|
|
5323
5250
|
} else if (ev === 'readable') {
|
|
5324
5251
|
if (!state.endEmitted && !state.readableListening) {
|
|
@@ -5326,7 +5253,6 @@ Readable.prototype.on = function (ev, fn) {
|
|
|
5326
5253
|
state.flowing = false;
|
|
5327
5254
|
state.emittedReadable = false;
|
|
5328
5255
|
debug('on readable', state.length, state.reading);
|
|
5329
|
-
|
|
5330
5256
|
if (state.length) {
|
|
5331
5257
|
emitReadable(this);
|
|
5332
5258
|
} else if (!state.reading) {
|
|
@@ -5334,15 +5260,11 @@ Readable.prototype.on = function (ev, fn) {
|
|
|
5334
5260
|
}
|
|
5335
5261
|
}
|
|
5336
5262
|
}
|
|
5337
|
-
|
|
5338
5263
|
return res;
|
|
5339
5264
|
};
|
|
5340
|
-
|
|
5341
5265
|
Readable.prototype.addListener = Readable.prototype.on;
|
|
5342
|
-
|
|
5343
5266
|
Readable.prototype.removeListener = function (ev, fn) {
|
|
5344
|
-
|
|
5345
|
-
|
|
5267
|
+
const res = Stream.prototype.removeListener.call(this, ev, fn);
|
|
5346
5268
|
if (ev === 'readable') {
|
|
5347
5269
|
// We need to check if there is someone still listening to
|
|
5348
5270
|
// readable and reset the state. However this needs to happen
|
|
@@ -5352,13 +5274,10 @@ Readable.prototype.removeListener = function (ev, fn) {
|
|
|
5352
5274
|
// effect.
|
|
5353
5275
|
process.nextTick(updateReadableListening, this);
|
|
5354
5276
|
}
|
|
5355
|
-
|
|
5356
5277
|
return res;
|
|
5357
5278
|
};
|
|
5358
|
-
|
|
5359
5279
|
Readable.prototype.removeAllListeners = function (ev) {
|
|
5360
|
-
|
|
5361
|
-
|
|
5280
|
+
const res = Stream.prototype.removeAllListeners.apply(this, arguments);
|
|
5362
5281
|
if (ev === 'readable' || ev === undefined) {
|
|
5363
5282
|
// We need to check if there is someone still listening to
|
|
5364
5283
|
// readable and reset the state. However this needs to happen
|
|
@@ -5368,121 +5287,102 @@ Readable.prototype.removeAllListeners = function (ev) {
|
|
|
5368
5287
|
// effect.
|
|
5369
5288
|
process.nextTick(updateReadableListening, this);
|
|
5370
5289
|
}
|
|
5371
|
-
|
|
5372
5290
|
return res;
|
|
5373
5291
|
};
|
|
5374
|
-
|
|
5375
5292
|
function updateReadableListening(self) {
|
|
5376
|
-
|
|
5293
|
+
const state = self._readableState;
|
|
5377
5294
|
state.readableListening = self.listenerCount('readable') > 0;
|
|
5378
|
-
|
|
5379
5295
|
if (state.resumeScheduled && !state.paused) {
|
|
5380
5296
|
// flowing needs to be set to true now, otherwise
|
|
5381
5297
|
// the upcoming resume will not flow.
|
|
5382
|
-
state.flowing = true;
|
|
5298
|
+
state.flowing = true;
|
|
5299
|
+
|
|
5300
|
+
// crude way to check if we should resume
|
|
5383
5301
|
} else if (self.listenerCount('data') > 0) {
|
|
5384
5302
|
self.resume();
|
|
5385
5303
|
}
|
|
5386
5304
|
}
|
|
5387
|
-
|
|
5388
5305
|
function nReadingNextTick(self) {
|
|
5389
5306
|
debug('readable nexttick read 0');
|
|
5390
5307
|
self.read(0);
|
|
5391
|
-
}
|
|
5392
|
-
// If the user uses them, then switch into old mode.
|
|
5393
|
-
|
|
5308
|
+
}
|
|
5394
5309
|
|
|
5310
|
+
// pause() and resume() are remnants of the legacy readable stream API
|
|
5311
|
+
// If the user uses them, then switch into old mode.
|
|
5395
5312
|
Readable.prototype.resume = function () {
|
|
5396
5313
|
var state = this._readableState;
|
|
5397
|
-
|
|
5398
5314
|
if (!state.flowing) {
|
|
5399
|
-
debug('resume');
|
|
5315
|
+
debug('resume');
|
|
5316
|
+
// we flow only if there is no one listening
|
|
5400
5317
|
// for readable, but we still have to call
|
|
5401
5318
|
// resume()
|
|
5402
|
-
|
|
5403
5319
|
state.flowing = !state.readableListening;
|
|
5404
5320
|
resume(this, state);
|
|
5405
5321
|
}
|
|
5406
|
-
|
|
5407
5322
|
state.paused = false;
|
|
5408
5323
|
return this;
|
|
5409
5324
|
};
|
|
5410
|
-
|
|
5411
5325
|
function resume(stream, state) {
|
|
5412
5326
|
if (!state.resumeScheduled) {
|
|
5413
5327
|
state.resumeScheduled = true;
|
|
5414
5328
|
process.nextTick(resume_, stream, state);
|
|
5415
5329
|
}
|
|
5416
5330
|
}
|
|
5417
|
-
|
|
5418
5331
|
function resume_(stream, state) {
|
|
5419
5332
|
debug('resume', state.reading);
|
|
5420
|
-
|
|
5421
5333
|
if (!state.reading) {
|
|
5422
5334
|
stream.read(0);
|
|
5423
5335
|
}
|
|
5424
|
-
|
|
5425
5336
|
state.resumeScheduled = false;
|
|
5426
5337
|
stream.emit('resume');
|
|
5427
5338
|
flow(stream);
|
|
5428
5339
|
if (state.flowing && !state.reading) stream.read(0);
|
|
5429
5340
|
}
|
|
5430
|
-
|
|
5431
5341
|
Readable.prototype.pause = function () {
|
|
5432
5342
|
debug('call pause flowing=%j', this._readableState.flowing);
|
|
5433
|
-
|
|
5434
5343
|
if (this._readableState.flowing !== false) {
|
|
5435
5344
|
debug('pause');
|
|
5436
5345
|
this._readableState.flowing = false;
|
|
5437
5346
|
this.emit('pause');
|
|
5438
5347
|
}
|
|
5439
|
-
|
|
5440
5348
|
this._readableState.paused = true;
|
|
5441
5349
|
return this;
|
|
5442
5350
|
};
|
|
5443
|
-
|
|
5444
5351
|
function flow(stream) {
|
|
5445
|
-
|
|
5352
|
+
const state = stream._readableState;
|
|
5446
5353
|
debug('flow', state.flowing);
|
|
5354
|
+
while (state.flowing && stream.read() !== null);
|
|
5355
|
+
}
|
|
5447
5356
|
|
|
5448
|
-
|
|
5449
|
-
;
|
|
5450
|
-
}
|
|
5451
|
-
} // wrap an old-style stream as the async data source.
|
|
5357
|
+
// wrap an old-style stream as the async data source.
|
|
5452
5358
|
// This is *not* part of the readable stream interface.
|
|
5453
5359
|
// It is an ugly unfortunate mess of history.
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
5360
|
Readable.prototype.wrap = function (stream) {
|
|
5457
|
-
var _this = this;
|
|
5458
|
-
|
|
5459
5361
|
var state = this._readableState;
|
|
5460
5362
|
var paused = false;
|
|
5461
|
-
stream.on('end',
|
|
5363
|
+
stream.on('end', () => {
|
|
5462
5364
|
debug('wrapped end');
|
|
5463
|
-
|
|
5464
5365
|
if (state.decoder && !state.ended) {
|
|
5465
5366
|
var chunk = state.decoder.end();
|
|
5466
|
-
if (chunk && chunk.length)
|
|
5367
|
+
if (chunk && chunk.length) this.push(chunk);
|
|
5467
5368
|
}
|
|
5468
|
-
|
|
5469
|
-
_this.push(null);
|
|
5369
|
+
this.push(null);
|
|
5470
5370
|
});
|
|
5471
|
-
stream.on('data',
|
|
5371
|
+
stream.on('data', chunk => {
|
|
5472
5372
|
debug('wrapped data');
|
|
5473
|
-
if (state.decoder) chunk = state.decoder.write(chunk);
|
|
5373
|
+
if (state.decoder) chunk = state.decoder.write(chunk);
|
|
5474
5374
|
|
|
5375
|
+
// don't skip over falsy values in objectMode
|
|
5475
5376
|
if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
|
|
5476
|
-
|
|
5477
|
-
var ret = _this.push(chunk);
|
|
5478
|
-
|
|
5377
|
+
var ret = this.push(chunk);
|
|
5479
5378
|
if (!ret) {
|
|
5480
5379
|
paused = true;
|
|
5481
5380
|
stream.pause();
|
|
5482
5381
|
}
|
|
5483
|
-
});
|
|
5484
|
-
// important when wrapping filters and duplexes.
|
|
5382
|
+
});
|
|
5485
5383
|
|
|
5384
|
+
// proxy all the other methods.
|
|
5385
|
+
// important when wrapping filters and duplexes.
|
|
5486
5386
|
for (var i in stream) {
|
|
5487
5387
|
if (this[i] === undefined && typeof stream[i] === 'function') {
|
|
5488
5388
|
this[i] = function methodWrap(method) {
|
|
@@ -5491,37 +5391,32 @@ Readable.prototype.wrap = function (stream) {
|
|
|
5491
5391
|
};
|
|
5492
5392
|
}(i);
|
|
5493
5393
|
}
|
|
5494
|
-
}
|
|
5495
|
-
|
|
5394
|
+
}
|
|
5496
5395
|
|
|
5396
|
+
// proxy certain important events.
|
|
5497
5397
|
for (var n = 0; n < kProxyEvents.length; n++) {
|
|
5498
5398
|
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
|
|
5499
|
-
}
|
|
5500
|
-
// underlying stream.
|
|
5501
|
-
|
|
5399
|
+
}
|
|
5502
5400
|
|
|
5503
|
-
|
|
5401
|
+
// when we try to consume some more bytes, simply unpause the
|
|
5402
|
+
// underlying stream.
|
|
5403
|
+
this._read = n => {
|
|
5504
5404
|
debug('wrapped _read', n);
|
|
5505
|
-
|
|
5506
5405
|
if (paused) {
|
|
5507
5406
|
paused = false;
|
|
5508
5407
|
stream.resume();
|
|
5509
5408
|
}
|
|
5510
5409
|
};
|
|
5511
|
-
|
|
5512
5410
|
return this;
|
|
5513
5411
|
};
|
|
5514
|
-
|
|
5515
5412
|
if (typeof Symbol === 'function') {
|
|
5516
5413
|
Readable.prototype[Symbol.asyncIterator] = function () {
|
|
5517
5414
|
if (createReadableStreamAsyncIterator === undefined) {
|
|
5518
5415
|
createReadableStreamAsyncIterator = __webpack_require__(97103);
|
|
5519
5416
|
}
|
|
5520
|
-
|
|
5521
5417
|
return createReadableStreamAsyncIterator(this);
|
|
5522
5418
|
};
|
|
5523
5419
|
}
|
|
5524
|
-
|
|
5525
5420
|
Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
|
|
5526
5421
|
// making it explicit this property is not enumerable
|
|
5527
5422
|
// because otherwise some prototype manipulation in
|
|
@@ -5553,22 +5448,24 @@ Object.defineProperty(Readable.prototype, 'readableFlowing', {
|
|
|
5553
5448
|
this._readableState.flowing = state;
|
|
5554
5449
|
}
|
|
5555
5450
|
}
|
|
5556
|
-
});
|
|
5451
|
+
});
|
|
5557
5452
|
|
|
5453
|
+
// exposed for testing purposes only.
|
|
5558
5454
|
Readable._fromList = fromList;
|
|
5559
5455
|
Object.defineProperty(Readable.prototype, 'readableLength', {
|
|
5560
5456
|
// making it explicit this property is not enumerable
|
|
5561
5457
|
// because otherwise some prototype manipulation in
|
|
5562
5458
|
// userland will fail
|
|
5563
5459
|
enumerable: false,
|
|
5564
|
-
get
|
|
5460
|
+
get() {
|
|
5565
5461
|
return this._readableState.length;
|
|
5566
5462
|
}
|
|
5567
|
-
});
|
|
5463
|
+
});
|
|
5464
|
+
|
|
5465
|
+
// Pluck off n bytes from an array of buffers.
|
|
5568
5466
|
// Length is the combined lengths of all the buffers in the list.
|
|
5569
5467
|
// This function is designed to be inlinable, so please take care when making
|
|
5570
5468
|
// changes to the function body.
|
|
5571
|
-
|
|
5572
5469
|
function fromList(n, state) {
|
|
5573
5470
|
// nothing buffered
|
|
5574
5471
|
if (state.length === 0) return null;
|
|
@@ -5583,52 +5480,44 @@ function fromList(n, state) {
|
|
|
5583
5480
|
}
|
|
5584
5481
|
return ret;
|
|
5585
5482
|
}
|
|
5586
|
-
|
|
5587
5483
|
function endReadable(stream) {
|
|
5588
5484
|
var state = stream._readableState;
|
|
5589
5485
|
debug('endReadable', state.endEmitted);
|
|
5590
|
-
|
|
5591
5486
|
if (!state.endEmitted) {
|
|
5592
5487
|
state.ended = true;
|
|
5593
5488
|
process.nextTick(endReadableNT, state, stream);
|
|
5594
5489
|
}
|
|
5595
5490
|
}
|
|
5596
|
-
|
|
5597
5491
|
function endReadableNT(state, stream) {
|
|
5598
|
-
debug('endReadableNT', state.endEmitted, state.length);
|
|
5492
|
+
debug('endReadableNT', state.endEmitted, state.length);
|
|
5599
5493
|
|
|
5494
|
+
// Check that we didn't get one last unshift.
|
|
5600
5495
|
if (!state.endEmitted && state.length === 0) {
|
|
5601
5496
|
state.endEmitted = true;
|
|
5602
5497
|
stream.readable = false;
|
|
5603
5498
|
stream.emit('end');
|
|
5604
|
-
|
|
5605
5499
|
if (state.autoDestroy) {
|
|
5606
5500
|
// In case of duplex streams we need a way to detect
|
|
5607
5501
|
// if the writable side is ready for autoDestroy as well
|
|
5608
|
-
|
|
5609
|
-
|
|
5502
|
+
const wState = stream._writableState;
|
|
5610
5503
|
if (!wState || wState.autoDestroy && wState.finished) {
|
|
5611
5504
|
stream.destroy();
|
|
5612
5505
|
}
|
|
5613
5506
|
}
|
|
5614
5507
|
}
|
|
5615
5508
|
}
|
|
5616
|
-
|
|
5617
5509
|
if (typeof Symbol === 'function') {
|
|
5618
5510
|
Readable.from = function (iterable, opts) {
|
|
5619
5511
|
if (from === undefined) {
|
|
5620
5512
|
from = __webpack_require__(2346);
|
|
5621
5513
|
}
|
|
5622
|
-
|
|
5623
5514
|
return from(Readable, iterable, opts);
|
|
5624
5515
|
};
|
|
5625
5516
|
}
|
|
5626
|
-
|
|
5627
5517
|
function indexOf(xs, x) {
|
|
5628
5518
|
for (var i = 0, l = xs.length; i < l; i++) {
|
|
5629
5519
|
if (xs[i] === x) return i;
|
|
5630
5520
|
}
|
|
5631
|
-
|
|
5632
5521
|
return -1;
|
|
5633
5522
|
}
|
|
5634
5523
|
|
|
@@ -5658,6 +5547,7 @@ function indexOf(xs, x) {
|
|
|
5658
5547
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
5659
5548
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
5660
5549
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
5550
|
+
|
|
5661
5551
|
// a transform stream is a readable/writable stream where you do
|
|
5662
5552
|
// something with the data. Sometimes it's called a "filter",
|
|
5663
5553
|
// but that's not a great name for it, since that implies a thing where
|
|
@@ -5701,40 +5591,34 @@ function indexOf(xs, x) {
|
|
|
5701
5591
|
// the results of the previous transformed chunk were consumed.
|
|
5702
5592
|
|
|
5703
5593
|
|
|
5704
|
-
module.exports = Transform;
|
|
5705
|
-
|
|
5706
|
-
var _require$codes = (__webpack_require__(18128)/* .codes */ .q),
|
|
5707
|
-
ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
|
|
5708
|
-
ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
|
|
5709
|
-
ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
|
|
5710
|
-
ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
|
|
5711
|
-
|
|
5712
|
-
var Duplex = __webpack_require__(57439);
|
|
5713
5594
|
|
|
5595
|
+
module.exports = Transform;
|
|
5596
|
+
const _require$codes = (__webpack_require__(18128)/* .codes */ .q),
|
|
5597
|
+
ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
|
|
5598
|
+
ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
|
|
5599
|
+
ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
|
|
5600
|
+
ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
|
|
5601
|
+
const Duplex = __webpack_require__(57439);
|
|
5714
5602
|
__webpack_require__(90838)(Transform, Duplex);
|
|
5715
|
-
|
|
5716
5603
|
function afterTransform(er, data) {
|
|
5717
5604
|
var ts = this._transformState;
|
|
5718
5605
|
ts.transforming = false;
|
|
5719
5606
|
var cb = ts.writecb;
|
|
5720
|
-
|
|
5721
5607
|
if (cb === null) {
|
|
5722
5608
|
return this.emit('error', new ERR_MULTIPLE_CALLBACK());
|
|
5723
5609
|
}
|
|
5724
|
-
|
|
5725
5610
|
ts.writechunk = null;
|
|
5726
5611
|
ts.writecb = null;
|
|
5727
|
-
if (data != null)
|
|
5612
|
+
if (data != null)
|
|
5613
|
+
// single equals check for both `null` and `undefined`
|
|
5728
5614
|
this.push(data);
|
|
5729
5615
|
cb(er);
|
|
5730
5616
|
var rs = this._readableState;
|
|
5731
5617
|
rs.reading = false;
|
|
5732
|
-
|
|
5733
5618
|
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
|
5734
5619
|
this._read(rs.highWaterMark);
|
|
5735
5620
|
}
|
|
5736
5621
|
}
|
|
5737
|
-
|
|
5738
5622
|
function Transform(options) {
|
|
5739
5623
|
if (!(this instanceof Transform)) return new Transform(options);
|
|
5740
5624
|
Duplex.call(this, options);
|
|
@@ -5745,39 +5629,38 @@ function Transform(options) {
|
|
|
5745
5629
|
writecb: null,
|
|
5746
5630
|
writechunk: null,
|
|
5747
5631
|
writeencoding: null
|
|
5748
|
-
};
|
|
5632
|
+
};
|
|
5633
|
+
|
|
5634
|
+
// start out asking for a readable event once data is transformed.
|
|
5635
|
+
this._readableState.needReadable = true;
|
|
5749
5636
|
|
|
5750
|
-
|
|
5637
|
+
// we have implemented the _read method, and done the other things
|
|
5751
5638
|
// that Readable wants before the first _read call, so unset the
|
|
5752
5639
|
// sync guard flag.
|
|
5753
|
-
|
|
5754
5640
|
this._readableState.sync = false;
|
|
5755
|
-
|
|
5756
5641
|
if (options) {
|
|
5757
5642
|
if (typeof options.transform === 'function') this._transform = options.transform;
|
|
5758
5643
|
if (typeof options.flush === 'function') this._flush = options.flush;
|
|
5759
|
-
}
|
|
5760
|
-
|
|
5644
|
+
}
|
|
5761
5645
|
|
|
5646
|
+
// When the writable side finishes, then flush out anything remaining.
|
|
5762
5647
|
this.on('prefinish', prefinish);
|
|
5763
5648
|
}
|
|
5764
|
-
|
|
5765
5649
|
function prefinish() {
|
|
5766
|
-
var _this = this;
|
|
5767
|
-
|
|
5768
5650
|
if (typeof this._flush === 'function' && !this._readableState.destroyed) {
|
|
5769
|
-
this._flush(
|
|
5770
|
-
done(
|
|
5651
|
+
this._flush((er, data) => {
|
|
5652
|
+
done(this, er, data);
|
|
5771
5653
|
});
|
|
5772
5654
|
} else {
|
|
5773
5655
|
done(this, null, null);
|
|
5774
5656
|
}
|
|
5775
5657
|
}
|
|
5776
|
-
|
|
5777
5658
|
Transform.prototype.push = function (chunk, encoding) {
|
|
5778
5659
|
this._transformState.needTransform = false;
|
|
5779
5660
|
return Duplex.prototype.push.call(this, chunk, encoding);
|
|
5780
|
-
};
|
|
5661
|
+
};
|
|
5662
|
+
|
|
5663
|
+
// This is the part where you do stuff!
|
|
5781
5664
|
// override this function in implementation classes.
|
|
5782
5665
|
// 'chunk' is an input chunk.
|
|
5783
5666
|
//
|
|
@@ -5787,33 +5670,27 @@ Transform.prototype.push = function (chunk, encoding) {
|
|
|
5787
5670
|
// Call `cb(err)` when you are done with this chunk. If you pass
|
|
5788
5671
|
// an error, then that'll put the hurt on the whole operation. If you
|
|
5789
5672
|
// never call cb(), then you'll never get another chunk.
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
5673
|
Transform.prototype._transform = function (chunk, encoding, cb) {
|
|
5793
5674
|
cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));
|
|
5794
5675
|
};
|
|
5795
|
-
|
|
5796
5676
|
Transform.prototype._write = function (chunk, encoding, cb) {
|
|
5797
5677
|
var ts = this._transformState;
|
|
5798
5678
|
ts.writecb = cb;
|
|
5799
5679
|
ts.writechunk = chunk;
|
|
5800
5680
|
ts.writeencoding = encoding;
|
|
5801
|
-
|
|
5802
5681
|
if (!ts.transforming) {
|
|
5803
5682
|
var rs = this._readableState;
|
|
5804
5683
|
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
|
|
5805
5684
|
}
|
|
5806
|
-
};
|
|
5685
|
+
};
|
|
5686
|
+
|
|
5687
|
+
// Doesn't matter what the args are here.
|
|
5807
5688
|
// _transform does all the work.
|
|
5808
5689
|
// That we got here means that the readable side wants more data.
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
5690
|
Transform.prototype._read = function (n) {
|
|
5812
5691
|
var ts = this._transformState;
|
|
5813
|
-
|
|
5814
5692
|
if (ts.writechunk !== null && !ts.transforming) {
|
|
5815
5693
|
ts.transforming = true;
|
|
5816
|
-
|
|
5817
5694
|
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
|
5818
5695
|
} else {
|
|
5819
5696
|
// mark that we need a transform, so that any data that comes in
|
|
@@ -5821,20 +5698,20 @@ Transform.prototype._read = function (n) {
|
|
|
5821
5698
|
ts.needTransform = true;
|
|
5822
5699
|
}
|
|
5823
5700
|
};
|
|
5824
|
-
|
|
5825
5701
|
Transform.prototype._destroy = function (err, cb) {
|
|
5826
|
-
Duplex.prototype._destroy.call(this, err,
|
|
5702
|
+
Duplex.prototype._destroy.call(this, err, err2 => {
|
|
5827
5703
|
cb(err2);
|
|
5828
5704
|
});
|
|
5829
5705
|
};
|
|
5830
|
-
|
|
5831
5706
|
function done(stream, er, data) {
|
|
5832
5707
|
if (er) return stream.emit('error', er);
|
|
5833
|
-
if (data != null)
|
|
5834
|
-
|
|
5708
|
+
if (data != null)
|
|
5709
|
+
// single equals check for both `null` and `undefined`
|
|
5710
|
+
stream.push(data);
|
|
5711
|
+
|
|
5712
|
+
// TODO(BridgeAR): Write a test for these two error cases
|
|
5835
5713
|
// if there's nothing in the write buffer, then that means
|
|
5836
5714
|
// that nothing more will ever be provided
|
|
5837
|
-
|
|
5838
5715
|
if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();
|
|
5839
5716
|
if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();
|
|
5840
5717
|
return stream.push(null);
|
|
@@ -5866,185 +5743,188 @@ function done(stream, er, data) {
|
|
|
5866
5743
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
5867
5744
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
5868
5745
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
5746
|
+
|
|
5869
5747
|
// A bit simpler than readable streams.
|
|
5870
5748
|
// Implement an async ._write(chunk, encoding, cb), and it'll handle all
|
|
5871
5749
|
// the drain event emission and buffering.
|
|
5872
5750
|
|
|
5873
5751
|
|
|
5752
|
+
|
|
5874
5753
|
module.exports = Writable;
|
|
5875
|
-
/* <replacement> */
|
|
5876
5754
|
|
|
5755
|
+
/* <replacement> */
|
|
5877
5756
|
function WriteReq(chunk, encoding, cb) {
|
|
5878
5757
|
this.chunk = chunk;
|
|
5879
5758
|
this.encoding = encoding;
|
|
5880
5759
|
this.callback = cb;
|
|
5881
5760
|
this.next = null;
|
|
5882
|
-
}
|
|
5883
|
-
// there will be only 2 of these for each stream
|
|
5884
|
-
|
|
5761
|
+
}
|
|
5885
5762
|
|
|
5763
|
+
// It seems a linked list but it is not
|
|
5764
|
+
// there will be only 2 of these for each stream
|
|
5886
5765
|
function CorkedRequest(state) {
|
|
5887
|
-
var _this = this;
|
|
5888
|
-
|
|
5889
5766
|
this.next = null;
|
|
5890
5767
|
this.entry = null;
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
onCorkedFinish(_this, state);
|
|
5768
|
+
this.finish = () => {
|
|
5769
|
+
onCorkedFinish(this, state);
|
|
5894
5770
|
};
|
|
5895
5771
|
}
|
|
5896
5772
|
/* </replacement> */
|
|
5897
5773
|
|
|
5898
5774
|
/*<replacement>*/
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
5775
|
var Duplex;
|
|
5902
5776
|
/*</replacement>*/
|
|
5903
5777
|
|
|
5904
5778
|
Writable.WritableState = WritableState;
|
|
5905
|
-
/*<replacement>*/
|
|
5906
5779
|
|
|
5907
|
-
|
|
5780
|
+
/*<replacement>*/
|
|
5781
|
+
const internalUtil = {
|
|
5908
5782
|
deprecate: __webpack_require__(89671)
|
|
5909
5783
|
};
|
|
5910
5784
|
/*</replacement>*/
|
|
5911
5785
|
|
|
5912
5786
|
/*<replacement>*/
|
|
5913
|
-
|
|
5914
5787
|
var Stream = __webpack_require__(2184);
|
|
5915
5788
|
/*</replacement>*/
|
|
5916
5789
|
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
var OurUint8Array = global.Uint8Array || function () {};
|
|
5921
|
-
|
|
5790
|
+
const Buffer = (__webpack_require__(60871).Buffer);
|
|
5791
|
+
const OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
|
|
5922
5792
|
function _uint8ArrayToBuffer(chunk) {
|
|
5923
5793
|
return Buffer.from(chunk);
|
|
5924
5794
|
}
|
|
5925
|
-
|
|
5926
5795
|
function _isUint8Array(obj) {
|
|
5927
5796
|
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
5928
5797
|
}
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,
|
|
5943
|
-
ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
|
|
5944
|
-
|
|
5945
|
-
var errorOrDestroy = destroyImpl.errorOrDestroy;
|
|
5946
|
-
|
|
5798
|
+
const destroyImpl = __webpack_require__(52576);
|
|
5799
|
+
const _require = __webpack_require__(74479),
|
|
5800
|
+
getHighWaterMark = _require.getHighWaterMark;
|
|
5801
|
+
const _require$codes = (__webpack_require__(18128)/* .codes */ .q),
|
|
5802
|
+
ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
|
|
5803
|
+
ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
|
|
5804
|
+
ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
|
|
5805
|
+
ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,
|
|
5806
|
+
ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,
|
|
5807
|
+
ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,
|
|
5808
|
+
ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,
|
|
5809
|
+
ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
|
|
5810
|
+
const errorOrDestroy = destroyImpl.errorOrDestroy;
|
|
5947
5811
|
__webpack_require__(90838)(Writable, Stream);
|
|
5948
|
-
|
|
5949
5812
|
function nop() {}
|
|
5950
|
-
|
|
5951
5813
|
function WritableState(options, stream, isDuplex) {
|
|
5952
5814
|
Duplex = Duplex || __webpack_require__(57439);
|
|
5953
|
-
options = options || {};
|
|
5815
|
+
options = options || {};
|
|
5816
|
+
|
|
5817
|
+
// Duplex streams are both readable and writable, but share
|
|
5954
5818
|
// the same options object.
|
|
5955
5819
|
// However, some cases require setting options to different
|
|
5956
5820
|
// values for the readable and the writable sides of the duplex stream,
|
|
5957
5821
|
// e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
|
|
5822
|
+
if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex;
|
|
5958
5823
|
|
|
5959
|
-
|
|
5824
|
+
// object stream flag to indicate whether or not this stream
|
|
5960
5825
|
// contains buffers or objects.
|
|
5961
|
-
|
|
5962
5826
|
this.objectMode = !!options.objectMode;
|
|
5963
|
-
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
|
|
5827
|
+
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
|
|
5828
|
+
|
|
5829
|
+
// the point at which write() starts returning false
|
|
5964
5830
|
// Note: 0 is a valid value, means that we always return false if
|
|
5965
5831
|
// the entire buffer is not flushed immediately on write()
|
|
5832
|
+
this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex);
|
|
5966
5833
|
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
this.finalCalled = false; // drain event flag.
|
|
5834
|
+
// if _final has been called
|
|
5835
|
+
this.finalCalled = false;
|
|
5970
5836
|
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
|
|
5837
|
+
// drain event flag.
|
|
5838
|
+
this.needDrain = false;
|
|
5839
|
+
// at the start of calling end()
|
|
5840
|
+
this.ending = false;
|
|
5841
|
+
// when end() has been called, and returned
|
|
5842
|
+
this.ended = false;
|
|
5843
|
+
// when 'finish' is emitted
|
|
5844
|
+
this.finished = false;
|
|
5976
5845
|
|
|
5977
|
-
|
|
5846
|
+
// has it been destroyed
|
|
5847
|
+
this.destroyed = false;
|
|
5978
5848
|
|
|
5979
|
-
|
|
5849
|
+
// should we decode strings into buffers before passing to _write?
|
|
5980
5850
|
// this is here so that some node-core streams can optimize string
|
|
5981
5851
|
// handling at a lower level.
|
|
5982
|
-
|
|
5983
5852
|
var noDecode = options.decodeStrings === false;
|
|
5984
|
-
this.decodeStrings = !noDecode;
|
|
5853
|
+
this.decodeStrings = !noDecode;
|
|
5854
|
+
|
|
5855
|
+
// Crypto is kind of old and crusty. Historically, its default string
|
|
5985
5856
|
// encoding is 'binary' so we have to make this configurable.
|
|
5986
5857
|
// Everything else in the universe uses 'utf8', though.
|
|
5858
|
+
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
|
5987
5859
|
|
|
5988
|
-
|
|
5860
|
+
// not an actual buffer we keep track of, but a measurement
|
|
5989
5861
|
// of how much we're waiting to get pushed to some underlying
|
|
5990
5862
|
// socket or file.
|
|
5863
|
+
this.length = 0;
|
|
5991
5864
|
|
|
5992
|
-
|
|
5865
|
+
// a flag to see when we're in the middle of a write.
|
|
5866
|
+
this.writing = false;
|
|
5993
5867
|
|
|
5994
|
-
|
|
5868
|
+
// when true all writes will be buffered until .uncork() call
|
|
5869
|
+
this.corked = 0;
|
|
5995
5870
|
|
|
5996
|
-
|
|
5871
|
+
// a flag to be able to tell if the onwrite cb is called immediately,
|
|
5997
5872
|
// or on a later tick. We set this to true at first, because any
|
|
5998
5873
|
// actions that shouldn't happen until "later" should generally also
|
|
5999
5874
|
// not happen before the first write call.
|
|
5875
|
+
this.sync = true;
|
|
6000
5876
|
|
|
6001
|
-
|
|
5877
|
+
// a flag to know if we're processing previously buffered items, which
|
|
6002
5878
|
// may call the _write() callback in the same tick, so that we don't
|
|
6003
5879
|
// end up in an overlapped onwrite situation.
|
|
5880
|
+
this.bufferProcessing = false;
|
|
6004
5881
|
|
|
6005
|
-
|
|
6006
|
-
|
|
5882
|
+
// the callback that's passed to _write(chunk,cb)
|
|
6007
5883
|
this.onwrite = function (er) {
|
|
6008
5884
|
onwrite(stream, er);
|
|
6009
|
-
};
|
|
6010
|
-
|
|
5885
|
+
};
|
|
6011
5886
|
|
|
6012
|
-
|
|
5887
|
+
// the callback that the user supplies to write(chunk,encoding,cb)
|
|
5888
|
+
this.writecb = null;
|
|
6013
5889
|
|
|
5890
|
+
// the amount that is being written when _write is called.
|
|
6014
5891
|
this.writelen = 0;
|
|
6015
5892
|
this.bufferedRequest = null;
|
|
6016
|
-
this.lastBufferedRequest = null;
|
|
5893
|
+
this.lastBufferedRequest = null;
|
|
5894
|
+
|
|
5895
|
+
// number of pending user-supplied write callbacks
|
|
6017
5896
|
// this must be 0 before 'finish' can be emitted
|
|
5897
|
+
this.pendingcb = 0;
|
|
6018
5898
|
|
|
6019
|
-
|
|
5899
|
+
// emit prefinish if the only thing we're waiting for is _write cbs
|
|
6020
5900
|
// This is relevant for synchronous Transform streams
|
|
5901
|
+
this.prefinished = false;
|
|
6021
5902
|
|
|
6022
|
-
|
|
5903
|
+
// True if the error was already emitted and should not be thrown again
|
|
5904
|
+
this.errorEmitted = false;
|
|
6023
5905
|
|
|
6024
|
-
|
|
5906
|
+
// Should close be emitted on destroy. Defaults to true.
|
|
5907
|
+
this.emitClose = options.emitClose !== false;
|
|
6025
5908
|
|
|
6026
|
-
|
|
5909
|
+
// Should .destroy() be called after 'finish' (and potentially 'end')
|
|
5910
|
+
this.autoDestroy = !!options.autoDestroy;
|
|
6027
5911
|
|
|
6028
|
-
|
|
5912
|
+
// count buffered requests
|
|
5913
|
+
this.bufferedRequestCount = 0;
|
|
6029
5914
|
|
|
6030
|
-
|
|
5915
|
+
// allocate the first CorkedRequest, there is always
|
|
6031
5916
|
// one allocated and free to use, and we maintain at most two
|
|
6032
|
-
|
|
6033
5917
|
this.corkedRequestsFree = new CorkedRequest(this);
|
|
6034
5918
|
}
|
|
6035
|
-
|
|
6036
5919
|
WritableState.prototype.getBuffer = function getBuffer() {
|
|
6037
5920
|
var current = this.bufferedRequest;
|
|
6038
5921
|
var out = [];
|
|
6039
|
-
|
|
6040
5922
|
while (current) {
|
|
6041
5923
|
out.push(current);
|
|
6042
5924
|
current = current.next;
|
|
6043
5925
|
}
|
|
6044
|
-
|
|
6045
5926
|
return out;
|
|
6046
5927
|
};
|
|
6047
|
-
|
|
6048
5928
|
(function () {
|
|
6049
5929
|
try {
|
|
6050
5930
|
Object.defineProperty(WritableState.prototype, 'buffer', {
|
|
@@ -6053,12 +5933,11 @@ WritableState.prototype.getBuffer = function getBuffer() {
|
|
|
6053
5933
|
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
|
|
6054
5934
|
});
|
|
6055
5935
|
} catch (_) {}
|
|
6056
|
-
})();
|
|
6057
|
-
// whose prototype chain only points to Readable.
|
|
6058
|
-
|
|
5936
|
+
})();
|
|
6059
5937
|
|
|
5938
|
+
// Test _writableState for inheritance to account for Duplex streams,
|
|
5939
|
+
// whose prototype chain only points to Readable.
|
|
6060
5940
|
var realHasInstance;
|
|
6061
|
-
|
|
6062
5941
|
if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
|
|
6063
5942
|
realHasInstance = Function.prototype[Symbol.hasInstance];
|
|
6064
5943
|
Object.defineProperty(Writable, Symbol.hasInstance, {
|
|
@@ -6073,81 +5952,73 @@ if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.protot
|
|
|
6073
5952
|
return object instanceof this;
|
|
6074
5953
|
};
|
|
6075
5954
|
}
|
|
6076
|
-
|
|
6077
5955
|
function Writable(options) {
|
|
6078
|
-
Duplex = Duplex || __webpack_require__(57439);
|
|
5956
|
+
Duplex = Duplex || __webpack_require__(57439);
|
|
5957
|
+
|
|
5958
|
+
// Writable ctor is applied to Duplexes, too.
|
|
6079
5959
|
// `realHasInstance` is necessary because using plain `instanceof`
|
|
6080
5960
|
// would return false, as no `_writableState` property is attached.
|
|
5961
|
+
|
|
6081
5962
|
// Trying to use the custom `instanceof` for Writable here will also break the
|
|
6082
5963
|
// Node.js LazyTransform implementation, which has a non-trivial getter for
|
|
6083
5964
|
// `_writableState` that would lead to infinite recursion.
|
|
5965
|
+
|
|
6084
5966
|
// Checking for a Stream.Duplex instance is faster here instead of inside
|
|
6085
5967
|
// the WritableState constructor, at least with V8 6.5
|
|
6086
|
-
|
|
6087
|
-
var isDuplex = this instanceof Duplex;
|
|
5968
|
+
const isDuplex = this instanceof Duplex;
|
|
6088
5969
|
if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);
|
|
6089
|
-
this._writableState = new WritableState(options, this, isDuplex);
|
|
5970
|
+
this._writableState = new WritableState(options, this, isDuplex);
|
|
6090
5971
|
|
|
5972
|
+
// legacy.
|
|
6091
5973
|
this.writable = true;
|
|
6092
|
-
|
|
6093
5974
|
if (options) {
|
|
6094
5975
|
if (typeof options.write === 'function') this._write = options.write;
|
|
6095
5976
|
if (typeof options.writev === 'function') this._writev = options.writev;
|
|
6096
5977
|
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
|
6097
5978
|
if (typeof options.final === 'function') this._final = options.final;
|
|
6098
5979
|
}
|
|
6099
|
-
|
|
6100
5980
|
Stream.call(this);
|
|
6101
|
-
}
|
|
6102
|
-
|
|
5981
|
+
}
|
|
6103
5982
|
|
|
5983
|
+
// Otherwise people can pipe Writable streams, which is just wrong.
|
|
6104
5984
|
Writable.prototype.pipe = function () {
|
|
6105
5985
|
errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
|
|
6106
5986
|
};
|
|
6107
|
-
|
|
6108
5987
|
function writeAfterEnd(stream, cb) {
|
|
6109
|
-
var er = new ERR_STREAM_WRITE_AFTER_END();
|
|
6110
|
-
|
|
5988
|
+
var er = new ERR_STREAM_WRITE_AFTER_END();
|
|
5989
|
+
// TODO: defer error events consistently everywhere, not just the cb
|
|
6111
5990
|
errorOrDestroy(stream, er);
|
|
6112
5991
|
process.nextTick(cb, er);
|
|
6113
|
-
}
|
|
5992
|
+
}
|
|
5993
|
+
|
|
5994
|
+
// Checks that a user-supplied chunk is valid, especially for the particular
|
|
6114
5995
|
// mode the stream is in. Currently this means that `null` is never accepted
|
|
6115
5996
|
// and undefined/non-string values are only allowed in object mode.
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
5997
|
function validChunk(stream, state, chunk, cb) {
|
|
6119
5998
|
var er;
|
|
6120
|
-
|
|
6121
5999
|
if (chunk === null) {
|
|
6122
6000
|
er = new ERR_STREAM_NULL_VALUES();
|
|
6123
6001
|
} else if (typeof chunk !== 'string' && !state.objectMode) {
|
|
6124
6002
|
er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);
|
|
6125
6003
|
}
|
|
6126
|
-
|
|
6127
6004
|
if (er) {
|
|
6128
6005
|
errorOrDestroy(stream, er);
|
|
6129
6006
|
process.nextTick(cb, er);
|
|
6130
6007
|
return false;
|
|
6131
6008
|
}
|
|
6132
|
-
|
|
6133
6009
|
return true;
|
|
6134
6010
|
}
|
|
6135
|
-
|
|
6136
6011
|
Writable.prototype.write = function (chunk, encoding, cb) {
|
|
6137
6012
|
var state = this._writableState;
|
|
6138
6013
|
var ret = false;
|
|
6139
|
-
|
|
6140
6014
|
var isBuf = !state.objectMode && _isUint8Array(chunk);
|
|
6141
|
-
|
|
6142
6015
|
if (isBuf && !Buffer.isBuffer(chunk)) {
|
|
6143
6016
|
chunk = _uint8ArrayToBuffer(chunk);
|
|
6144
6017
|
}
|
|
6145
|
-
|
|
6146
6018
|
if (typeof encoding === 'function') {
|
|
6147
6019
|
cb = encoding;
|
|
6148
6020
|
encoding = null;
|
|
6149
6021
|
}
|
|
6150
|
-
|
|
6151
6022
|
if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
|
|
6152
6023
|
if (typeof cb !== 'function') cb = nop;
|
|
6153
6024
|
if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
|
|
@@ -6156,20 +6027,16 @@ Writable.prototype.write = function (chunk, encoding, cb) {
|
|
|
6156
6027
|
}
|
|
6157
6028
|
return ret;
|
|
6158
6029
|
};
|
|
6159
|
-
|
|
6160
6030
|
Writable.prototype.cork = function () {
|
|
6161
6031
|
this._writableState.corked++;
|
|
6162
6032
|
};
|
|
6163
|
-
|
|
6164
6033
|
Writable.prototype.uncork = function () {
|
|
6165
6034
|
var state = this._writableState;
|
|
6166
|
-
|
|
6167
6035
|
if (state.corked) {
|
|
6168
6036
|
state.corked--;
|
|
6169
6037
|
if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
|
|
6170
6038
|
}
|
|
6171
6039
|
};
|
|
6172
|
-
|
|
6173
6040
|
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
|
6174
6041
|
// node::ParseEncoding() requires lower case.
|
|
6175
6042
|
if (typeof encoding === 'string') encoding = encoding.toLowerCase();
|
|
@@ -6177,7 +6044,6 @@ Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
|
|
6177
6044
|
this._writableState.defaultEncoding = encoding;
|
|
6178
6045
|
return this;
|
|
6179
6046
|
};
|
|
6180
|
-
|
|
6181
6047
|
Object.defineProperty(Writable.prototype, 'writableBuffer', {
|
|
6182
6048
|
// making it explicit this property is not enumerable
|
|
6183
6049
|
// because otherwise some prototype manipulation in
|
|
@@ -6187,15 +6053,12 @@ Object.defineProperty(Writable.prototype, 'writableBuffer', {
|
|
|
6187
6053
|
return this._writableState && this._writableState.getBuffer();
|
|
6188
6054
|
}
|
|
6189
6055
|
});
|
|
6190
|
-
|
|
6191
6056
|
function decodeChunk(state, chunk, encoding) {
|
|
6192
6057
|
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
|
|
6193
6058
|
chunk = Buffer.from(chunk, encoding);
|
|
6194
6059
|
}
|
|
6195
|
-
|
|
6196
6060
|
return chunk;
|
|
6197
6061
|
}
|
|
6198
|
-
|
|
6199
6062
|
Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
|
|
6200
6063
|
// making it explicit this property is not enumerable
|
|
6201
6064
|
// because otherwise some prototype manipulation in
|
|
@@ -6204,51 +6067,45 @@ Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
|
|
|
6204
6067
|
get: function get() {
|
|
6205
6068
|
return this._writableState.highWaterMark;
|
|
6206
6069
|
}
|
|
6207
|
-
});
|
|
6070
|
+
});
|
|
6071
|
+
|
|
6072
|
+
// if we're already writing something, then just put this
|
|
6208
6073
|
// in the queue, and wait our turn. Otherwise, call _write
|
|
6209
6074
|
// If we return false, then we need a drain event, so set that flag.
|
|
6210
|
-
|
|
6211
6075
|
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
|
|
6212
6076
|
if (!isBuf) {
|
|
6213
6077
|
var newChunk = decodeChunk(state, chunk, encoding);
|
|
6214
|
-
|
|
6215
6078
|
if (chunk !== newChunk) {
|
|
6216
6079
|
isBuf = true;
|
|
6217
6080
|
encoding = 'buffer';
|
|
6218
6081
|
chunk = newChunk;
|
|
6219
6082
|
}
|
|
6220
6083
|
}
|
|
6221
|
-
|
|
6222
6084
|
var len = state.objectMode ? 1 : chunk.length;
|
|
6223
6085
|
state.length += len;
|
|
6224
|
-
var ret = state.length < state.highWaterMark;
|
|
6225
|
-
|
|
6086
|
+
var ret = state.length < state.highWaterMark;
|
|
6087
|
+
// we must ensure that previous needDrain will not be reset to false.
|
|
6226
6088
|
if (!ret) state.needDrain = true;
|
|
6227
|
-
|
|
6228
6089
|
if (state.writing || state.corked) {
|
|
6229
6090
|
var last = state.lastBufferedRequest;
|
|
6230
6091
|
state.lastBufferedRequest = {
|
|
6231
|
-
chunk
|
|
6232
|
-
encoding
|
|
6233
|
-
isBuf
|
|
6092
|
+
chunk,
|
|
6093
|
+
encoding,
|
|
6094
|
+
isBuf,
|
|
6234
6095
|
callback: cb,
|
|
6235
6096
|
next: null
|
|
6236
6097
|
};
|
|
6237
|
-
|
|
6238
6098
|
if (last) {
|
|
6239
6099
|
last.next = state.lastBufferedRequest;
|
|
6240
6100
|
} else {
|
|
6241
6101
|
state.bufferedRequest = state.lastBufferedRequest;
|
|
6242
6102
|
}
|
|
6243
|
-
|
|
6244
6103
|
state.bufferedRequestCount += 1;
|
|
6245
6104
|
} else {
|
|
6246
6105
|
doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
6247
6106
|
}
|
|
6248
|
-
|
|
6249
6107
|
return ret;
|
|
6250
6108
|
}
|
|
6251
|
-
|
|
6252
6109
|
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
|
6253
6110
|
state.writelen = len;
|
|
6254
6111
|
state.writecb = cb;
|
|
@@ -6257,16 +6114,14 @@ function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
|
|
6257
6114
|
if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
|
|
6258
6115
|
state.sync = false;
|
|
6259
6116
|
}
|
|
6260
|
-
|
|
6261
6117
|
function onwriteError(stream, state, sync, er, cb) {
|
|
6262
6118
|
--state.pendingcb;
|
|
6263
|
-
|
|
6264
6119
|
if (sync) {
|
|
6265
6120
|
// defer the callback if we are being called synchronously
|
|
6266
6121
|
// to avoid piling up things on the stack
|
|
6267
|
-
process.nextTick(cb, er);
|
|
6122
|
+
process.nextTick(cb, er);
|
|
6123
|
+
// this can emit finish, and it will always happen
|
|
6268
6124
|
// after error
|
|
6269
|
-
|
|
6270
6125
|
process.nextTick(finishMaybe, stream, state);
|
|
6271
6126
|
stream._writableState.errorEmitted = true;
|
|
6272
6127
|
errorOrDestroy(stream, er);
|
|
@@ -6275,20 +6130,18 @@ function onwriteError(stream, state, sync, er, cb) {
|
|
|
6275
6130
|
// it is async
|
|
6276
6131
|
cb(er);
|
|
6277
6132
|
stream._writableState.errorEmitted = true;
|
|
6278
|
-
errorOrDestroy(stream, er);
|
|
6133
|
+
errorOrDestroy(stream, er);
|
|
6134
|
+
// this can emit finish, but finish must
|
|
6279
6135
|
// always follow error
|
|
6280
|
-
|
|
6281
6136
|
finishMaybe(stream, state);
|
|
6282
6137
|
}
|
|
6283
6138
|
}
|
|
6284
|
-
|
|
6285
6139
|
function onwriteStateUpdate(state) {
|
|
6286
6140
|
state.writing = false;
|
|
6287
6141
|
state.writecb = null;
|
|
6288
6142
|
state.length -= state.writelen;
|
|
6289
6143
|
state.writelen = 0;
|
|
6290
6144
|
}
|
|
6291
|
-
|
|
6292
6145
|
function onwrite(stream, er) {
|
|
6293
6146
|
var state = stream._writableState;
|
|
6294
6147
|
var sync = state.sync;
|
|
@@ -6298,11 +6151,9 @@ function onwrite(stream, er) {
|
|
|
6298
6151
|
if (er) onwriteError(stream, state, sync, er, cb);else {
|
|
6299
6152
|
// Check if we're actually ready to finish, but don't emit yet
|
|
6300
6153
|
var finished = needFinish(state) || stream.destroyed;
|
|
6301
|
-
|
|
6302
6154
|
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
|
|
6303
6155
|
clearBuffer(stream, state);
|
|
6304
6156
|
}
|
|
6305
|
-
|
|
6306
6157
|
if (sync) {
|
|
6307
6158
|
process.nextTick(afterWrite, stream, state, finished, cb);
|
|
6308
6159
|
} else {
|
|
@@ -6310,29 +6161,27 @@ function onwrite(stream, er) {
|
|
|
6310
6161
|
}
|
|
6311
6162
|
}
|
|
6312
6163
|
}
|
|
6313
|
-
|
|
6314
6164
|
function afterWrite(stream, state, finished, cb) {
|
|
6315
6165
|
if (!finished) onwriteDrain(stream, state);
|
|
6316
6166
|
state.pendingcb--;
|
|
6317
6167
|
cb();
|
|
6318
6168
|
finishMaybe(stream, state);
|
|
6319
|
-
}
|
|
6169
|
+
}
|
|
6170
|
+
|
|
6171
|
+
// Must force callback to be called on nextTick, so that we don't
|
|
6320
6172
|
// emit 'drain' before the write() consumer gets the 'false' return
|
|
6321
6173
|
// value, and has a chance to attach a 'drain' listener.
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
6174
|
function onwriteDrain(stream, state) {
|
|
6325
6175
|
if (state.length === 0 && state.needDrain) {
|
|
6326
6176
|
state.needDrain = false;
|
|
6327
6177
|
stream.emit('drain');
|
|
6328
6178
|
}
|
|
6329
|
-
}
|
|
6330
|
-
|
|
6179
|
+
}
|
|
6331
6180
|
|
|
6181
|
+
// if there's something in the buffer waiting, then process it
|
|
6332
6182
|
function clearBuffer(stream, state) {
|
|
6333
6183
|
state.bufferProcessing = true;
|
|
6334
6184
|
var entry = state.bufferedRequest;
|
|
6335
|
-
|
|
6336
6185
|
if (stream._writev && entry && entry.next) {
|
|
6337
6186
|
// Fast case, write everything using _writev()
|
|
6338
6187
|
var l = state.bufferedRequestCount;
|
|
@@ -6341,28 +6190,25 @@ function clearBuffer(stream, state) {
|
|
|
6341
6190
|
holder.entry = entry;
|
|
6342
6191
|
var count = 0;
|
|
6343
6192
|
var allBuffers = true;
|
|
6344
|
-
|
|
6345
6193
|
while (entry) {
|
|
6346
6194
|
buffer[count] = entry;
|
|
6347
6195
|
if (!entry.isBuf) allBuffers = false;
|
|
6348
6196
|
entry = entry.next;
|
|
6349
6197
|
count += 1;
|
|
6350
6198
|
}
|
|
6351
|
-
|
|
6352
6199
|
buffer.allBuffers = allBuffers;
|
|
6353
|
-
doWrite(stream, state, true, state.length, buffer, '', holder.finish);
|
|
6354
|
-
// as the hot path ends with doWrite
|
|
6200
|
+
doWrite(stream, state, true, state.length, buffer, '', holder.finish);
|
|
6355
6201
|
|
|
6202
|
+
// doWrite is almost always async, defer these to save a bit of time
|
|
6203
|
+
// as the hot path ends with doWrite
|
|
6356
6204
|
state.pendingcb++;
|
|
6357
6205
|
state.lastBufferedRequest = null;
|
|
6358
|
-
|
|
6359
6206
|
if (holder.next) {
|
|
6360
6207
|
state.corkedRequestsFree = holder.next;
|
|
6361
6208
|
holder.next = null;
|
|
6362
6209
|
} else {
|
|
6363
6210
|
state.corkedRequestsFree = new CorkedRequest(state);
|
|
6364
6211
|
}
|
|
6365
|
-
|
|
6366
6212
|
state.bufferedRequestCount = 0;
|
|
6367
6213
|
} else {
|
|
6368
6214
|
// Slow case, write chunks one-by-one
|
|
@@ -6373,32 +6219,26 @@ function clearBuffer(stream, state) {
|
|
|
6373
6219
|
var len = state.objectMode ? 1 : chunk.length;
|
|
6374
6220
|
doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
6375
6221
|
entry = entry.next;
|
|
6376
|
-
state.bufferedRequestCount--;
|
|
6222
|
+
state.bufferedRequestCount--;
|
|
6223
|
+
// if we didn't call the onwrite immediately, then
|
|
6377
6224
|
// it means that we need to wait until it does.
|
|
6378
6225
|
// also, that means that the chunk and cb are currently
|
|
6379
6226
|
// being processed, so move the buffer counter past them.
|
|
6380
|
-
|
|
6381
6227
|
if (state.writing) {
|
|
6382
6228
|
break;
|
|
6383
6229
|
}
|
|
6384
6230
|
}
|
|
6385
|
-
|
|
6386
6231
|
if (entry === null) state.lastBufferedRequest = null;
|
|
6387
6232
|
}
|
|
6388
|
-
|
|
6389
6233
|
state.bufferedRequest = entry;
|
|
6390
6234
|
state.bufferProcessing = false;
|
|
6391
6235
|
}
|
|
6392
|
-
|
|
6393
6236
|
Writable.prototype._write = function (chunk, encoding, cb) {
|
|
6394
6237
|
cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));
|
|
6395
6238
|
};
|
|
6396
|
-
|
|
6397
6239
|
Writable.prototype._writev = null;
|
|
6398
|
-
|
|
6399
6240
|
Writable.prototype.end = function (chunk, encoding, cb) {
|
|
6400
6241
|
var state = this._writableState;
|
|
6401
|
-
|
|
6402
6242
|
if (typeof chunk === 'function') {
|
|
6403
6243
|
cb = chunk;
|
|
6404
6244
|
chunk = null;
|
|
@@ -6407,47 +6247,41 @@ Writable.prototype.end = function (chunk, encoding, cb) {
|
|
|
6407
6247
|
cb = encoding;
|
|
6408
6248
|
encoding = null;
|
|
6409
6249
|
}
|
|
6250
|
+
if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
|
|
6410
6251
|
|
|
6411
|
-
|
|
6412
|
-
|
|
6252
|
+
// .end() fully uncorks
|
|
6413
6253
|
if (state.corked) {
|
|
6414
6254
|
state.corked = 1;
|
|
6415
6255
|
this.uncork();
|
|
6416
|
-
}
|
|
6417
|
-
|
|
6256
|
+
}
|
|
6418
6257
|
|
|
6258
|
+
// ignore unnecessary end() calls.
|
|
6419
6259
|
if (!state.ending) endWritable(this, state, cb);
|
|
6420
6260
|
return this;
|
|
6421
6261
|
};
|
|
6422
|
-
|
|
6423
6262
|
Object.defineProperty(Writable.prototype, 'writableLength', {
|
|
6424
6263
|
// making it explicit this property is not enumerable
|
|
6425
6264
|
// because otherwise some prototype manipulation in
|
|
6426
6265
|
// userland will fail
|
|
6427
6266
|
enumerable: false,
|
|
6428
|
-
get
|
|
6267
|
+
get() {
|
|
6429
6268
|
return this._writableState.length;
|
|
6430
6269
|
}
|
|
6431
6270
|
});
|
|
6432
|
-
|
|
6433
6271
|
function needFinish(state) {
|
|
6434
6272
|
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
|
6435
6273
|
}
|
|
6436
|
-
|
|
6437
6274
|
function callFinal(stream, state) {
|
|
6438
|
-
stream._final(
|
|
6275
|
+
stream._final(err => {
|
|
6439
6276
|
state.pendingcb--;
|
|
6440
|
-
|
|
6441
6277
|
if (err) {
|
|
6442
6278
|
errorOrDestroy(stream, err);
|
|
6443
6279
|
}
|
|
6444
|
-
|
|
6445
6280
|
state.prefinished = true;
|
|
6446
6281
|
stream.emit('prefinish');
|
|
6447
6282
|
finishMaybe(stream, state);
|
|
6448
6283
|
});
|
|
6449
6284
|
}
|
|
6450
|
-
|
|
6451
6285
|
function prefinish(stream, state) {
|
|
6452
6286
|
if (!state.prefinished && !state.finalCalled) {
|
|
6453
6287
|
if (typeof stream._final === 'function' && !state.destroyed) {
|
|
@@ -6460,86 +6294,72 @@ function prefinish(stream, state) {
|
|
|
6460
6294
|
}
|
|
6461
6295
|
}
|
|
6462
6296
|
}
|
|
6463
|
-
|
|
6464
6297
|
function finishMaybe(stream, state) {
|
|
6465
6298
|
var need = needFinish(state);
|
|
6466
|
-
|
|
6467
6299
|
if (need) {
|
|
6468
6300
|
prefinish(stream, state);
|
|
6469
|
-
|
|
6470
6301
|
if (state.pendingcb === 0) {
|
|
6471
6302
|
state.finished = true;
|
|
6472
6303
|
stream.emit('finish');
|
|
6473
|
-
|
|
6474
6304
|
if (state.autoDestroy) {
|
|
6475
6305
|
// In case of duplex streams we need a way to detect
|
|
6476
6306
|
// if the readable side is ready for autoDestroy as well
|
|
6477
|
-
|
|
6478
|
-
|
|
6307
|
+
const rState = stream._readableState;
|
|
6479
6308
|
if (!rState || rState.autoDestroy && rState.endEmitted) {
|
|
6480
6309
|
stream.destroy();
|
|
6481
6310
|
}
|
|
6482
6311
|
}
|
|
6483
6312
|
}
|
|
6484
6313
|
}
|
|
6485
|
-
|
|
6486
6314
|
return need;
|
|
6487
6315
|
}
|
|
6488
|
-
|
|
6489
6316
|
function endWritable(stream, state, cb) {
|
|
6490
6317
|
state.ending = true;
|
|
6491
6318
|
finishMaybe(stream, state);
|
|
6492
|
-
|
|
6493
6319
|
if (cb) {
|
|
6494
6320
|
if (state.finished) process.nextTick(cb);else stream.once('finish', cb);
|
|
6495
6321
|
}
|
|
6496
|
-
|
|
6497
6322
|
state.ended = true;
|
|
6498
6323
|
stream.writable = false;
|
|
6499
6324
|
}
|
|
6500
|
-
|
|
6501
6325
|
function onCorkedFinish(corkReq, state, err) {
|
|
6502
6326
|
var entry = corkReq.entry;
|
|
6503
6327
|
corkReq.entry = null;
|
|
6504
|
-
|
|
6505
6328
|
while (entry) {
|
|
6506
6329
|
var cb = entry.callback;
|
|
6507
6330
|
state.pendingcb--;
|
|
6508
6331
|
cb(err);
|
|
6509
6332
|
entry = entry.next;
|
|
6510
|
-
}
|
|
6511
|
-
|
|
6333
|
+
}
|
|
6512
6334
|
|
|
6335
|
+
// reuse the free corkReq.
|
|
6513
6336
|
state.corkedRequestsFree.next = corkReq;
|
|
6514
6337
|
}
|
|
6515
|
-
|
|
6516
6338
|
Object.defineProperty(Writable.prototype, 'destroyed', {
|
|
6517
6339
|
// making it explicit this property is not enumerable
|
|
6518
6340
|
// because otherwise some prototype manipulation in
|
|
6519
6341
|
// userland will fail
|
|
6520
6342
|
enumerable: false,
|
|
6521
|
-
get
|
|
6343
|
+
get() {
|
|
6522
6344
|
if (this._writableState === undefined) {
|
|
6523
6345
|
return false;
|
|
6524
6346
|
}
|
|
6525
|
-
|
|
6526
6347
|
return this._writableState.destroyed;
|
|
6527
6348
|
},
|
|
6528
|
-
set
|
|
6349
|
+
set(value) {
|
|
6529
6350
|
// we ignore the value if the stream
|
|
6530
6351
|
// has not been initialized yet
|
|
6531
6352
|
if (!this._writableState) {
|
|
6532
6353
|
return;
|
|
6533
|
-
}
|
|
6534
|
-
// managing destroyed
|
|
6535
|
-
|
|
6354
|
+
}
|
|
6536
6355
|
|
|
6356
|
+
// backward compatibility, the user is explicitly
|
|
6357
|
+
// managing destroyed
|
|
6537
6358
|
this._writableState.destroyed = value;
|
|
6538
6359
|
}
|
|
6539
6360
|
});
|
|
6540
6361
|
Writable.prototype.destroy = destroyImpl.destroy;
|
|
6541
6362
|
Writable.prototype._undestroy = destroyImpl.undestroy;
|
|
6542
|
-
|
|
6543
6363
|
Writable.prototype._destroy = function (err, cb) {
|
|
6544
6364
|
cb(err);
|
|
6545
6365
|
};
|
|
@@ -6552,35 +6372,27 @@ Writable.prototype._destroy = function (err, cb) {
|
|
|
6552
6372
|
"use strict";
|
|
6553
6373
|
|
|
6554
6374
|
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
var kError = Symbol('error');
|
|
6564
|
-
var kEnded = Symbol('ended');
|
|
6565
|
-
var kLastPromise = Symbol('lastPromise');
|
|
6566
|
-
var kHandlePromise = Symbol('handlePromise');
|
|
6567
|
-
var kStream = Symbol('stream');
|
|
6568
|
-
|
|
6375
|
+
const finished = __webpack_require__(30685);
|
|
6376
|
+
const kLastResolve = Symbol('lastResolve');
|
|
6377
|
+
const kLastReject = Symbol('lastReject');
|
|
6378
|
+
const kError = Symbol('error');
|
|
6379
|
+
const kEnded = Symbol('ended');
|
|
6380
|
+
const kLastPromise = Symbol('lastPromise');
|
|
6381
|
+
const kHandlePromise = Symbol('handlePromise');
|
|
6382
|
+
const kStream = Symbol('stream');
|
|
6569
6383
|
function createIterResult(value, done) {
|
|
6570
6384
|
return {
|
|
6571
|
-
value
|
|
6572
|
-
done
|
|
6385
|
+
value,
|
|
6386
|
+
done
|
|
6573
6387
|
};
|
|
6574
6388
|
}
|
|
6575
|
-
|
|
6576
6389
|
function readAndResolve(iter) {
|
|
6577
|
-
|
|
6578
|
-
|
|
6390
|
+
const resolve = iter[kLastResolve];
|
|
6579
6391
|
if (resolve !== null) {
|
|
6580
|
-
|
|
6392
|
+
const data = iter[kStream].read();
|
|
6393
|
+
// we defer if data is null
|
|
6581
6394
|
// we can be expecting either 'end' or
|
|
6582
6395
|
// 'error'
|
|
6583
|
-
|
|
6584
6396
|
if (data !== null) {
|
|
6585
6397
|
iter[kLastPromise] = null;
|
|
6586
6398
|
iter[kLastResolve] = null;
|
|
@@ -6589,173 +6401,159 @@ function readAndResolve(iter) {
|
|
|
6589
6401
|
}
|
|
6590
6402
|
}
|
|
6591
6403
|
}
|
|
6592
|
-
|
|
6593
6404
|
function onReadable(iter) {
|
|
6594
6405
|
// we wait for the next tick, because it might
|
|
6595
6406
|
// emit an error with process.nextTick
|
|
6596
6407
|
process.nextTick(readAndResolve, iter);
|
|
6597
6408
|
}
|
|
6598
|
-
|
|
6599
6409
|
function wrapForNext(lastPromise, iter) {
|
|
6600
|
-
return
|
|
6601
|
-
lastPromise.then(
|
|
6410
|
+
return (resolve, reject) => {
|
|
6411
|
+
lastPromise.then(() => {
|
|
6602
6412
|
if (iter[kEnded]) {
|
|
6603
6413
|
resolve(createIterResult(undefined, true));
|
|
6604
6414
|
return;
|
|
6605
6415
|
}
|
|
6606
|
-
|
|
6607
6416
|
iter[kHandlePromise](resolve, reject);
|
|
6608
6417
|
}, reject);
|
|
6609
6418
|
};
|
|
6610
6419
|
}
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {
|
|
6420
|
+
const AsyncIteratorPrototype = Object.getPrototypeOf(function () {});
|
|
6421
|
+
const ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf({
|
|
6614
6422
|
get stream() {
|
|
6615
6423
|
return this[kStream];
|
|
6616
6424
|
},
|
|
6617
|
-
|
|
6618
|
-
next: function next() {
|
|
6619
|
-
var _this = this;
|
|
6620
|
-
|
|
6425
|
+
next() {
|
|
6621
6426
|
// if we have detected an error in the meanwhile
|
|
6622
6427
|
// reject straight away
|
|
6623
|
-
|
|
6624
|
-
|
|
6428
|
+
const error = this[kError];
|
|
6625
6429
|
if (error !== null) {
|
|
6626
6430
|
return Promise.reject(error);
|
|
6627
6431
|
}
|
|
6628
|
-
|
|
6629
6432
|
if (this[kEnded]) {
|
|
6630
6433
|
return Promise.resolve(createIterResult(undefined, true));
|
|
6631
6434
|
}
|
|
6632
|
-
|
|
6633
6435
|
if (this[kStream].destroyed) {
|
|
6634
6436
|
// We need to defer via nextTick because if .destroy(err) is
|
|
6635
6437
|
// called, the error will be emitted via nextTick, and
|
|
6636
6438
|
// we cannot guarantee that there is no error lingering around
|
|
6637
6439
|
// waiting to be emitted.
|
|
6638
|
-
return new Promise(
|
|
6639
|
-
process.nextTick(
|
|
6640
|
-
if (
|
|
6641
|
-
reject(
|
|
6440
|
+
return new Promise((resolve, reject) => {
|
|
6441
|
+
process.nextTick(() => {
|
|
6442
|
+
if (this[kError]) {
|
|
6443
|
+
reject(this[kError]);
|
|
6642
6444
|
} else {
|
|
6643
6445
|
resolve(createIterResult(undefined, true));
|
|
6644
6446
|
}
|
|
6645
6447
|
});
|
|
6646
6448
|
});
|
|
6647
|
-
}
|
|
6449
|
+
}
|
|
6450
|
+
|
|
6451
|
+
// if we have multiple next() calls
|
|
6648
6452
|
// we will wait for the previous Promise to finish
|
|
6649
6453
|
// this logic is optimized to support for await loops,
|
|
6650
6454
|
// where next() is only called once at a time
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
var lastPromise = this[kLastPromise];
|
|
6654
|
-
var promise;
|
|
6655
|
-
|
|
6455
|
+
const lastPromise = this[kLastPromise];
|
|
6456
|
+
let promise;
|
|
6656
6457
|
if (lastPromise) {
|
|
6657
6458
|
promise = new Promise(wrapForNext(lastPromise, this));
|
|
6658
6459
|
} else {
|
|
6659
6460
|
// fast path needed to support multiple this.push()
|
|
6660
6461
|
// without triggering the next() queue
|
|
6661
|
-
|
|
6662
|
-
|
|
6462
|
+
const data = this[kStream].read();
|
|
6663
6463
|
if (data !== null) {
|
|
6664
6464
|
return Promise.resolve(createIterResult(data, false));
|
|
6665
6465
|
}
|
|
6666
|
-
|
|
6667
6466
|
promise = new Promise(this[kHandlePromise]);
|
|
6668
6467
|
}
|
|
6669
|
-
|
|
6670
6468
|
this[kLastPromise] = promise;
|
|
6671
6469
|
return promise;
|
|
6672
|
-
}
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
}
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
resolve(createIterResult(undefined, true));
|
|
6470
|
+
},
|
|
6471
|
+
[Symbol.asyncIterator]() {
|
|
6472
|
+
return this;
|
|
6473
|
+
},
|
|
6474
|
+
return() {
|
|
6475
|
+
// destroy(err, cb) is a private API
|
|
6476
|
+
// we can guarantee we have that here, because we control the
|
|
6477
|
+
// Readable class this is attached to
|
|
6478
|
+
return new Promise((resolve, reject) => {
|
|
6479
|
+
this[kStream].destroy(null, err => {
|
|
6480
|
+
if (err) {
|
|
6481
|
+
reject(err);
|
|
6482
|
+
return;
|
|
6483
|
+
}
|
|
6484
|
+
resolve(createIterResult(undefined, true));
|
|
6485
|
+
});
|
|
6689
6486
|
});
|
|
6690
|
-
}
|
|
6691
|
-
}
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
writable: true
|
|
6702
|
-
}), _defineProperty(_Object$create, kLastReject, {
|
|
6703
|
-
value: null,
|
|
6704
|
-
writable: true
|
|
6705
|
-
}), _defineProperty(_Object$create, kError, {
|
|
6706
|
-
value: null,
|
|
6707
|
-
writable: true
|
|
6708
|
-
}), _defineProperty(_Object$create, kEnded, {
|
|
6709
|
-
value: stream._readableState.endEmitted,
|
|
6710
|
-
writable: true
|
|
6711
|
-
}), _defineProperty(_Object$create, kHandlePromise, {
|
|
6712
|
-
value: function value(resolve, reject) {
|
|
6713
|
-
var data = iterator[kStream].read();
|
|
6714
|
-
|
|
6715
|
-
if (data) {
|
|
6716
|
-
iterator[kLastPromise] = null;
|
|
6717
|
-
iterator[kLastResolve] = null;
|
|
6718
|
-
iterator[kLastReject] = null;
|
|
6719
|
-
resolve(createIterResult(data, false));
|
|
6720
|
-
} else {
|
|
6721
|
-
iterator[kLastResolve] = resolve;
|
|
6722
|
-
iterator[kLastReject] = reject;
|
|
6723
|
-
}
|
|
6487
|
+
}
|
|
6488
|
+
}, AsyncIteratorPrototype);
|
|
6489
|
+
const createReadableStreamAsyncIterator = stream => {
|
|
6490
|
+
const iterator = Object.create(ReadableStreamAsyncIteratorPrototype, {
|
|
6491
|
+
[kStream]: {
|
|
6492
|
+
value: stream,
|
|
6493
|
+
writable: true
|
|
6494
|
+
},
|
|
6495
|
+
[kLastResolve]: {
|
|
6496
|
+
value: null,
|
|
6497
|
+
writable: true
|
|
6724
6498
|
},
|
|
6725
|
-
|
|
6726
|
-
|
|
6499
|
+
[kLastReject]: {
|
|
6500
|
+
value: null,
|
|
6501
|
+
writable: true
|
|
6502
|
+
},
|
|
6503
|
+
[kError]: {
|
|
6504
|
+
value: null,
|
|
6505
|
+
writable: true
|
|
6506
|
+
},
|
|
6507
|
+
[kEnded]: {
|
|
6508
|
+
value: stream._readableState.endEmitted,
|
|
6509
|
+
writable: true
|
|
6510
|
+
},
|
|
6511
|
+
// the function passed to new Promise
|
|
6512
|
+
// is cached so we avoid allocating a new
|
|
6513
|
+
// closure at every run
|
|
6514
|
+
[kHandlePromise]: {
|
|
6515
|
+
value: (resolve, reject) => {
|
|
6516
|
+
const data = iterator[kStream].read();
|
|
6517
|
+
if (data) {
|
|
6518
|
+
iterator[kLastPromise] = null;
|
|
6519
|
+
iterator[kLastResolve] = null;
|
|
6520
|
+
iterator[kLastReject] = null;
|
|
6521
|
+
resolve(createIterResult(data, false));
|
|
6522
|
+
} else {
|
|
6523
|
+
iterator[kLastResolve] = resolve;
|
|
6524
|
+
iterator[kLastReject] = reject;
|
|
6525
|
+
}
|
|
6526
|
+
},
|
|
6527
|
+
writable: true
|
|
6528
|
+
}
|
|
6529
|
+
});
|
|
6727
6530
|
iterator[kLastPromise] = null;
|
|
6728
|
-
finished(stream,
|
|
6531
|
+
finished(stream, err => {
|
|
6729
6532
|
if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
|
|
6730
|
-
|
|
6533
|
+
const reject = iterator[kLastReject];
|
|
6534
|
+
// reject if we are waiting for data in the Promise
|
|
6731
6535
|
// returned by next() and store the error
|
|
6732
|
-
|
|
6733
6536
|
if (reject !== null) {
|
|
6734
6537
|
iterator[kLastPromise] = null;
|
|
6735
6538
|
iterator[kLastResolve] = null;
|
|
6736
6539
|
iterator[kLastReject] = null;
|
|
6737
6540
|
reject(err);
|
|
6738
6541
|
}
|
|
6739
|
-
|
|
6740
6542
|
iterator[kError] = err;
|
|
6741
6543
|
return;
|
|
6742
6544
|
}
|
|
6743
|
-
|
|
6744
|
-
var resolve = iterator[kLastResolve];
|
|
6745
|
-
|
|
6545
|
+
const resolve = iterator[kLastResolve];
|
|
6746
6546
|
if (resolve !== null) {
|
|
6747
6547
|
iterator[kLastPromise] = null;
|
|
6748
6548
|
iterator[kLastResolve] = null;
|
|
6749
6549
|
iterator[kLastReject] = null;
|
|
6750
6550
|
resolve(createIterResult(undefined, true));
|
|
6751
6551
|
}
|
|
6752
|
-
|
|
6753
6552
|
iterator[kEnded] = true;
|
|
6754
6553
|
});
|
|
6755
6554
|
stream.on('readable', onReadable.bind(null, iterator));
|
|
6756
6555
|
return iterator;
|
|
6757
6556
|
};
|
|
6758
|
-
|
|
6759
6557
|
module.exports = createReadableStreamAsyncIterator;
|
|
6760
6558
|
|
|
6761
6559
|
/***/ }),
|
|
@@ -6766,214 +6564,159 @@ module.exports = createReadableStreamAsyncIterator;
|
|
|
6766
6564
|
"use strict";
|
|
6767
6565
|
|
|
6768
6566
|
|
|
6769
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
6770
|
-
|
|
6771
|
-
function
|
|
6772
|
-
|
|
6773
|
-
function
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
6780
|
-
|
|
6781
|
-
var _require = __webpack_require__(60871),
|
|
6782
|
-
Buffer = _require.Buffer;
|
|
6783
|
-
|
|
6784
|
-
var _require2 = __webpack_require__(73837),
|
|
6785
|
-
inspect = _require2.inspect;
|
|
6786
|
-
|
|
6787
|
-
var custom = inspect && inspect.custom || 'inspect';
|
|
6788
|
-
|
|
6567
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6568
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6569
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6570
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
6571
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
6572
|
+
const _require = __webpack_require__(60871),
|
|
6573
|
+
Buffer = _require.Buffer;
|
|
6574
|
+
const _require2 = __webpack_require__(73837),
|
|
6575
|
+
inspect = _require2.inspect;
|
|
6576
|
+
const custom = inspect && inspect.custom || 'inspect';
|
|
6789
6577
|
function copyBuffer(src, target, offset) {
|
|
6790
6578
|
Buffer.prototype.copy.call(src, target, offset);
|
|
6791
6579
|
}
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
/*#__PURE__*/
|
|
6795
|
-
function () {
|
|
6796
|
-
function BufferList() {
|
|
6797
|
-
_classCallCheck(this, BufferList);
|
|
6798
|
-
|
|
6580
|
+
module.exports = class BufferList {
|
|
6581
|
+
constructor() {
|
|
6799
6582
|
this.head = null;
|
|
6800
6583
|
this.tail = null;
|
|
6801
6584
|
this.length = 0;
|
|
6802
6585
|
}
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
}, {
|
|
6891
|
-
key: "first",
|
|
6892
|
-
value: function first() {
|
|
6893
|
-
return this.head.data;
|
|
6894
|
-
} // Consumes a specified amount of characters from the buffered data.
|
|
6895
|
-
|
|
6896
|
-
}, {
|
|
6897
|
-
key: "_getString",
|
|
6898
|
-
value: function _getString(n) {
|
|
6899
|
-
var p = this.head;
|
|
6900
|
-
var c = 1;
|
|
6901
|
-
var ret = p.data;
|
|
6902
|
-
n -= ret.length;
|
|
6903
|
-
|
|
6904
|
-
while (p = p.next) {
|
|
6905
|
-
var str = p.data;
|
|
6906
|
-
var nb = n > str.length ? str.length : n;
|
|
6907
|
-
if (nb === str.length) ret += str;else ret += str.slice(0, n);
|
|
6908
|
-
n -= nb;
|
|
6909
|
-
|
|
6910
|
-
if (n === 0) {
|
|
6911
|
-
if (nb === str.length) {
|
|
6912
|
-
++c;
|
|
6913
|
-
if (p.next) this.head = p.next;else this.head = this.tail = null;
|
|
6914
|
-
} else {
|
|
6915
|
-
this.head = p;
|
|
6916
|
-
p.data = str.slice(nb);
|
|
6917
|
-
}
|
|
6918
|
-
|
|
6919
|
-
break;
|
|
6586
|
+
push(v) {
|
|
6587
|
+
const entry = {
|
|
6588
|
+
data: v,
|
|
6589
|
+
next: null
|
|
6590
|
+
};
|
|
6591
|
+
if (this.length > 0) this.tail.next = entry;else this.head = entry;
|
|
6592
|
+
this.tail = entry;
|
|
6593
|
+
++this.length;
|
|
6594
|
+
}
|
|
6595
|
+
unshift(v) {
|
|
6596
|
+
const entry = {
|
|
6597
|
+
data: v,
|
|
6598
|
+
next: this.head
|
|
6599
|
+
};
|
|
6600
|
+
if (this.length === 0) this.tail = entry;
|
|
6601
|
+
this.head = entry;
|
|
6602
|
+
++this.length;
|
|
6603
|
+
}
|
|
6604
|
+
shift() {
|
|
6605
|
+
if (this.length === 0) return;
|
|
6606
|
+
const ret = this.head.data;
|
|
6607
|
+
if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
|
|
6608
|
+
--this.length;
|
|
6609
|
+
return ret;
|
|
6610
|
+
}
|
|
6611
|
+
clear() {
|
|
6612
|
+
this.head = this.tail = null;
|
|
6613
|
+
this.length = 0;
|
|
6614
|
+
}
|
|
6615
|
+
join(s) {
|
|
6616
|
+
if (this.length === 0) return '';
|
|
6617
|
+
var p = this.head;
|
|
6618
|
+
var ret = '' + p.data;
|
|
6619
|
+
while (p = p.next) ret += s + p.data;
|
|
6620
|
+
return ret;
|
|
6621
|
+
}
|
|
6622
|
+
concat(n) {
|
|
6623
|
+
if (this.length === 0) return Buffer.alloc(0);
|
|
6624
|
+
const ret = Buffer.allocUnsafe(n >>> 0);
|
|
6625
|
+
var p = this.head;
|
|
6626
|
+
var i = 0;
|
|
6627
|
+
while (p) {
|
|
6628
|
+
copyBuffer(p.data, ret, i);
|
|
6629
|
+
i += p.data.length;
|
|
6630
|
+
p = p.next;
|
|
6631
|
+
}
|
|
6632
|
+
return ret;
|
|
6633
|
+
}
|
|
6634
|
+
|
|
6635
|
+
// Consumes a specified amount of bytes or characters from the buffered data.
|
|
6636
|
+
consume(n, hasStrings) {
|
|
6637
|
+
var ret;
|
|
6638
|
+
if (n < this.head.data.length) {
|
|
6639
|
+
// `slice` is the same for buffers and strings.
|
|
6640
|
+
ret = this.head.data.slice(0, n);
|
|
6641
|
+
this.head.data = this.head.data.slice(n);
|
|
6642
|
+
} else if (n === this.head.data.length) {
|
|
6643
|
+
// First chunk is a perfect match.
|
|
6644
|
+
ret = this.shift();
|
|
6645
|
+
} else {
|
|
6646
|
+
// Result spans more than one buffer.
|
|
6647
|
+
ret = hasStrings ? this._getString(n) : this._getBuffer(n);
|
|
6648
|
+
}
|
|
6649
|
+
return ret;
|
|
6650
|
+
}
|
|
6651
|
+
first() {
|
|
6652
|
+
return this.head.data;
|
|
6653
|
+
}
|
|
6654
|
+
|
|
6655
|
+
// Consumes a specified amount of characters from the buffered data.
|
|
6656
|
+
_getString(n) {
|
|
6657
|
+
var p = this.head;
|
|
6658
|
+
var c = 1;
|
|
6659
|
+
var ret = p.data;
|
|
6660
|
+
n -= ret.length;
|
|
6661
|
+
while (p = p.next) {
|
|
6662
|
+
const str = p.data;
|
|
6663
|
+
const nb = n > str.length ? str.length : n;
|
|
6664
|
+
if (nb === str.length) ret += str;else ret += str.slice(0, n);
|
|
6665
|
+
n -= nb;
|
|
6666
|
+
if (n === 0) {
|
|
6667
|
+
if (nb === str.length) {
|
|
6668
|
+
++c;
|
|
6669
|
+
if (p.next) this.head = p.next;else this.head = this.tail = null;
|
|
6670
|
+
} else {
|
|
6671
|
+
this.head = p;
|
|
6672
|
+
p.data = str.slice(nb);
|
|
6920
6673
|
}
|
|
6921
|
-
|
|
6922
|
-
++c;
|
|
6674
|
+
break;
|
|
6923
6675
|
}
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
if (
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
this.head = p;
|
|
6950
|
-
p.data = buf.slice(nb);
|
|
6951
|
-
}
|
|
6952
|
-
|
|
6953
|
-
break;
|
|
6676
|
+
++c;
|
|
6677
|
+
}
|
|
6678
|
+
this.length -= c;
|
|
6679
|
+
return ret;
|
|
6680
|
+
}
|
|
6681
|
+
|
|
6682
|
+
// Consumes a specified amount of bytes from the buffered data.
|
|
6683
|
+
_getBuffer(n) {
|
|
6684
|
+
const ret = Buffer.allocUnsafe(n);
|
|
6685
|
+
var p = this.head;
|
|
6686
|
+
var c = 1;
|
|
6687
|
+
p.data.copy(ret);
|
|
6688
|
+
n -= p.data.length;
|
|
6689
|
+
while (p = p.next) {
|
|
6690
|
+
const buf = p.data;
|
|
6691
|
+
const nb = n > buf.length ? buf.length : n;
|
|
6692
|
+
buf.copy(ret, ret.length - n, 0, nb);
|
|
6693
|
+
n -= nb;
|
|
6694
|
+
if (n === 0) {
|
|
6695
|
+
if (nb === buf.length) {
|
|
6696
|
+
++c;
|
|
6697
|
+
if (p.next) this.head = p.next;else this.head = this.tail = null;
|
|
6698
|
+
} else {
|
|
6699
|
+
this.head = p;
|
|
6700
|
+
p.data = buf.slice(nb);
|
|
6954
6701
|
}
|
|
6955
|
-
|
|
6956
|
-
++c;
|
|
6702
|
+
break;
|
|
6957
6703
|
}
|
|
6958
|
-
|
|
6959
|
-
this.length -= c;
|
|
6960
|
-
return ret;
|
|
6961
|
-
} // Make sure the linked list only shows the minimal necessary information.
|
|
6962
|
-
|
|
6963
|
-
}, {
|
|
6964
|
-
key: custom,
|
|
6965
|
-
value: function value(_, options) {
|
|
6966
|
-
return inspect(this, _objectSpread({}, options, {
|
|
6967
|
-
// Only inspect one level.
|
|
6968
|
-
depth: 0,
|
|
6969
|
-
// It should not recurse.
|
|
6970
|
-
customInspect: false
|
|
6971
|
-
}));
|
|
6704
|
+
++c;
|
|
6972
6705
|
}
|
|
6973
|
-
|
|
6706
|
+
this.length -= c;
|
|
6707
|
+
return ret;
|
|
6708
|
+
}
|
|
6974
6709
|
|
|
6975
|
-
|
|
6976
|
-
|
|
6710
|
+
// Make sure the linked list only shows the minimal necessary information.
|
|
6711
|
+
[custom](_, options) {
|
|
6712
|
+
return inspect(this, _objectSpread(_objectSpread({}, options), {}, {
|
|
6713
|
+
// Only inspect one level.
|
|
6714
|
+
depth: 0,
|
|
6715
|
+
// It should not recurse.
|
|
6716
|
+
customInspect: false
|
|
6717
|
+
}));
|
|
6718
|
+
}
|
|
6719
|
+
};
|
|
6977
6720
|
|
|
6978
6721
|
/***/ }),
|
|
6979
6722
|
|
|
@@ -6981,14 +6724,12 @@ function () {
|
|
|
6981
6724
|
/***/ ((module) => {
|
|
6982
6725
|
|
|
6983
6726
|
"use strict";
|
|
6984
|
-
// undocumented cb() API, needed for core, not for public API
|
|
6985
6727
|
|
|
6986
|
-
function destroy(err, cb) {
|
|
6987
|
-
var _this = this;
|
|
6988
|
-
|
|
6989
|
-
var readableDestroyed = this._readableState && this._readableState.destroyed;
|
|
6990
|
-
var writableDestroyed = this._writableState && this._writableState.destroyed;
|
|
6991
6728
|
|
|
6729
|
+
// undocumented cb() API, needed for core, not for public API
|
|
6730
|
+
function destroy(err, cb) {
|
|
6731
|
+
const readableDestroyed = this._readableState && this._readableState.destroyed;
|
|
6732
|
+
const writableDestroyed = this._writableState && this._writableState.destroyed;
|
|
6992
6733
|
if (readableDestroyed || writableDestroyed) {
|
|
6993
6734
|
if (cb) {
|
|
6994
6735
|
cb(err);
|
|
@@ -7000,53 +6741,48 @@ function destroy(err, cb) {
|
|
|
7000
6741
|
process.nextTick(emitErrorNT, this, err);
|
|
7001
6742
|
}
|
|
7002
6743
|
}
|
|
7003
|
-
|
|
7004
6744
|
return this;
|
|
7005
|
-
}
|
|
7006
|
-
// to make it re-entrance safe in case destroy() is called within callbacks
|
|
6745
|
+
}
|
|
7007
6746
|
|
|
6747
|
+
// we set destroyed to true before firing error callbacks in order
|
|
6748
|
+
// to make it re-entrance safe in case destroy() is called within callbacks
|
|
7008
6749
|
|
|
7009
6750
|
if (this._readableState) {
|
|
7010
6751
|
this._readableState.destroyed = true;
|
|
7011
|
-
}
|
|
7012
|
-
|
|
6752
|
+
}
|
|
7013
6753
|
|
|
6754
|
+
// if this is a duplex stream mark the writable part as destroyed as well
|
|
7014
6755
|
if (this._writableState) {
|
|
7015
6756
|
this._writableState.destroyed = true;
|
|
7016
6757
|
}
|
|
7017
|
-
|
|
7018
|
-
this._destroy(err || null, function (err) {
|
|
6758
|
+
this._destroy(err || null, err => {
|
|
7019
6759
|
if (!cb && err) {
|
|
7020
|
-
if (!
|
|
7021
|
-
process.nextTick(emitErrorAndCloseNT,
|
|
7022
|
-
} else if (!
|
|
7023
|
-
|
|
7024
|
-
process.nextTick(emitErrorAndCloseNT,
|
|
6760
|
+
if (!this._writableState) {
|
|
6761
|
+
process.nextTick(emitErrorAndCloseNT, this, err);
|
|
6762
|
+
} else if (!this._writableState.errorEmitted) {
|
|
6763
|
+
this._writableState.errorEmitted = true;
|
|
6764
|
+
process.nextTick(emitErrorAndCloseNT, this, err);
|
|
7025
6765
|
} else {
|
|
7026
|
-
process.nextTick(emitCloseNT,
|
|
6766
|
+
process.nextTick(emitCloseNT, this);
|
|
7027
6767
|
}
|
|
7028
6768
|
} else if (cb) {
|
|
7029
|
-
process.nextTick(emitCloseNT,
|
|
6769
|
+
process.nextTick(emitCloseNT, this);
|
|
7030
6770
|
cb(err);
|
|
7031
6771
|
} else {
|
|
7032
|
-
process.nextTick(emitCloseNT,
|
|
6772
|
+
process.nextTick(emitCloseNT, this);
|
|
7033
6773
|
}
|
|
7034
6774
|
});
|
|
7035
|
-
|
|
7036
6775
|
return this;
|
|
7037
6776
|
}
|
|
7038
|
-
|
|
7039
6777
|
function emitErrorAndCloseNT(self, err) {
|
|
7040
6778
|
emitErrorNT(self, err);
|
|
7041
6779
|
emitCloseNT(self);
|
|
7042
6780
|
}
|
|
7043
|
-
|
|
7044
6781
|
function emitCloseNT(self) {
|
|
7045
6782
|
if (self._writableState && !self._writableState.emitClose) return;
|
|
7046
6783
|
if (self._readableState && !self._readableState.emitClose) return;
|
|
7047
6784
|
self.emit('close');
|
|
7048
6785
|
}
|
|
7049
|
-
|
|
7050
6786
|
function undestroy() {
|
|
7051
6787
|
if (this._readableState) {
|
|
7052
6788
|
this._readableState.destroyed = false;
|
|
@@ -7054,7 +6790,6 @@ function undestroy() {
|
|
|
7054
6790
|
this._readableState.ended = false;
|
|
7055
6791
|
this._readableState.endEmitted = false;
|
|
7056
6792
|
}
|
|
7057
|
-
|
|
7058
6793
|
if (this._writableState) {
|
|
7059
6794
|
this._writableState.destroyed = false;
|
|
7060
6795
|
this._writableState.ended = false;
|
|
@@ -7065,26 +6800,24 @@ function undestroy() {
|
|
|
7065
6800
|
this._writableState.errorEmitted = false;
|
|
7066
6801
|
}
|
|
7067
6802
|
}
|
|
7068
|
-
|
|
7069
6803
|
function emitErrorNT(self, err) {
|
|
7070
6804
|
self.emit('error', err);
|
|
7071
6805
|
}
|
|
7072
|
-
|
|
7073
6806
|
function errorOrDestroy(stream, err) {
|
|
7074
6807
|
// We have tests that rely on errors being emitted
|
|
7075
6808
|
// in the same tick, so changing this is semver major.
|
|
7076
6809
|
// For now when you opt-in to autoDestroy we allow
|
|
7077
6810
|
// the error to be emitted nextTick. In a future
|
|
7078
6811
|
// semver major update we should change the default to this.
|
|
7079
|
-
|
|
7080
|
-
|
|
6812
|
+
|
|
6813
|
+
const rState = stream._readableState;
|
|
6814
|
+
const wState = stream._writableState;
|
|
7081
6815
|
if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
|
|
7082
6816
|
}
|
|
7083
|
-
|
|
7084
6817
|
module.exports = {
|
|
7085
|
-
destroy
|
|
7086
|
-
undestroy
|
|
7087
|
-
errorOrDestroy
|
|
6818
|
+
destroy,
|
|
6819
|
+
undestroy,
|
|
6820
|
+
errorOrDestroy
|
|
7088
6821
|
};
|
|
7089
6822
|
|
|
7090
6823
|
/***/ }),
|
|
@@ -7097,77 +6830,61 @@ module.exports = {
|
|
|
7097
6830
|
// permission from the author, Mathias Buus (@mafintosh).
|
|
7098
6831
|
|
|
7099
6832
|
|
|
7100
|
-
var ERR_STREAM_PREMATURE_CLOSE = (__webpack_require__(18128)/* .codes.ERR_STREAM_PREMATURE_CLOSE */ .q.ERR_STREAM_PREMATURE_CLOSE);
|
|
7101
6833
|
|
|
6834
|
+
const ERR_STREAM_PREMATURE_CLOSE = (__webpack_require__(18128)/* .codes.ERR_STREAM_PREMATURE_CLOSE */ .q.ERR_STREAM_PREMATURE_CLOSE);
|
|
7102
6835
|
function once(callback) {
|
|
7103
|
-
|
|
6836
|
+
let called = false;
|
|
7104
6837
|
return function () {
|
|
7105
6838
|
if (called) return;
|
|
7106
6839
|
called = true;
|
|
7107
|
-
|
|
7108
6840
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
7109
6841
|
args[_key] = arguments[_key];
|
|
7110
6842
|
}
|
|
7111
|
-
|
|
7112
6843
|
callback.apply(this, args);
|
|
7113
6844
|
};
|
|
7114
6845
|
}
|
|
7115
|
-
|
|
7116
6846
|
function noop() {}
|
|
7117
|
-
|
|
7118
6847
|
function isRequest(stream) {
|
|
7119
6848
|
return stream.setHeader && typeof stream.abort === 'function';
|
|
7120
6849
|
}
|
|
7121
|
-
|
|
7122
6850
|
function eos(stream, opts, callback) {
|
|
7123
6851
|
if (typeof opts === 'function') return eos(stream, null, opts);
|
|
7124
6852
|
if (!opts) opts = {};
|
|
7125
6853
|
callback = once(callback || noop);
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
var onlegacyfinish = function onlegacyfinish() {
|
|
6854
|
+
let readable = opts.readable || opts.readable !== false && stream.readable;
|
|
6855
|
+
let writable = opts.writable || opts.writable !== false && stream.writable;
|
|
6856
|
+
const onlegacyfinish = () => {
|
|
7130
6857
|
if (!stream.writable) onfinish();
|
|
7131
6858
|
};
|
|
7132
|
-
|
|
7133
6859
|
var writableEnded = stream._writableState && stream._writableState.finished;
|
|
7134
|
-
|
|
7135
|
-
var onfinish = function onfinish() {
|
|
6860
|
+
const onfinish = () => {
|
|
7136
6861
|
writable = false;
|
|
7137
6862
|
writableEnded = true;
|
|
7138
6863
|
if (!readable) callback.call(stream);
|
|
7139
6864
|
};
|
|
7140
|
-
|
|
7141
6865
|
var readableEnded = stream._readableState && stream._readableState.endEmitted;
|
|
7142
|
-
|
|
7143
|
-
var onend = function onend() {
|
|
6866
|
+
const onend = () => {
|
|
7144
6867
|
readable = false;
|
|
7145
6868
|
readableEnded = true;
|
|
7146
6869
|
if (!writable) callback.call(stream);
|
|
7147
6870
|
};
|
|
7148
|
-
|
|
7149
|
-
var onerror = function onerror(err) {
|
|
6871
|
+
const onerror = err => {
|
|
7150
6872
|
callback.call(stream, err);
|
|
7151
6873
|
};
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
var err;
|
|
7155
|
-
|
|
6874
|
+
const onclose = () => {
|
|
6875
|
+
let err;
|
|
7156
6876
|
if (readable && !readableEnded) {
|
|
7157
6877
|
if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
|
|
7158
6878
|
return callback.call(stream, err);
|
|
7159
6879
|
}
|
|
7160
|
-
|
|
7161
6880
|
if (writable && !writableEnded) {
|
|
7162
6881
|
if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
|
|
7163
6882
|
return callback.call(stream, err);
|
|
7164
6883
|
}
|
|
7165
6884
|
};
|
|
7166
|
-
|
|
7167
|
-
var onrequest = function onrequest() {
|
|
6885
|
+
const onrequest = () => {
|
|
7168
6886
|
stream.req.on('finish', onfinish);
|
|
7169
6887
|
};
|
|
7170
|
-
|
|
7171
6888
|
if (isRequest(stream)) {
|
|
7172
6889
|
stream.on('complete', onfinish);
|
|
7173
6890
|
stream.on('abort', onclose);
|
|
@@ -7177,7 +6894,6 @@ function eos(stream, opts, callback) {
|
|
|
7177
6894
|
stream.on('end', onlegacyfinish);
|
|
7178
6895
|
stream.on('close', onlegacyfinish);
|
|
7179
6896
|
}
|
|
7180
|
-
|
|
7181
6897
|
stream.on('end', onend);
|
|
7182
6898
|
stream.on('finish', onfinish);
|
|
7183
6899
|
if (opts.error !== false) stream.on('error', onerror);
|
|
@@ -7195,7 +6911,6 @@ function eos(stream, opts, callback) {
|
|
|
7195
6911
|
stream.removeListener('close', onclose);
|
|
7196
6912
|
};
|
|
7197
6913
|
}
|
|
7198
|
-
|
|
7199
6914
|
module.exports = eos;
|
|
7200
6915
|
|
|
7201
6916
|
/***/ }),
|
|
@@ -7207,52 +6922,42 @@ module.exports = eos;
|
|
|
7207
6922
|
|
|
7208
6923
|
|
|
7209
6924
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
7210
|
-
|
|
7211
6925
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
7212
|
-
|
|
7213
|
-
function
|
|
7214
|
-
|
|
7215
|
-
function
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
var ERR_INVALID_ARG_TYPE = (__webpack_require__(18128)/* .codes.ERR_INVALID_ARG_TYPE */ .q.ERR_INVALID_ARG_TYPE);
|
|
7220
|
-
|
|
6926
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6927
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6928
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6929
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
6930
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
6931
|
+
const ERR_INVALID_ARG_TYPE = (__webpack_require__(18128)/* .codes.ERR_INVALID_ARG_TYPE */ .q.ERR_INVALID_ARG_TYPE);
|
|
7221
6932
|
function from(Readable, iterable, opts) {
|
|
7222
|
-
|
|
7223
|
-
|
|
6933
|
+
let iterator;
|
|
7224
6934
|
if (iterable && typeof iterable.next === 'function') {
|
|
7225
6935
|
iterator = iterable;
|
|
7226
6936
|
} else if (iterable && iterable[Symbol.asyncIterator]) iterator = iterable[Symbol.asyncIterator]();else if (iterable && iterable[Symbol.iterator]) iterator = iterable[Symbol.iterator]();else throw new ERR_INVALID_ARG_TYPE('iterable', ['Iterable'], iterable);
|
|
7227
|
-
|
|
7228
|
-
var readable = new Readable(_objectSpread({
|
|
6937
|
+
const readable = new Readable(_objectSpread({
|
|
7229
6938
|
objectMode: true
|
|
7230
|
-
}, opts));
|
|
6939
|
+
}, opts));
|
|
6940
|
+
// Reading boolean to protect against _read
|
|
7231
6941
|
// being called before last iteration completion.
|
|
7232
|
-
|
|
7233
|
-
var reading = false;
|
|
7234
|
-
|
|
6942
|
+
let reading = false;
|
|
7235
6943
|
readable._read = function () {
|
|
7236
6944
|
if (!reading) {
|
|
7237
6945
|
reading = true;
|
|
7238
6946
|
next();
|
|
7239
6947
|
}
|
|
7240
6948
|
};
|
|
7241
|
-
|
|
7242
6949
|
function next() {
|
|
7243
6950
|
return _next2.apply(this, arguments);
|
|
7244
6951
|
}
|
|
7245
|
-
|
|
7246
6952
|
function _next2() {
|
|
7247
6953
|
_next2 = _asyncToGenerator(function* () {
|
|
7248
6954
|
try {
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
|
|
6955
|
+
const _yield$iterator$next = yield iterator.next(),
|
|
6956
|
+
value = _yield$iterator$next.value,
|
|
6957
|
+
done = _yield$iterator$next.done;
|
|
7253
6958
|
if (done) {
|
|
7254
6959
|
readable.push(null);
|
|
7255
|
-
} else if (readable.push(
|
|
6960
|
+
} else if (readable.push(yield value)) {
|
|
7256
6961
|
next();
|
|
7257
6962
|
} else {
|
|
7258
6963
|
reading = false;
|
|
@@ -7263,10 +6968,8 @@ function from(Readable, iterable, opts) {
|
|
|
7263
6968
|
});
|
|
7264
6969
|
return _next2.apply(this, arguments);
|
|
7265
6970
|
}
|
|
7266
|
-
|
|
7267
6971
|
return readable;
|
|
7268
6972
|
}
|
|
7269
|
-
|
|
7270
6973
|
module.exports = from;
|
|
7271
6974
|
|
|
7272
6975
|
/***/ }),
|
|
@@ -7279,87 +6982,77 @@ module.exports = from;
|
|
|
7279
6982
|
// permission from the author, Mathias Buus (@mafintosh).
|
|
7280
6983
|
|
|
7281
6984
|
|
|
7282
|
-
var eos;
|
|
7283
6985
|
|
|
6986
|
+
let eos;
|
|
7284
6987
|
function once(callback) {
|
|
7285
|
-
|
|
6988
|
+
let called = false;
|
|
7286
6989
|
return function () {
|
|
7287
6990
|
if (called) return;
|
|
7288
6991
|
called = true;
|
|
7289
|
-
callback
|
|
6992
|
+
callback(...arguments);
|
|
7290
6993
|
};
|
|
7291
6994
|
}
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
|
|
7296
|
-
|
|
6995
|
+
const _require$codes = (__webpack_require__(18128)/* .codes */ .q),
|
|
6996
|
+
ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,
|
|
6997
|
+
ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
|
|
7297
6998
|
function noop(err) {
|
|
7298
6999
|
// Rethrow the error if it exists to avoid swallowing it
|
|
7299
7000
|
if (err) throw err;
|
|
7300
7001
|
}
|
|
7301
|
-
|
|
7302
7002
|
function isRequest(stream) {
|
|
7303
7003
|
return stream.setHeader && typeof stream.abort === 'function';
|
|
7304
7004
|
}
|
|
7305
|
-
|
|
7306
7005
|
function destroyer(stream, reading, writing, callback) {
|
|
7307
7006
|
callback = once(callback);
|
|
7308
|
-
|
|
7309
|
-
stream.on('close',
|
|
7007
|
+
let closed = false;
|
|
7008
|
+
stream.on('close', () => {
|
|
7310
7009
|
closed = true;
|
|
7311
7010
|
});
|
|
7312
7011
|
if (eos === undefined) eos = __webpack_require__(30685);
|
|
7313
7012
|
eos(stream, {
|
|
7314
7013
|
readable: reading,
|
|
7315
7014
|
writable: writing
|
|
7316
|
-
},
|
|
7015
|
+
}, err => {
|
|
7317
7016
|
if (err) return callback(err);
|
|
7318
7017
|
closed = true;
|
|
7319
7018
|
callback();
|
|
7320
7019
|
});
|
|
7321
|
-
|
|
7322
|
-
return
|
|
7020
|
+
let destroyed = false;
|
|
7021
|
+
return err => {
|
|
7323
7022
|
if (closed) return;
|
|
7324
7023
|
if (destroyed) return;
|
|
7325
|
-
destroyed = true;
|
|
7024
|
+
destroyed = true;
|
|
7326
7025
|
|
|
7026
|
+
// request.destroy just do .end - .abort is what we want
|
|
7327
7027
|
if (isRequest(stream)) return stream.abort();
|
|
7328
7028
|
if (typeof stream.destroy === 'function') return stream.destroy();
|
|
7329
7029
|
callback(err || new ERR_STREAM_DESTROYED('pipe'));
|
|
7330
7030
|
};
|
|
7331
7031
|
}
|
|
7332
|
-
|
|
7333
7032
|
function call(fn) {
|
|
7334
7033
|
fn();
|
|
7335
7034
|
}
|
|
7336
|
-
|
|
7337
7035
|
function pipe(from, to) {
|
|
7338
7036
|
return from.pipe(to);
|
|
7339
7037
|
}
|
|
7340
|
-
|
|
7341
7038
|
function popCallback(streams) {
|
|
7342
7039
|
if (!streams.length) return noop;
|
|
7343
7040
|
if (typeof streams[streams.length - 1] !== 'function') return noop;
|
|
7344
7041
|
return streams.pop();
|
|
7345
7042
|
}
|
|
7346
|
-
|
|
7347
7043
|
function pipeline() {
|
|
7348
7044
|
for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
7349
7045
|
streams[_key] = arguments[_key];
|
|
7350
7046
|
}
|
|
7351
|
-
|
|
7352
|
-
var callback = popCallback(streams);
|
|
7047
|
+
const callback = popCallback(streams);
|
|
7353
7048
|
if (Array.isArray(streams[0])) streams = streams[0];
|
|
7354
|
-
|
|
7355
7049
|
if (streams.length < 2) {
|
|
7356
7050
|
throw new ERR_MISSING_ARGS('streams');
|
|
7357
7051
|
}
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
var writing = i > 0;
|
|
7052
|
+
let error;
|
|
7053
|
+
const destroys = streams.map(function (stream, i) {
|
|
7054
|
+
const reading = i < streams.length - 1;
|
|
7055
|
+
const writing = i > 0;
|
|
7363
7056
|
return destroyer(stream, reading, writing, function (err) {
|
|
7364
7057
|
if (!error) error = err;
|
|
7365
7058
|
if (err) destroys.forEach(call);
|
|
@@ -7370,7 +7063,6 @@ function pipeline() {
|
|
|
7370
7063
|
});
|
|
7371
7064
|
return streams.reduce(pipe);
|
|
7372
7065
|
}
|
|
7373
|
-
|
|
7374
7066
|
module.exports = pipeline;
|
|
7375
7067
|
|
|
7376
7068
|
/***/ }),
|
|
@@ -7381,30 +7073,25 @@ module.exports = pipeline;
|
|
|
7381
7073
|
"use strict";
|
|
7382
7074
|
|
|
7383
7075
|
|
|
7384
|
-
|
|
7385
|
-
|
|
7076
|
+
const ERR_INVALID_OPT_VALUE = (__webpack_require__(18128)/* .codes.ERR_INVALID_OPT_VALUE */ .q.ERR_INVALID_OPT_VALUE);
|
|
7386
7077
|
function highWaterMarkFrom(options, isDuplex, duplexKey) {
|
|
7387
7078
|
return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
|
|
7388
7079
|
}
|
|
7389
|
-
|
|
7390
7080
|
function getHighWaterMark(state, options, duplexKey, isDuplex) {
|
|
7391
|
-
|
|
7392
|
-
|
|
7081
|
+
const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
|
|
7393
7082
|
if (hwm != null) {
|
|
7394
7083
|
if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
|
|
7395
|
-
|
|
7084
|
+
const name = isDuplex ? duplexKey : 'highWaterMark';
|
|
7396
7085
|
throw new ERR_INVALID_OPT_VALUE(name, hwm);
|
|
7397
7086
|
}
|
|
7398
|
-
|
|
7399
7087
|
return Math.floor(hwm);
|
|
7400
|
-
}
|
|
7401
|
-
|
|
7088
|
+
}
|
|
7402
7089
|
|
|
7090
|
+
// Default value
|
|
7403
7091
|
return state.objectMode ? 16 : 16 * 1024;
|
|
7404
7092
|
}
|
|
7405
|
-
|
|
7406
7093
|
module.exports = {
|
|
7407
|
-
getHighWaterMark
|
|
7094
|
+
getHighWaterMark
|
|
7408
7095
|
};
|
|
7409
7096
|
|
|
7410
7097
|
/***/ }),
|