@nsshunt/stsutils 1.16.43 → 1.16.45
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/dist/stsutils.mjs +0 -2836
- package/dist/stsutils.mjs.map +1 -1
- package/dist/stsutils.umd.js +3 -2836
- package/dist/stsutils.umd.js.map +1 -1
- package/package.json +2 -5
- package/types/index.d.ts +10 -1
- package/types/index.d.ts.map +1 -1
- package/types/winstonTransport.d.ts +0 -14
- package/types/winstonTransport.d.ts.map +0 -1
package/dist/stsutils.mjs
CHANGED
|
@@ -24,9 +24,6 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
24
24
|
};
|
|
25
25
|
var _options;
|
|
26
26
|
import Ajv from "ajv/dist/jtd.js";
|
|
27
|
-
import require$$0$2 from "util";
|
|
28
|
-
import require$$0 from "events";
|
|
29
|
-
import require$$0$1 from "buffer";
|
|
30
27
|
function GetErrorPayload(errorCode, details = null) {
|
|
31
28
|
return {
|
|
32
29
|
error: errorCode.code,
|
|
@@ -170,2838 +167,6 @@ function compareParameterTypes(source1, source2, authParameterTypes) {
|
|
|
170
167
|
}
|
|
171
168
|
return errors;
|
|
172
169
|
}
|
|
173
|
-
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
174
|
-
function getDefaultExportFromCjs(x) {
|
|
175
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
176
|
-
}
|
|
177
|
-
var dist = { exports: {} };
|
|
178
|
-
var browser = deprecate;
|
|
179
|
-
function deprecate(fn, msg) {
|
|
180
|
-
if (config$1("noDeprecation")) {
|
|
181
|
-
return fn;
|
|
182
|
-
}
|
|
183
|
-
var warned = false;
|
|
184
|
-
function deprecated() {
|
|
185
|
-
if (!warned) {
|
|
186
|
-
if (config$1("throwDeprecation")) {
|
|
187
|
-
throw new Error(msg);
|
|
188
|
-
} else if (config$1("traceDeprecation")) {
|
|
189
|
-
console.trace(msg);
|
|
190
|
-
} else {
|
|
191
|
-
console.warn(msg);
|
|
192
|
-
}
|
|
193
|
-
warned = true;
|
|
194
|
-
}
|
|
195
|
-
return fn.apply(this, arguments);
|
|
196
|
-
}
|
|
197
|
-
return deprecated;
|
|
198
|
-
}
|
|
199
|
-
function config$1(name) {
|
|
200
|
-
try {
|
|
201
|
-
if (!commonjsGlobal.localStorage)
|
|
202
|
-
return false;
|
|
203
|
-
} catch (_) {
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
var val = commonjsGlobal.localStorage[name];
|
|
207
|
-
if (null == val)
|
|
208
|
-
return false;
|
|
209
|
-
return String(val).toLowerCase() === "true";
|
|
210
|
-
}
|
|
211
|
-
var streamBrowser = require$$0.EventEmitter;
|
|
212
|
-
function destroy(err, cb) {
|
|
213
|
-
var _this = this;
|
|
214
|
-
var readableDestroyed = this._readableState && this._readableState.destroyed;
|
|
215
|
-
var writableDestroyed = this._writableState && this._writableState.destroyed;
|
|
216
|
-
if (readableDestroyed || writableDestroyed) {
|
|
217
|
-
if (cb) {
|
|
218
|
-
cb(err);
|
|
219
|
-
} else if (err) {
|
|
220
|
-
if (!this._writableState) {
|
|
221
|
-
process.nextTick(emitErrorNT, this, err);
|
|
222
|
-
} else if (!this._writableState.errorEmitted) {
|
|
223
|
-
this._writableState.errorEmitted = true;
|
|
224
|
-
process.nextTick(emitErrorNT, this, err);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return this;
|
|
228
|
-
}
|
|
229
|
-
if (this._readableState) {
|
|
230
|
-
this._readableState.destroyed = true;
|
|
231
|
-
}
|
|
232
|
-
if (this._writableState) {
|
|
233
|
-
this._writableState.destroyed = true;
|
|
234
|
-
}
|
|
235
|
-
this._destroy(err || null, function(err2) {
|
|
236
|
-
if (!cb && err2) {
|
|
237
|
-
if (!_this._writableState) {
|
|
238
|
-
process.nextTick(emitErrorAndCloseNT, _this, err2);
|
|
239
|
-
} else if (!_this._writableState.errorEmitted) {
|
|
240
|
-
_this._writableState.errorEmitted = true;
|
|
241
|
-
process.nextTick(emitErrorAndCloseNT, _this, err2);
|
|
242
|
-
} else {
|
|
243
|
-
process.nextTick(emitCloseNT, _this);
|
|
244
|
-
}
|
|
245
|
-
} else if (cb) {
|
|
246
|
-
process.nextTick(emitCloseNT, _this);
|
|
247
|
-
cb(err2);
|
|
248
|
-
} else {
|
|
249
|
-
process.nextTick(emitCloseNT, _this);
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
return this;
|
|
253
|
-
}
|
|
254
|
-
function emitErrorAndCloseNT(self2, err) {
|
|
255
|
-
emitErrorNT(self2, err);
|
|
256
|
-
emitCloseNT(self2);
|
|
257
|
-
}
|
|
258
|
-
function emitCloseNT(self2) {
|
|
259
|
-
if (self2._writableState && !self2._writableState.emitClose)
|
|
260
|
-
return;
|
|
261
|
-
if (self2._readableState && !self2._readableState.emitClose)
|
|
262
|
-
return;
|
|
263
|
-
self2.emit("close");
|
|
264
|
-
}
|
|
265
|
-
function undestroy() {
|
|
266
|
-
if (this._readableState) {
|
|
267
|
-
this._readableState.destroyed = false;
|
|
268
|
-
this._readableState.reading = false;
|
|
269
|
-
this._readableState.ended = false;
|
|
270
|
-
this._readableState.endEmitted = false;
|
|
271
|
-
}
|
|
272
|
-
if (this._writableState) {
|
|
273
|
-
this._writableState.destroyed = false;
|
|
274
|
-
this._writableState.ended = false;
|
|
275
|
-
this._writableState.ending = false;
|
|
276
|
-
this._writableState.finalCalled = false;
|
|
277
|
-
this._writableState.prefinished = false;
|
|
278
|
-
this._writableState.finished = false;
|
|
279
|
-
this._writableState.errorEmitted = false;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
function emitErrorNT(self2, err) {
|
|
283
|
-
self2.emit("error", err);
|
|
284
|
-
}
|
|
285
|
-
function errorOrDestroy(stream, err) {
|
|
286
|
-
var rState = stream._readableState;
|
|
287
|
-
var wState = stream._writableState;
|
|
288
|
-
if (rState && rState.autoDestroy || wState && wState.autoDestroy)
|
|
289
|
-
stream.destroy(err);
|
|
290
|
-
else
|
|
291
|
-
stream.emit("error", err);
|
|
292
|
-
}
|
|
293
|
-
var destroy_1 = {
|
|
294
|
-
destroy,
|
|
295
|
-
undestroy,
|
|
296
|
-
errorOrDestroy
|
|
297
|
-
};
|
|
298
|
-
var errorsBrowser = {};
|
|
299
|
-
function _inheritsLoose(subClass, superClass) {
|
|
300
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
301
|
-
subClass.prototype.constructor = subClass;
|
|
302
|
-
subClass.__proto__ = superClass;
|
|
303
|
-
}
|
|
304
|
-
var codes = {};
|
|
305
|
-
function createErrorType(code, message, Base) {
|
|
306
|
-
if (!Base) {
|
|
307
|
-
Base = Error;
|
|
308
|
-
}
|
|
309
|
-
function getMessage(arg1, arg2, arg3) {
|
|
310
|
-
if (typeof message === "string") {
|
|
311
|
-
return message;
|
|
312
|
-
} else {
|
|
313
|
-
return message(arg1, arg2, arg3);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
var NodeError = /* @__PURE__ */ function(_Base) {
|
|
317
|
-
_inheritsLoose(NodeError2, _Base);
|
|
318
|
-
function NodeError2(arg1, arg2, arg3) {
|
|
319
|
-
return _Base.call(this, getMessage(arg1, arg2, arg3)) || this;
|
|
320
|
-
}
|
|
321
|
-
return NodeError2;
|
|
322
|
-
}(Base);
|
|
323
|
-
NodeError.prototype.name = Base.name;
|
|
324
|
-
NodeError.prototype.code = code;
|
|
325
|
-
codes[code] = NodeError;
|
|
326
|
-
}
|
|
327
|
-
function oneOf(expected, thing) {
|
|
328
|
-
if (Array.isArray(expected)) {
|
|
329
|
-
var len = expected.length;
|
|
330
|
-
expected = expected.map(function(i) {
|
|
331
|
-
return String(i);
|
|
332
|
-
});
|
|
333
|
-
if (len > 2) {
|
|
334
|
-
return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(", "), ", or ") + expected[len - 1];
|
|
335
|
-
} else if (len === 2) {
|
|
336
|
-
return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);
|
|
337
|
-
} else {
|
|
338
|
-
return "of ".concat(thing, " ").concat(expected[0]);
|
|
339
|
-
}
|
|
340
|
-
} else {
|
|
341
|
-
return "of ".concat(thing, " ").concat(String(expected));
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
function startsWith(str, search, pos) {
|
|
345
|
-
return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
|
|
346
|
-
}
|
|
347
|
-
function endsWith(str, search, this_len) {
|
|
348
|
-
if (this_len === void 0 || this_len > str.length) {
|
|
349
|
-
this_len = str.length;
|
|
350
|
-
}
|
|
351
|
-
return str.substring(this_len - search.length, this_len) === search;
|
|
352
|
-
}
|
|
353
|
-
function includes(str, search, start) {
|
|
354
|
-
if (typeof start !== "number") {
|
|
355
|
-
start = 0;
|
|
356
|
-
}
|
|
357
|
-
if (start + search.length > str.length) {
|
|
358
|
-
return false;
|
|
359
|
-
} else {
|
|
360
|
-
return str.indexOf(search, start) !== -1;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
createErrorType("ERR_INVALID_OPT_VALUE", function(name, value) {
|
|
364
|
-
return 'The value "' + value + '" is invalid for option "' + name + '"';
|
|
365
|
-
}, TypeError);
|
|
366
|
-
createErrorType("ERR_INVALID_ARG_TYPE", function(name, expected, actual) {
|
|
367
|
-
var determiner;
|
|
368
|
-
if (typeof expected === "string" && startsWith(expected, "not ")) {
|
|
369
|
-
determiner = "must not be";
|
|
370
|
-
expected = expected.replace(/^not /, "");
|
|
371
|
-
} else {
|
|
372
|
-
determiner = "must be";
|
|
373
|
-
}
|
|
374
|
-
var msg;
|
|
375
|
-
if (endsWith(name, " argument")) {
|
|
376
|
-
msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, "type"));
|
|
377
|
-
} else {
|
|
378
|
-
var type = includes(name, ".") ? "property" : "argument";
|
|
379
|
-
msg = 'The "'.concat(name, '" ').concat(type, " ").concat(determiner, " ").concat(oneOf(expected, "type"));
|
|
380
|
-
}
|
|
381
|
-
msg += ". Received type ".concat(typeof actual);
|
|
382
|
-
return msg;
|
|
383
|
-
}, TypeError);
|
|
384
|
-
createErrorType("ERR_STREAM_PUSH_AFTER_EOF", "stream.push() after EOF");
|
|
385
|
-
createErrorType("ERR_METHOD_NOT_IMPLEMENTED", function(name) {
|
|
386
|
-
return "The " + name + " method is not implemented";
|
|
387
|
-
});
|
|
388
|
-
createErrorType("ERR_STREAM_PREMATURE_CLOSE", "Premature close");
|
|
389
|
-
createErrorType("ERR_STREAM_DESTROYED", function(name) {
|
|
390
|
-
return "Cannot call " + name + " after a stream was destroyed";
|
|
391
|
-
});
|
|
392
|
-
createErrorType("ERR_MULTIPLE_CALLBACK", "Callback called multiple times");
|
|
393
|
-
createErrorType("ERR_STREAM_CANNOT_PIPE", "Cannot pipe, not readable");
|
|
394
|
-
createErrorType("ERR_STREAM_WRITE_AFTER_END", "write after end");
|
|
395
|
-
createErrorType("ERR_STREAM_NULL_VALUES", "May not write null values to stream", TypeError);
|
|
396
|
-
createErrorType("ERR_UNKNOWN_ENCODING", function(arg) {
|
|
397
|
-
return "Unknown encoding: " + arg;
|
|
398
|
-
}, TypeError);
|
|
399
|
-
createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT", "stream.unshift() after end event");
|
|
400
|
-
errorsBrowser.codes = codes;
|
|
401
|
-
var ERR_INVALID_OPT_VALUE = errorsBrowser.codes.ERR_INVALID_OPT_VALUE;
|
|
402
|
-
function highWaterMarkFrom(options, isDuplex, duplexKey) {
|
|
403
|
-
return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
|
|
404
|
-
}
|
|
405
|
-
function getHighWaterMark(state2, options, duplexKey, isDuplex) {
|
|
406
|
-
var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
|
|
407
|
-
if (hwm != null) {
|
|
408
|
-
if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
|
|
409
|
-
var name = isDuplex ? duplexKey : "highWaterMark";
|
|
410
|
-
throw new ERR_INVALID_OPT_VALUE(name, hwm);
|
|
411
|
-
}
|
|
412
|
-
return Math.floor(hwm);
|
|
413
|
-
}
|
|
414
|
-
return state2.objectMode ? 16 : 16 * 1024;
|
|
415
|
-
}
|
|
416
|
-
var state = {
|
|
417
|
-
getHighWaterMark
|
|
418
|
-
};
|
|
419
|
-
var inherits_browser = { exports: {} };
|
|
420
|
-
if (typeof Object.create === "function") {
|
|
421
|
-
inherits_browser.exports = function inherits(ctor, superCtor) {
|
|
422
|
-
if (superCtor) {
|
|
423
|
-
ctor.super_ = superCtor;
|
|
424
|
-
ctor.prototype = Object.create(superCtor.prototype, {
|
|
425
|
-
constructor: {
|
|
426
|
-
value: ctor,
|
|
427
|
-
enumerable: false,
|
|
428
|
-
writable: true,
|
|
429
|
-
configurable: true
|
|
430
|
-
}
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
|
-
} else {
|
|
435
|
-
inherits_browser.exports = function inherits(ctor, superCtor) {
|
|
436
|
-
if (superCtor) {
|
|
437
|
-
ctor.super_ = superCtor;
|
|
438
|
-
var TempCtor = function() {
|
|
439
|
-
};
|
|
440
|
-
TempCtor.prototype = superCtor.prototype;
|
|
441
|
-
ctor.prototype = new TempCtor();
|
|
442
|
-
ctor.prototype.constructor = ctor;
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
}
|
|
446
|
-
var inherits_browserExports = inherits_browser.exports;
|
|
447
|
-
var buffer_list;
|
|
448
|
-
var hasRequiredBuffer_list;
|
|
449
|
-
function requireBuffer_list() {
|
|
450
|
-
if (hasRequiredBuffer_list)
|
|
451
|
-
return buffer_list;
|
|
452
|
-
hasRequiredBuffer_list = 1;
|
|
453
|
-
function ownKeys(object, enumerableOnly) {
|
|
454
|
-
var keys = Object.keys(object);
|
|
455
|
-
if (Object.getOwnPropertySymbols) {
|
|
456
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
457
|
-
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
458
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
459
|
-
})), keys.push.apply(keys, symbols);
|
|
460
|
-
}
|
|
461
|
-
return keys;
|
|
462
|
-
}
|
|
463
|
-
function _objectSpread(target) {
|
|
464
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
465
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
466
|
-
i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
|
|
467
|
-
_defineProperty(target, key, source[key]);
|
|
468
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
469
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
return target;
|
|
473
|
-
}
|
|
474
|
-
function _defineProperty(obj, key, value) {
|
|
475
|
-
key = _toPropertyKey(key);
|
|
476
|
-
if (key in obj) {
|
|
477
|
-
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
478
|
-
} else {
|
|
479
|
-
obj[key] = value;
|
|
480
|
-
}
|
|
481
|
-
return obj;
|
|
482
|
-
}
|
|
483
|
-
function _classCallCheck(instance, Constructor) {
|
|
484
|
-
if (!(instance instanceof Constructor)) {
|
|
485
|
-
throw new TypeError("Cannot call a class as a function");
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
function _defineProperties(target, props) {
|
|
489
|
-
for (var i = 0; i < props.length; i++) {
|
|
490
|
-
var descriptor = props[i];
|
|
491
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
492
|
-
descriptor.configurable = true;
|
|
493
|
-
if ("value" in descriptor)
|
|
494
|
-
descriptor.writable = true;
|
|
495
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
499
|
-
if (protoProps)
|
|
500
|
-
_defineProperties(Constructor.prototype, protoProps);
|
|
501
|
-
if (staticProps)
|
|
502
|
-
_defineProperties(Constructor, staticProps);
|
|
503
|
-
Object.defineProperty(Constructor, "prototype", { writable: false });
|
|
504
|
-
return Constructor;
|
|
505
|
-
}
|
|
506
|
-
function _toPropertyKey(arg) {
|
|
507
|
-
var key = _toPrimitive(arg, "string");
|
|
508
|
-
return typeof key === "symbol" ? key : String(key);
|
|
509
|
-
}
|
|
510
|
-
function _toPrimitive(input, hint) {
|
|
511
|
-
if (typeof input !== "object" || input === null)
|
|
512
|
-
return input;
|
|
513
|
-
var prim = input[Symbol.toPrimitive];
|
|
514
|
-
if (prim !== void 0) {
|
|
515
|
-
var res = prim.call(input, hint || "default");
|
|
516
|
-
if (typeof res !== "object")
|
|
517
|
-
return res;
|
|
518
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
519
|
-
}
|
|
520
|
-
return (hint === "string" ? String : Number)(input);
|
|
521
|
-
}
|
|
522
|
-
var _require = require$$0$1, Buffer2 = _require.Buffer;
|
|
523
|
-
var _require2 = require$$0$2, inspect = _require2.inspect;
|
|
524
|
-
var custom = inspect && inspect.custom || "inspect";
|
|
525
|
-
function copyBuffer(src, target, offset) {
|
|
526
|
-
Buffer2.prototype.copy.call(src, target, offset);
|
|
527
|
-
}
|
|
528
|
-
buffer_list = /* @__PURE__ */ function() {
|
|
529
|
-
function BufferList() {
|
|
530
|
-
_classCallCheck(this, BufferList);
|
|
531
|
-
this.head = null;
|
|
532
|
-
this.tail = null;
|
|
533
|
-
this.length = 0;
|
|
534
|
-
}
|
|
535
|
-
_createClass(BufferList, [{
|
|
536
|
-
key: "push",
|
|
537
|
-
value: function push(v) {
|
|
538
|
-
var entry = {
|
|
539
|
-
data: v,
|
|
540
|
-
next: null
|
|
541
|
-
};
|
|
542
|
-
if (this.length > 0)
|
|
543
|
-
this.tail.next = entry;
|
|
544
|
-
else
|
|
545
|
-
this.head = entry;
|
|
546
|
-
this.tail = entry;
|
|
547
|
-
++this.length;
|
|
548
|
-
}
|
|
549
|
-
}, {
|
|
550
|
-
key: "unshift",
|
|
551
|
-
value: function unshift(v) {
|
|
552
|
-
var entry = {
|
|
553
|
-
data: v,
|
|
554
|
-
next: this.head
|
|
555
|
-
};
|
|
556
|
-
if (this.length === 0)
|
|
557
|
-
this.tail = entry;
|
|
558
|
-
this.head = entry;
|
|
559
|
-
++this.length;
|
|
560
|
-
}
|
|
561
|
-
}, {
|
|
562
|
-
key: "shift",
|
|
563
|
-
value: function shift() {
|
|
564
|
-
if (this.length === 0)
|
|
565
|
-
return;
|
|
566
|
-
var ret = this.head.data;
|
|
567
|
-
if (this.length === 1)
|
|
568
|
-
this.head = this.tail = null;
|
|
569
|
-
else
|
|
570
|
-
this.head = this.head.next;
|
|
571
|
-
--this.length;
|
|
572
|
-
return ret;
|
|
573
|
-
}
|
|
574
|
-
}, {
|
|
575
|
-
key: "clear",
|
|
576
|
-
value: function clear() {
|
|
577
|
-
this.head = this.tail = null;
|
|
578
|
-
this.length = 0;
|
|
579
|
-
}
|
|
580
|
-
}, {
|
|
581
|
-
key: "join",
|
|
582
|
-
value: function join(s) {
|
|
583
|
-
if (this.length === 0)
|
|
584
|
-
return "";
|
|
585
|
-
var p = this.head;
|
|
586
|
-
var ret = "" + p.data;
|
|
587
|
-
while (p = p.next)
|
|
588
|
-
ret += s + p.data;
|
|
589
|
-
return ret;
|
|
590
|
-
}
|
|
591
|
-
}, {
|
|
592
|
-
key: "concat",
|
|
593
|
-
value: function concat(n) {
|
|
594
|
-
if (this.length === 0)
|
|
595
|
-
return Buffer2.alloc(0);
|
|
596
|
-
var ret = Buffer2.allocUnsafe(n >>> 0);
|
|
597
|
-
var p = this.head;
|
|
598
|
-
var i = 0;
|
|
599
|
-
while (p) {
|
|
600
|
-
copyBuffer(p.data, ret, i);
|
|
601
|
-
i += p.data.length;
|
|
602
|
-
p = p.next;
|
|
603
|
-
}
|
|
604
|
-
return ret;
|
|
605
|
-
}
|
|
606
|
-
// Consumes a specified amount of bytes or characters from the buffered data.
|
|
607
|
-
}, {
|
|
608
|
-
key: "consume",
|
|
609
|
-
value: function consume(n, hasStrings) {
|
|
610
|
-
var ret;
|
|
611
|
-
if (n < this.head.data.length) {
|
|
612
|
-
ret = this.head.data.slice(0, n);
|
|
613
|
-
this.head.data = this.head.data.slice(n);
|
|
614
|
-
} else if (n === this.head.data.length) {
|
|
615
|
-
ret = this.shift();
|
|
616
|
-
} else {
|
|
617
|
-
ret = hasStrings ? this._getString(n) : this._getBuffer(n);
|
|
618
|
-
}
|
|
619
|
-
return ret;
|
|
620
|
-
}
|
|
621
|
-
}, {
|
|
622
|
-
key: "first",
|
|
623
|
-
value: function first() {
|
|
624
|
-
return this.head.data;
|
|
625
|
-
}
|
|
626
|
-
// Consumes a specified amount of characters from the buffered data.
|
|
627
|
-
}, {
|
|
628
|
-
key: "_getString",
|
|
629
|
-
value: function _getString(n) {
|
|
630
|
-
var p = this.head;
|
|
631
|
-
var c = 1;
|
|
632
|
-
var ret = p.data;
|
|
633
|
-
n -= ret.length;
|
|
634
|
-
while (p = p.next) {
|
|
635
|
-
var str = p.data;
|
|
636
|
-
var nb = n > str.length ? str.length : n;
|
|
637
|
-
if (nb === str.length)
|
|
638
|
-
ret += str;
|
|
639
|
-
else
|
|
640
|
-
ret += str.slice(0, n);
|
|
641
|
-
n -= nb;
|
|
642
|
-
if (n === 0) {
|
|
643
|
-
if (nb === str.length) {
|
|
644
|
-
++c;
|
|
645
|
-
if (p.next)
|
|
646
|
-
this.head = p.next;
|
|
647
|
-
else
|
|
648
|
-
this.head = this.tail = null;
|
|
649
|
-
} else {
|
|
650
|
-
this.head = p;
|
|
651
|
-
p.data = str.slice(nb);
|
|
652
|
-
}
|
|
653
|
-
break;
|
|
654
|
-
}
|
|
655
|
-
++c;
|
|
656
|
-
}
|
|
657
|
-
this.length -= c;
|
|
658
|
-
return ret;
|
|
659
|
-
}
|
|
660
|
-
// Consumes a specified amount of bytes from the buffered data.
|
|
661
|
-
}, {
|
|
662
|
-
key: "_getBuffer",
|
|
663
|
-
value: function _getBuffer(n) {
|
|
664
|
-
var ret = Buffer2.allocUnsafe(n);
|
|
665
|
-
var p = this.head;
|
|
666
|
-
var c = 1;
|
|
667
|
-
p.data.copy(ret);
|
|
668
|
-
n -= p.data.length;
|
|
669
|
-
while (p = p.next) {
|
|
670
|
-
var buf = p.data;
|
|
671
|
-
var nb = n > buf.length ? buf.length : n;
|
|
672
|
-
buf.copy(ret, ret.length - n, 0, nb);
|
|
673
|
-
n -= nb;
|
|
674
|
-
if (n === 0) {
|
|
675
|
-
if (nb === buf.length) {
|
|
676
|
-
++c;
|
|
677
|
-
if (p.next)
|
|
678
|
-
this.head = p.next;
|
|
679
|
-
else
|
|
680
|
-
this.head = this.tail = null;
|
|
681
|
-
} else {
|
|
682
|
-
this.head = p;
|
|
683
|
-
p.data = buf.slice(nb);
|
|
684
|
-
}
|
|
685
|
-
break;
|
|
686
|
-
}
|
|
687
|
-
++c;
|
|
688
|
-
}
|
|
689
|
-
this.length -= c;
|
|
690
|
-
return ret;
|
|
691
|
-
}
|
|
692
|
-
// Make sure the linked list only shows the minimal necessary information.
|
|
693
|
-
}, {
|
|
694
|
-
key: custom,
|
|
695
|
-
value: function value(_, options) {
|
|
696
|
-
return inspect(this, _objectSpread(_objectSpread({}, options), {}, {
|
|
697
|
-
// Only inspect one level.
|
|
698
|
-
depth: 0,
|
|
699
|
-
// It should not recurse.
|
|
700
|
-
customInspect: false
|
|
701
|
-
}));
|
|
702
|
-
}
|
|
703
|
-
}]);
|
|
704
|
-
return BufferList;
|
|
705
|
-
}();
|
|
706
|
-
return buffer_list;
|
|
707
|
-
}
|
|
708
|
-
var string_decoder = {};
|
|
709
|
-
var safeBuffer = { exports: {} };
|
|
710
|
-
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
711
|
-
var hasRequiredSafeBuffer;
|
|
712
|
-
function requireSafeBuffer() {
|
|
713
|
-
if (hasRequiredSafeBuffer)
|
|
714
|
-
return safeBuffer.exports;
|
|
715
|
-
hasRequiredSafeBuffer = 1;
|
|
716
|
-
(function(module, exports) {
|
|
717
|
-
var buffer = require$$0$1;
|
|
718
|
-
var Buffer2 = buffer.Buffer;
|
|
719
|
-
function copyProps(src, dst) {
|
|
720
|
-
for (var key in src) {
|
|
721
|
-
dst[key] = src[key];
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) {
|
|
725
|
-
module.exports = buffer;
|
|
726
|
-
} else {
|
|
727
|
-
copyProps(buffer, exports);
|
|
728
|
-
exports.Buffer = SafeBuffer;
|
|
729
|
-
}
|
|
730
|
-
function SafeBuffer(arg, encodingOrOffset, length) {
|
|
731
|
-
return Buffer2(arg, encodingOrOffset, length);
|
|
732
|
-
}
|
|
733
|
-
SafeBuffer.prototype = Object.create(Buffer2.prototype);
|
|
734
|
-
copyProps(Buffer2, SafeBuffer);
|
|
735
|
-
SafeBuffer.from = function(arg, encodingOrOffset, length) {
|
|
736
|
-
if (typeof arg === "number") {
|
|
737
|
-
throw new TypeError("Argument must not be a number");
|
|
738
|
-
}
|
|
739
|
-
return Buffer2(arg, encodingOrOffset, length);
|
|
740
|
-
};
|
|
741
|
-
SafeBuffer.alloc = function(size, fill, encoding) {
|
|
742
|
-
if (typeof size !== "number") {
|
|
743
|
-
throw new TypeError("Argument must be a number");
|
|
744
|
-
}
|
|
745
|
-
var buf = Buffer2(size);
|
|
746
|
-
if (fill !== void 0) {
|
|
747
|
-
if (typeof encoding === "string") {
|
|
748
|
-
buf.fill(fill, encoding);
|
|
749
|
-
} else {
|
|
750
|
-
buf.fill(fill);
|
|
751
|
-
}
|
|
752
|
-
} else {
|
|
753
|
-
buf.fill(0);
|
|
754
|
-
}
|
|
755
|
-
return buf;
|
|
756
|
-
};
|
|
757
|
-
SafeBuffer.allocUnsafe = function(size) {
|
|
758
|
-
if (typeof size !== "number") {
|
|
759
|
-
throw new TypeError("Argument must be a number");
|
|
760
|
-
}
|
|
761
|
-
return Buffer2(size);
|
|
762
|
-
};
|
|
763
|
-
SafeBuffer.allocUnsafeSlow = function(size) {
|
|
764
|
-
if (typeof size !== "number") {
|
|
765
|
-
throw new TypeError("Argument must be a number");
|
|
766
|
-
}
|
|
767
|
-
return buffer.SlowBuffer(size);
|
|
768
|
-
};
|
|
769
|
-
})(safeBuffer, safeBuffer.exports);
|
|
770
|
-
return safeBuffer.exports;
|
|
771
|
-
}
|
|
772
|
-
var hasRequiredString_decoder;
|
|
773
|
-
function requireString_decoder() {
|
|
774
|
-
if (hasRequiredString_decoder)
|
|
775
|
-
return string_decoder;
|
|
776
|
-
hasRequiredString_decoder = 1;
|
|
777
|
-
var Buffer2 = requireSafeBuffer().Buffer;
|
|
778
|
-
var isEncoding = Buffer2.isEncoding || function(encoding) {
|
|
779
|
-
encoding = "" + encoding;
|
|
780
|
-
switch (encoding && encoding.toLowerCase()) {
|
|
781
|
-
case "hex":
|
|
782
|
-
case "utf8":
|
|
783
|
-
case "utf-8":
|
|
784
|
-
case "ascii":
|
|
785
|
-
case "binary":
|
|
786
|
-
case "base64":
|
|
787
|
-
case "ucs2":
|
|
788
|
-
case "ucs-2":
|
|
789
|
-
case "utf16le":
|
|
790
|
-
case "utf-16le":
|
|
791
|
-
case "raw":
|
|
792
|
-
return true;
|
|
793
|
-
default:
|
|
794
|
-
return false;
|
|
795
|
-
}
|
|
796
|
-
};
|
|
797
|
-
function _normalizeEncoding(enc) {
|
|
798
|
-
if (!enc)
|
|
799
|
-
return "utf8";
|
|
800
|
-
var retried;
|
|
801
|
-
while (true) {
|
|
802
|
-
switch (enc) {
|
|
803
|
-
case "utf8":
|
|
804
|
-
case "utf-8":
|
|
805
|
-
return "utf8";
|
|
806
|
-
case "ucs2":
|
|
807
|
-
case "ucs-2":
|
|
808
|
-
case "utf16le":
|
|
809
|
-
case "utf-16le":
|
|
810
|
-
return "utf16le";
|
|
811
|
-
case "latin1":
|
|
812
|
-
case "binary":
|
|
813
|
-
return "latin1";
|
|
814
|
-
case "base64":
|
|
815
|
-
case "ascii":
|
|
816
|
-
case "hex":
|
|
817
|
-
return enc;
|
|
818
|
-
default:
|
|
819
|
-
if (retried)
|
|
820
|
-
return;
|
|
821
|
-
enc = ("" + enc).toLowerCase();
|
|
822
|
-
retried = true;
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
function normalizeEncoding(enc) {
|
|
827
|
-
var nenc = _normalizeEncoding(enc);
|
|
828
|
-
if (typeof nenc !== "string" && (Buffer2.isEncoding === isEncoding || !isEncoding(enc)))
|
|
829
|
-
throw new Error("Unknown encoding: " + enc);
|
|
830
|
-
return nenc || enc;
|
|
831
|
-
}
|
|
832
|
-
string_decoder.StringDecoder = StringDecoder;
|
|
833
|
-
function StringDecoder(encoding) {
|
|
834
|
-
this.encoding = normalizeEncoding(encoding);
|
|
835
|
-
var nb;
|
|
836
|
-
switch (this.encoding) {
|
|
837
|
-
case "utf16le":
|
|
838
|
-
this.text = utf16Text;
|
|
839
|
-
this.end = utf16End;
|
|
840
|
-
nb = 4;
|
|
841
|
-
break;
|
|
842
|
-
case "utf8":
|
|
843
|
-
this.fillLast = utf8FillLast;
|
|
844
|
-
nb = 4;
|
|
845
|
-
break;
|
|
846
|
-
case "base64":
|
|
847
|
-
this.text = base64Text;
|
|
848
|
-
this.end = base64End;
|
|
849
|
-
nb = 3;
|
|
850
|
-
break;
|
|
851
|
-
default:
|
|
852
|
-
this.write = simpleWrite;
|
|
853
|
-
this.end = simpleEnd;
|
|
854
|
-
return;
|
|
855
|
-
}
|
|
856
|
-
this.lastNeed = 0;
|
|
857
|
-
this.lastTotal = 0;
|
|
858
|
-
this.lastChar = Buffer2.allocUnsafe(nb);
|
|
859
|
-
}
|
|
860
|
-
StringDecoder.prototype.write = function(buf) {
|
|
861
|
-
if (buf.length === 0)
|
|
862
|
-
return "";
|
|
863
|
-
var r;
|
|
864
|
-
var i;
|
|
865
|
-
if (this.lastNeed) {
|
|
866
|
-
r = this.fillLast(buf);
|
|
867
|
-
if (r === void 0)
|
|
868
|
-
return "";
|
|
869
|
-
i = this.lastNeed;
|
|
870
|
-
this.lastNeed = 0;
|
|
871
|
-
} else {
|
|
872
|
-
i = 0;
|
|
873
|
-
}
|
|
874
|
-
if (i < buf.length)
|
|
875
|
-
return r ? r + this.text(buf, i) : this.text(buf, i);
|
|
876
|
-
return r || "";
|
|
877
|
-
};
|
|
878
|
-
StringDecoder.prototype.end = utf8End;
|
|
879
|
-
StringDecoder.prototype.text = utf8Text;
|
|
880
|
-
StringDecoder.prototype.fillLast = function(buf) {
|
|
881
|
-
if (this.lastNeed <= buf.length) {
|
|
882
|
-
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
|
|
883
|
-
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
|
884
|
-
}
|
|
885
|
-
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
|
|
886
|
-
this.lastNeed -= buf.length;
|
|
887
|
-
};
|
|
888
|
-
function utf8CheckByte(byte) {
|
|
889
|
-
if (byte <= 127)
|
|
890
|
-
return 0;
|
|
891
|
-
else if (byte >> 5 === 6)
|
|
892
|
-
return 2;
|
|
893
|
-
else if (byte >> 4 === 14)
|
|
894
|
-
return 3;
|
|
895
|
-
else if (byte >> 3 === 30)
|
|
896
|
-
return 4;
|
|
897
|
-
return byte >> 6 === 2 ? -1 : -2;
|
|
898
|
-
}
|
|
899
|
-
function utf8CheckIncomplete(self2, buf, i) {
|
|
900
|
-
var j = buf.length - 1;
|
|
901
|
-
if (j < i)
|
|
902
|
-
return 0;
|
|
903
|
-
var nb = utf8CheckByte(buf[j]);
|
|
904
|
-
if (nb >= 0) {
|
|
905
|
-
if (nb > 0)
|
|
906
|
-
self2.lastNeed = nb - 1;
|
|
907
|
-
return nb;
|
|
908
|
-
}
|
|
909
|
-
if (--j < i || nb === -2)
|
|
910
|
-
return 0;
|
|
911
|
-
nb = utf8CheckByte(buf[j]);
|
|
912
|
-
if (nb >= 0) {
|
|
913
|
-
if (nb > 0)
|
|
914
|
-
self2.lastNeed = nb - 2;
|
|
915
|
-
return nb;
|
|
916
|
-
}
|
|
917
|
-
if (--j < i || nb === -2)
|
|
918
|
-
return 0;
|
|
919
|
-
nb = utf8CheckByte(buf[j]);
|
|
920
|
-
if (nb >= 0) {
|
|
921
|
-
if (nb > 0) {
|
|
922
|
-
if (nb === 2)
|
|
923
|
-
nb = 0;
|
|
924
|
-
else
|
|
925
|
-
self2.lastNeed = nb - 3;
|
|
926
|
-
}
|
|
927
|
-
return nb;
|
|
928
|
-
}
|
|
929
|
-
return 0;
|
|
930
|
-
}
|
|
931
|
-
function utf8CheckExtraBytes(self2, buf, p) {
|
|
932
|
-
if ((buf[0] & 192) !== 128) {
|
|
933
|
-
self2.lastNeed = 0;
|
|
934
|
-
return "�";
|
|
935
|
-
}
|
|
936
|
-
if (self2.lastNeed > 1 && buf.length > 1) {
|
|
937
|
-
if ((buf[1] & 192) !== 128) {
|
|
938
|
-
self2.lastNeed = 1;
|
|
939
|
-
return "�";
|
|
940
|
-
}
|
|
941
|
-
if (self2.lastNeed > 2 && buf.length > 2) {
|
|
942
|
-
if ((buf[2] & 192) !== 128) {
|
|
943
|
-
self2.lastNeed = 2;
|
|
944
|
-
return "�";
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
function utf8FillLast(buf) {
|
|
950
|
-
var p = this.lastTotal - this.lastNeed;
|
|
951
|
-
var r = utf8CheckExtraBytes(this, buf);
|
|
952
|
-
if (r !== void 0)
|
|
953
|
-
return r;
|
|
954
|
-
if (this.lastNeed <= buf.length) {
|
|
955
|
-
buf.copy(this.lastChar, p, 0, this.lastNeed);
|
|
956
|
-
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
|
957
|
-
}
|
|
958
|
-
buf.copy(this.lastChar, p, 0, buf.length);
|
|
959
|
-
this.lastNeed -= buf.length;
|
|
960
|
-
}
|
|
961
|
-
function utf8Text(buf, i) {
|
|
962
|
-
var total = utf8CheckIncomplete(this, buf, i);
|
|
963
|
-
if (!this.lastNeed)
|
|
964
|
-
return buf.toString("utf8", i);
|
|
965
|
-
this.lastTotal = total;
|
|
966
|
-
var end = buf.length - (total - this.lastNeed);
|
|
967
|
-
buf.copy(this.lastChar, 0, end);
|
|
968
|
-
return buf.toString("utf8", i, end);
|
|
969
|
-
}
|
|
970
|
-
function utf8End(buf) {
|
|
971
|
-
var r = buf && buf.length ? this.write(buf) : "";
|
|
972
|
-
if (this.lastNeed)
|
|
973
|
-
return r + "�";
|
|
974
|
-
return r;
|
|
975
|
-
}
|
|
976
|
-
function utf16Text(buf, i) {
|
|
977
|
-
if ((buf.length - i) % 2 === 0) {
|
|
978
|
-
var r = buf.toString("utf16le", i);
|
|
979
|
-
if (r) {
|
|
980
|
-
var c = r.charCodeAt(r.length - 1);
|
|
981
|
-
if (c >= 55296 && c <= 56319) {
|
|
982
|
-
this.lastNeed = 2;
|
|
983
|
-
this.lastTotal = 4;
|
|
984
|
-
this.lastChar[0] = buf[buf.length - 2];
|
|
985
|
-
this.lastChar[1] = buf[buf.length - 1];
|
|
986
|
-
return r.slice(0, -1);
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
return r;
|
|
990
|
-
}
|
|
991
|
-
this.lastNeed = 1;
|
|
992
|
-
this.lastTotal = 2;
|
|
993
|
-
this.lastChar[0] = buf[buf.length - 1];
|
|
994
|
-
return buf.toString("utf16le", i, buf.length - 1);
|
|
995
|
-
}
|
|
996
|
-
function utf16End(buf) {
|
|
997
|
-
var r = buf && buf.length ? this.write(buf) : "";
|
|
998
|
-
if (this.lastNeed) {
|
|
999
|
-
var end = this.lastTotal - this.lastNeed;
|
|
1000
|
-
return r + this.lastChar.toString("utf16le", 0, end);
|
|
1001
|
-
}
|
|
1002
|
-
return r;
|
|
1003
|
-
}
|
|
1004
|
-
function base64Text(buf, i) {
|
|
1005
|
-
var n = (buf.length - i) % 3;
|
|
1006
|
-
if (n === 0)
|
|
1007
|
-
return buf.toString("base64", i);
|
|
1008
|
-
this.lastNeed = 3 - n;
|
|
1009
|
-
this.lastTotal = 3;
|
|
1010
|
-
if (n === 1) {
|
|
1011
|
-
this.lastChar[0] = buf[buf.length - 1];
|
|
1012
|
-
} else {
|
|
1013
|
-
this.lastChar[0] = buf[buf.length - 2];
|
|
1014
|
-
this.lastChar[1] = buf[buf.length - 1];
|
|
1015
|
-
}
|
|
1016
|
-
return buf.toString("base64", i, buf.length - n);
|
|
1017
|
-
}
|
|
1018
|
-
function base64End(buf) {
|
|
1019
|
-
var r = buf && buf.length ? this.write(buf) : "";
|
|
1020
|
-
if (this.lastNeed)
|
|
1021
|
-
return r + this.lastChar.toString("base64", 0, 3 - this.lastNeed);
|
|
1022
|
-
return r;
|
|
1023
|
-
}
|
|
1024
|
-
function simpleWrite(buf) {
|
|
1025
|
-
return buf.toString(this.encoding);
|
|
1026
|
-
}
|
|
1027
|
-
function simpleEnd(buf) {
|
|
1028
|
-
return buf && buf.length ? this.write(buf) : "";
|
|
1029
|
-
}
|
|
1030
|
-
return string_decoder;
|
|
1031
|
-
}
|
|
1032
|
-
var endOfStream;
|
|
1033
|
-
var hasRequiredEndOfStream;
|
|
1034
|
-
function requireEndOfStream() {
|
|
1035
|
-
if (hasRequiredEndOfStream)
|
|
1036
|
-
return endOfStream;
|
|
1037
|
-
hasRequiredEndOfStream = 1;
|
|
1038
|
-
var ERR_STREAM_PREMATURE_CLOSE = errorsBrowser.codes.ERR_STREAM_PREMATURE_CLOSE;
|
|
1039
|
-
function once(callback) {
|
|
1040
|
-
var called = false;
|
|
1041
|
-
return function() {
|
|
1042
|
-
if (called)
|
|
1043
|
-
return;
|
|
1044
|
-
called = true;
|
|
1045
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1046
|
-
args[_key] = arguments[_key];
|
|
1047
|
-
}
|
|
1048
|
-
callback.apply(this, args);
|
|
1049
|
-
};
|
|
1050
|
-
}
|
|
1051
|
-
function noop() {
|
|
1052
|
-
}
|
|
1053
|
-
function isRequest(stream) {
|
|
1054
|
-
return stream.setHeader && typeof stream.abort === "function";
|
|
1055
|
-
}
|
|
1056
|
-
function eos(stream, opts, callback) {
|
|
1057
|
-
if (typeof opts === "function")
|
|
1058
|
-
return eos(stream, null, opts);
|
|
1059
|
-
if (!opts)
|
|
1060
|
-
opts = {};
|
|
1061
|
-
callback = once(callback || noop);
|
|
1062
|
-
var readable = opts.readable || opts.readable !== false && stream.readable;
|
|
1063
|
-
var writable = opts.writable || opts.writable !== false && stream.writable;
|
|
1064
|
-
var onlegacyfinish = function onlegacyfinish2() {
|
|
1065
|
-
if (!stream.writable)
|
|
1066
|
-
onfinish();
|
|
1067
|
-
};
|
|
1068
|
-
var writableEnded = stream._writableState && stream._writableState.finished;
|
|
1069
|
-
var onfinish = function onfinish2() {
|
|
1070
|
-
writable = false;
|
|
1071
|
-
writableEnded = true;
|
|
1072
|
-
if (!readable)
|
|
1073
|
-
callback.call(stream);
|
|
1074
|
-
};
|
|
1075
|
-
var readableEnded = stream._readableState && stream._readableState.endEmitted;
|
|
1076
|
-
var onend = function onend2() {
|
|
1077
|
-
readable = false;
|
|
1078
|
-
readableEnded = true;
|
|
1079
|
-
if (!writable)
|
|
1080
|
-
callback.call(stream);
|
|
1081
|
-
};
|
|
1082
|
-
var onerror = function onerror2(err) {
|
|
1083
|
-
callback.call(stream, err);
|
|
1084
|
-
};
|
|
1085
|
-
var onclose = function onclose2() {
|
|
1086
|
-
var err;
|
|
1087
|
-
if (readable && !readableEnded) {
|
|
1088
|
-
if (!stream._readableState || !stream._readableState.ended)
|
|
1089
|
-
err = new ERR_STREAM_PREMATURE_CLOSE();
|
|
1090
|
-
return callback.call(stream, err);
|
|
1091
|
-
}
|
|
1092
|
-
if (writable && !writableEnded) {
|
|
1093
|
-
if (!stream._writableState || !stream._writableState.ended)
|
|
1094
|
-
err = new ERR_STREAM_PREMATURE_CLOSE();
|
|
1095
|
-
return callback.call(stream, err);
|
|
1096
|
-
}
|
|
1097
|
-
};
|
|
1098
|
-
var onrequest = function onrequest2() {
|
|
1099
|
-
stream.req.on("finish", onfinish);
|
|
1100
|
-
};
|
|
1101
|
-
if (isRequest(stream)) {
|
|
1102
|
-
stream.on("complete", onfinish);
|
|
1103
|
-
stream.on("abort", onclose);
|
|
1104
|
-
if (stream.req)
|
|
1105
|
-
onrequest();
|
|
1106
|
-
else
|
|
1107
|
-
stream.on("request", onrequest);
|
|
1108
|
-
} else if (writable && !stream._writableState) {
|
|
1109
|
-
stream.on("end", onlegacyfinish);
|
|
1110
|
-
stream.on("close", onlegacyfinish);
|
|
1111
|
-
}
|
|
1112
|
-
stream.on("end", onend);
|
|
1113
|
-
stream.on("finish", onfinish);
|
|
1114
|
-
if (opts.error !== false)
|
|
1115
|
-
stream.on("error", onerror);
|
|
1116
|
-
stream.on("close", onclose);
|
|
1117
|
-
return function() {
|
|
1118
|
-
stream.removeListener("complete", onfinish);
|
|
1119
|
-
stream.removeListener("abort", onclose);
|
|
1120
|
-
stream.removeListener("request", onrequest);
|
|
1121
|
-
if (stream.req)
|
|
1122
|
-
stream.req.removeListener("finish", onfinish);
|
|
1123
|
-
stream.removeListener("end", onlegacyfinish);
|
|
1124
|
-
stream.removeListener("close", onlegacyfinish);
|
|
1125
|
-
stream.removeListener("finish", onfinish);
|
|
1126
|
-
stream.removeListener("end", onend);
|
|
1127
|
-
stream.removeListener("error", onerror);
|
|
1128
|
-
stream.removeListener("close", onclose);
|
|
1129
|
-
};
|
|
1130
|
-
}
|
|
1131
|
-
endOfStream = eos;
|
|
1132
|
-
return endOfStream;
|
|
1133
|
-
}
|
|
1134
|
-
var async_iterator;
|
|
1135
|
-
var hasRequiredAsync_iterator;
|
|
1136
|
-
function requireAsync_iterator() {
|
|
1137
|
-
if (hasRequiredAsync_iterator)
|
|
1138
|
-
return async_iterator;
|
|
1139
|
-
hasRequiredAsync_iterator = 1;
|
|
1140
|
-
var _Object$setPrototypeO;
|
|
1141
|
-
function _defineProperty(obj, key, value) {
|
|
1142
|
-
key = _toPropertyKey(key);
|
|
1143
|
-
if (key in obj) {
|
|
1144
|
-
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
1145
|
-
} else {
|
|
1146
|
-
obj[key] = value;
|
|
1147
|
-
}
|
|
1148
|
-
return obj;
|
|
1149
|
-
}
|
|
1150
|
-
function _toPropertyKey(arg) {
|
|
1151
|
-
var key = _toPrimitive(arg, "string");
|
|
1152
|
-
return typeof key === "symbol" ? key : String(key);
|
|
1153
|
-
}
|
|
1154
|
-
function _toPrimitive(input, hint) {
|
|
1155
|
-
if (typeof input !== "object" || input === null)
|
|
1156
|
-
return input;
|
|
1157
|
-
var prim = input[Symbol.toPrimitive];
|
|
1158
|
-
if (prim !== void 0) {
|
|
1159
|
-
var res = prim.call(input, hint || "default");
|
|
1160
|
-
if (typeof res !== "object")
|
|
1161
|
-
return res;
|
|
1162
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1163
|
-
}
|
|
1164
|
-
return (hint === "string" ? String : Number)(input);
|
|
1165
|
-
}
|
|
1166
|
-
var finished = requireEndOfStream();
|
|
1167
|
-
var kLastResolve = Symbol("lastResolve");
|
|
1168
|
-
var kLastReject = Symbol("lastReject");
|
|
1169
|
-
var kError = Symbol("error");
|
|
1170
|
-
var kEnded = Symbol("ended");
|
|
1171
|
-
var kLastPromise = Symbol("lastPromise");
|
|
1172
|
-
var kHandlePromise = Symbol("handlePromise");
|
|
1173
|
-
var kStream = Symbol("stream");
|
|
1174
|
-
function createIterResult(value, done) {
|
|
1175
|
-
return {
|
|
1176
|
-
value,
|
|
1177
|
-
done
|
|
1178
|
-
};
|
|
1179
|
-
}
|
|
1180
|
-
function readAndResolve(iter) {
|
|
1181
|
-
var resolve = iter[kLastResolve];
|
|
1182
|
-
if (resolve !== null) {
|
|
1183
|
-
var data = iter[kStream].read();
|
|
1184
|
-
if (data !== null) {
|
|
1185
|
-
iter[kLastPromise] = null;
|
|
1186
|
-
iter[kLastResolve] = null;
|
|
1187
|
-
iter[kLastReject] = null;
|
|
1188
|
-
resolve(createIterResult(data, false));
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
function onReadable(iter) {
|
|
1193
|
-
process.nextTick(readAndResolve, iter);
|
|
1194
|
-
}
|
|
1195
|
-
function wrapForNext(lastPromise, iter) {
|
|
1196
|
-
return function(resolve, reject) {
|
|
1197
|
-
lastPromise.then(function() {
|
|
1198
|
-
if (iter[kEnded]) {
|
|
1199
|
-
resolve(createIterResult(void 0, true));
|
|
1200
|
-
return;
|
|
1201
|
-
}
|
|
1202
|
-
iter[kHandlePromise](resolve, reject);
|
|
1203
|
-
}, reject);
|
|
1204
|
-
};
|
|
1205
|
-
}
|
|
1206
|
-
var AsyncIteratorPrototype = Object.getPrototypeOf(function() {
|
|
1207
|
-
});
|
|
1208
|
-
var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {
|
|
1209
|
-
get stream() {
|
|
1210
|
-
return this[kStream];
|
|
1211
|
-
},
|
|
1212
|
-
next: function next() {
|
|
1213
|
-
var _this = this;
|
|
1214
|
-
var error = this[kError];
|
|
1215
|
-
if (error !== null) {
|
|
1216
|
-
return Promise.reject(error);
|
|
1217
|
-
}
|
|
1218
|
-
if (this[kEnded]) {
|
|
1219
|
-
return Promise.resolve(createIterResult(void 0, true));
|
|
1220
|
-
}
|
|
1221
|
-
if (this[kStream].destroyed) {
|
|
1222
|
-
return new Promise(function(resolve, reject) {
|
|
1223
|
-
process.nextTick(function() {
|
|
1224
|
-
if (_this[kError]) {
|
|
1225
|
-
reject(_this[kError]);
|
|
1226
|
-
} else {
|
|
1227
|
-
resolve(createIterResult(void 0, true));
|
|
1228
|
-
}
|
|
1229
|
-
});
|
|
1230
|
-
});
|
|
1231
|
-
}
|
|
1232
|
-
var lastPromise = this[kLastPromise];
|
|
1233
|
-
var promise;
|
|
1234
|
-
if (lastPromise) {
|
|
1235
|
-
promise = new Promise(wrapForNext(lastPromise, this));
|
|
1236
|
-
} else {
|
|
1237
|
-
var data = this[kStream].read();
|
|
1238
|
-
if (data !== null) {
|
|
1239
|
-
return Promise.resolve(createIterResult(data, false));
|
|
1240
|
-
}
|
|
1241
|
-
promise = new Promise(this[kHandlePromise]);
|
|
1242
|
-
}
|
|
1243
|
-
this[kLastPromise] = promise;
|
|
1244
|
-
return promise;
|
|
1245
|
-
}
|
|
1246
|
-
}, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function() {
|
|
1247
|
-
return this;
|
|
1248
|
-
}), _defineProperty(_Object$setPrototypeO, "return", function _return() {
|
|
1249
|
-
var _this2 = this;
|
|
1250
|
-
return new Promise(function(resolve, reject) {
|
|
1251
|
-
_this2[kStream].destroy(null, function(err) {
|
|
1252
|
-
if (err) {
|
|
1253
|
-
reject(err);
|
|
1254
|
-
return;
|
|
1255
|
-
}
|
|
1256
|
-
resolve(createIterResult(void 0, true));
|
|
1257
|
-
});
|
|
1258
|
-
});
|
|
1259
|
-
}), _Object$setPrototypeO), AsyncIteratorPrototype);
|
|
1260
|
-
var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator2(stream) {
|
|
1261
|
-
var _Object$create;
|
|
1262
|
-
var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
|
|
1263
|
-
value: stream,
|
|
1264
|
-
writable: true
|
|
1265
|
-
}), _defineProperty(_Object$create, kLastResolve, {
|
|
1266
|
-
value: null,
|
|
1267
|
-
writable: true
|
|
1268
|
-
}), _defineProperty(_Object$create, kLastReject, {
|
|
1269
|
-
value: null,
|
|
1270
|
-
writable: true
|
|
1271
|
-
}), _defineProperty(_Object$create, kError, {
|
|
1272
|
-
value: null,
|
|
1273
|
-
writable: true
|
|
1274
|
-
}), _defineProperty(_Object$create, kEnded, {
|
|
1275
|
-
value: stream._readableState.endEmitted,
|
|
1276
|
-
writable: true
|
|
1277
|
-
}), _defineProperty(_Object$create, kHandlePromise, {
|
|
1278
|
-
value: function value(resolve, reject) {
|
|
1279
|
-
var data = iterator[kStream].read();
|
|
1280
|
-
if (data) {
|
|
1281
|
-
iterator[kLastPromise] = null;
|
|
1282
|
-
iterator[kLastResolve] = null;
|
|
1283
|
-
iterator[kLastReject] = null;
|
|
1284
|
-
resolve(createIterResult(data, false));
|
|
1285
|
-
} else {
|
|
1286
|
-
iterator[kLastResolve] = resolve;
|
|
1287
|
-
iterator[kLastReject] = reject;
|
|
1288
|
-
}
|
|
1289
|
-
},
|
|
1290
|
-
writable: true
|
|
1291
|
-
}), _Object$create));
|
|
1292
|
-
iterator[kLastPromise] = null;
|
|
1293
|
-
finished(stream, function(err) {
|
|
1294
|
-
if (err && err.code !== "ERR_STREAM_PREMATURE_CLOSE") {
|
|
1295
|
-
var reject = iterator[kLastReject];
|
|
1296
|
-
if (reject !== null) {
|
|
1297
|
-
iterator[kLastPromise] = null;
|
|
1298
|
-
iterator[kLastResolve] = null;
|
|
1299
|
-
iterator[kLastReject] = null;
|
|
1300
|
-
reject(err);
|
|
1301
|
-
}
|
|
1302
|
-
iterator[kError] = err;
|
|
1303
|
-
return;
|
|
1304
|
-
}
|
|
1305
|
-
var resolve = iterator[kLastResolve];
|
|
1306
|
-
if (resolve !== null) {
|
|
1307
|
-
iterator[kLastPromise] = null;
|
|
1308
|
-
iterator[kLastResolve] = null;
|
|
1309
|
-
iterator[kLastReject] = null;
|
|
1310
|
-
resolve(createIterResult(void 0, true));
|
|
1311
|
-
}
|
|
1312
|
-
iterator[kEnded] = true;
|
|
1313
|
-
});
|
|
1314
|
-
stream.on("readable", onReadable.bind(null, iterator));
|
|
1315
|
-
return iterator;
|
|
1316
|
-
};
|
|
1317
|
-
async_iterator = createReadableStreamAsyncIterator;
|
|
1318
|
-
return async_iterator;
|
|
1319
|
-
}
|
|
1320
|
-
var fromBrowser;
|
|
1321
|
-
var hasRequiredFromBrowser;
|
|
1322
|
-
function requireFromBrowser() {
|
|
1323
|
-
if (hasRequiredFromBrowser)
|
|
1324
|
-
return fromBrowser;
|
|
1325
|
-
hasRequiredFromBrowser = 1;
|
|
1326
|
-
fromBrowser = function() {
|
|
1327
|
-
throw new Error("Readable.from is not available in the browser");
|
|
1328
|
-
};
|
|
1329
|
-
return fromBrowser;
|
|
1330
|
-
}
|
|
1331
|
-
var _stream_readable;
|
|
1332
|
-
var hasRequired_stream_readable;
|
|
1333
|
-
function require_stream_readable() {
|
|
1334
|
-
if (hasRequired_stream_readable)
|
|
1335
|
-
return _stream_readable;
|
|
1336
|
-
hasRequired_stream_readable = 1;
|
|
1337
|
-
_stream_readable = Readable;
|
|
1338
|
-
var Duplex;
|
|
1339
|
-
Readable.ReadableState = ReadableState;
|
|
1340
|
-
require$$0.EventEmitter;
|
|
1341
|
-
var EElistenerCount = function EElistenerCount2(emitter, type) {
|
|
1342
|
-
return emitter.listeners(type).length;
|
|
1343
|
-
};
|
|
1344
|
-
var Stream = streamBrowser;
|
|
1345
|
-
var Buffer2 = require$$0$1.Buffer;
|
|
1346
|
-
var OurUint8Array = (typeof commonjsGlobal !== "undefined" ? commonjsGlobal : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() {
|
|
1347
|
-
};
|
|
1348
|
-
function _uint8ArrayToBuffer(chunk) {
|
|
1349
|
-
return Buffer2.from(chunk);
|
|
1350
|
-
}
|
|
1351
|
-
function _isUint8Array(obj) {
|
|
1352
|
-
return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
1353
|
-
}
|
|
1354
|
-
var debugUtil = require$$0$2;
|
|
1355
|
-
var debug;
|
|
1356
|
-
if (debugUtil && debugUtil.debuglog) {
|
|
1357
|
-
debug = debugUtil.debuglog("stream");
|
|
1358
|
-
} else {
|
|
1359
|
-
debug = function debug2() {
|
|
1360
|
-
};
|
|
1361
|
-
}
|
|
1362
|
-
var BufferList = requireBuffer_list();
|
|
1363
|
-
var destroyImpl = destroy_1;
|
|
1364
|
-
var _require = state, getHighWaterMark2 = _require.getHighWaterMark;
|
|
1365
|
-
var _require$codes = errorsBrowser.codes, ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF, ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;
|
|
1366
|
-
var StringDecoder;
|
|
1367
|
-
var createReadableStreamAsyncIterator;
|
|
1368
|
-
var from;
|
|
1369
|
-
inherits_browserExports(Readable, Stream);
|
|
1370
|
-
var errorOrDestroy2 = destroyImpl.errorOrDestroy;
|
|
1371
|
-
var kProxyEvents = ["error", "close", "destroy", "pause", "resume"];
|
|
1372
|
-
function prependListener(emitter, event, fn) {
|
|
1373
|
-
if (typeof emitter.prependListener === "function")
|
|
1374
|
-
return emitter.prependListener(event, fn);
|
|
1375
|
-
if (!emitter._events || !emitter._events[event])
|
|
1376
|
-
emitter.on(event, fn);
|
|
1377
|
-
else if (Array.isArray(emitter._events[event]))
|
|
1378
|
-
emitter._events[event].unshift(fn);
|
|
1379
|
-
else
|
|
1380
|
-
emitter._events[event] = [fn, emitter._events[event]];
|
|
1381
|
-
}
|
|
1382
|
-
function ReadableState(options, stream, isDuplex) {
|
|
1383
|
-
Duplex = Duplex || require_stream_duplex();
|
|
1384
|
-
options = options || {};
|
|
1385
|
-
if (typeof isDuplex !== "boolean")
|
|
1386
|
-
isDuplex = stream instanceof Duplex;
|
|
1387
|
-
this.objectMode = !!options.objectMode;
|
|
1388
|
-
if (isDuplex)
|
|
1389
|
-
this.objectMode = this.objectMode || !!options.readableObjectMode;
|
|
1390
|
-
this.highWaterMark = getHighWaterMark2(this, options, "readableHighWaterMark", isDuplex);
|
|
1391
|
-
this.buffer = new BufferList();
|
|
1392
|
-
this.length = 0;
|
|
1393
|
-
this.pipes = null;
|
|
1394
|
-
this.pipesCount = 0;
|
|
1395
|
-
this.flowing = null;
|
|
1396
|
-
this.ended = false;
|
|
1397
|
-
this.endEmitted = false;
|
|
1398
|
-
this.reading = false;
|
|
1399
|
-
this.sync = true;
|
|
1400
|
-
this.needReadable = false;
|
|
1401
|
-
this.emittedReadable = false;
|
|
1402
|
-
this.readableListening = false;
|
|
1403
|
-
this.resumeScheduled = false;
|
|
1404
|
-
this.paused = true;
|
|
1405
|
-
this.emitClose = options.emitClose !== false;
|
|
1406
|
-
this.autoDestroy = !!options.autoDestroy;
|
|
1407
|
-
this.destroyed = false;
|
|
1408
|
-
this.defaultEncoding = options.defaultEncoding || "utf8";
|
|
1409
|
-
this.awaitDrain = 0;
|
|
1410
|
-
this.readingMore = false;
|
|
1411
|
-
this.decoder = null;
|
|
1412
|
-
this.encoding = null;
|
|
1413
|
-
if (options.encoding) {
|
|
1414
|
-
if (!StringDecoder)
|
|
1415
|
-
StringDecoder = requireString_decoder().StringDecoder;
|
|
1416
|
-
this.decoder = new StringDecoder(options.encoding);
|
|
1417
|
-
this.encoding = options.encoding;
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
function Readable(options) {
|
|
1421
|
-
Duplex = Duplex || require_stream_duplex();
|
|
1422
|
-
if (!(this instanceof Readable))
|
|
1423
|
-
return new Readable(options);
|
|
1424
|
-
var isDuplex = this instanceof Duplex;
|
|
1425
|
-
this._readableState = new ReadableState(options, this, isDuplex);
|
|
1426
|
-
this.readable = true;
|
|
1427
|
-
if (options) {
|
|
1428
|
-
if (typeof options.read === "function")
|
|
1429
|
-
this._read = options.read;
|
|
1430
|
-
if (typeof options.destroy === "function")
|
|
1431
|
-
this._destroy = options.destroy;
|
|
1432
|
-
}
|
|
1433
|
-
Stream.call(this);
|
|
1434
|
-
}
|
|
1435
|
-
Object.defineProperty(Readable.prototype, "destroyed", {
|
|
1436
|
-
// making it explicit this property is not enumerable
|
|
1437
|
-
// because otherwise some prototype manipulation in
|
|
1438
|
-
// userland will fail
|
|
1439
|
-
enumerable: false,
|
|
1440
|
-
get: function get() {
|
|
1441
|
-
if (this._readableState === void 0) {
|
|
1442
|
-
return false;
|
|
1443
|
-
}
|
|
1444
|
-
return this._readableState.destroyed;
|
|
1445
|
-
},
|
|
1446
|
-
set: function set(value) {
|
|
1447
|
-
if (!this._readableState) {
|
|
1448
|
-
return;
|
|
1449
|
-
}
|
|
1450
|
-
this._readableState.destroyed = value;
|
|
1451
|
-
}
|
|
1452
|
-
});
|
|
1453
|
-
Readable.prototype.destroy = destroyImpl.destroy;
|
|
1454
|
-
Readable.prototype._undestroy = destroyImpl.undestroy;
|
|
1455
|
-
Readable.prototype._destroy = function(err, cb) {
|
|
1456
|
-
cb(err);
|
|
1457
|
-
};
|
|
1458
|
-
Readable.prototype.push = function(chunk, encoding) {
|
|
1459
|
-
var state2 = this._readableState;
|
|
1460
|
-
var skipChunkCheck;
|
|
1461
|
-
if (!state2.objectMode) {
|
|
1462
|
-
if (typeof chunk === "string") {
|
|
1463
|
-
encoding = encoding || state2.defaultEncoding;
|
|
1464
|
-
if (encoding !== state2.encoding) {
|
|
1465
|
-
chunk = Buffer2.from(chunk, encoding);
|
|
1466
|
-
encoding = "";
|
|
1467
|
-
}
|
|
1468
|
-
skipChunkCheck = true;
|
|
1469
|
-
}
|
|
1470
|
-
} else {
|
|
1471
|
-
skipChunkCheck = true;
|
|
1472
|
-
}
|
|
1473
|
-
return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
|
|
1474
|
-
};
|
|
1475
|
-
Readable.prototype.unshift = function(chunk) {
|
|
1476
|
-
return readableAddChunk(this, chunk, null, true, false);
|
|
1477
|
-
};
|
|
1478
|
-
function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
|
|
1479
|
-
debug("readableAddChunk", chunk);
|
|
1480
|
-
var state2 = stream._readableState;
|
|
1481
|
-
if (chunk === null) {
|
|
1482
|
-
state2.reading = false;
|
|
1483
|
-
onEofChunk(stream, state2);
|
|
1484
|
-
} else {
|
|
1485
|
-
var er;
|
|
1486
|
-
if (!skipChunkCheck)
|
|
1487
|
-
er = chunkInvalid(state2, chunk);
|
|
1488
|
-
if (er) {
|
|
1489
|
-
errorOrDestroy2(stream, er);
|
|
1490
|
-
} else if (state2.objectMode || chunk && chunk.length > 0) {
|
|
1491
|
-
if (typeof chunk !== "string" && !state2.objectMode && Object.getPrototypeOf(chunk) !== Buffer2.prototype) {
|
|
1492
|
-
chunk = _uint8ArrayToBuffer(chunk);
|
|
1493
|
-
}
|
|
1494
|
-
if (addToFront) {
|
|
1495
|
-
if (state2.endEmitted)
|
|
1496
|
-
errorOrDestroy2(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());
|
|
1497
|
-
else
|
|
1498
|
-
addChunk(stream, state2, chunk, true);
|
|
1499
|
-
} else if (state2.ended) {
|
|
1500
|
-
errorOrDestroy2(stream, new ERR_STREAM_PUSH_AFTER_EOF());
|
|
1501
|
-
} else if (state2.destroyed) {
|
|
1502
|
-
return false;
|
|
1503
|
-
} else {
|
|
1504
|
-
state2.reading = false;
|
|
1505
|
-
if (state2.decoder && !encoding) {
|
|
1506
|
-
chunk = state2.decoder.write(chunk);
|
|
1507
|
-
if (state2.objectMode || chunk.length !== 0)
|
|
1508
|
-
addChunk(stream, state2, chunk, false);
|
|
1509
|
-
else
|
|
1510
|
-
maybeReadMore(stream, state2);
|
|
1511
|
-
} else {
|
|
1512
|
-
addChunk(stream, state2, chunk, false);
|
|
1513
|
-
}
|
|
1514
|
-
}
|
|
1515
|
-
} else if (!addToFront) {
|
|
1516
|
-
state2.reading = false;
|
|
1517
|
-
maybeReadMore(stream, state2);
|
|
1518
|
-
}
|
|
1519
|
-
}
|
|
1520
|
-
return !state2.ended && (state2.length < state2.highWaterMark || state2.length === 0);
|
|
1521
|
-
}
|
|
1522
|
-
function addChunk(stream, state2, chunk, addToFront) {
|
|
1523
|
-
if (state2.flowing && state2.length === 0 && !state2.sync) {
|
|
1524
|
-
state2.awaitDrain = 0;
|
|
1525
|
-
stream.emit("data", chunk);
|
|
1526
|
-
} else {
|
|
1527
|
-
state2.length += state2.objectMode ? 1 : chunk.length;
|
|
1528
|
-
if (addToFront)
|
|
1529
|
-
state2.buffer.unshift(chunk);
|
|
1530
|
-
else
|
|
1531
|
-
state2.buffer.push(chunk);
|
|
1532
|
-
if (state2.needReadable)
|
|
1533
|
-
emitReadable(stream);
|
|
1534
|
-
}
|
|
1535
|
-
maybeReadMore(stream, state2);
|
|
1536
|
-
}
|
|
1537
|
-
function chunkInvalid(state2, chunk) {
|
|
1538
|
-
var er;
|
|
1539
|
-
if (!_isUint8Array(chunk) && typeof chunk !== "string" && chunk !== void 0 && !state2.objectMode) {
|
|
1540
|
-
er = new ERR_INVALID_ARG_TYPE("chunk", ["string", "Buffer", "Uint8Array"], chunk);
|
|
1541
|
-
}
|
|
1542
|
-
return er;
|
|
1543
|
-
}
|
|
1544
|
-
Readable.prototype.isPaused = function() {
|
|
1545
|
-
return this._readableState.flowing === false;
|
|
1546
|
-
};
|
|
1547
|
-
Readable.prototype.setEncoding = function(enc) {
|
|
1548
|
-
if (!StringDecoder)
|
|
1549
|
-
StringDecoder = requireString_decoder().StringDecoder;
|
|
1550
|
-
var decoder = new StringDecoder(enc);
|
|
1551
|
-
this._readableState.decoder = decoder;
|
|
1552
|
-
this._readableState.encoding = this._readableState.decoder.encoding;
|
|
1553
|
-
var p = this._readableState.buffer.head;
|
|
1554
|
-
var content = "";
|
|
1555
|
-
while (p !== null) {
|
|
1556
|
-
content += decoder.write(p.data);
|
|
1557
|
-
p = p.next;
|
|
1558
|
-
}
|
|
1559
|
-
this._readableState.buffer.clear();
|
|
1560
|
-
if (content !== "")
|
|
1561
|
-
this._readableState.buffer.push(content);
|
|
1562
|
-
this._readableState.length = content.length;
|
|
1563
|
-
return this;
|
|
1564
|
-
};
|
|
1565
|
-
var MAX_HWM = 1073741824;
|
|
1566
|
-
function computeNewHighWaterMark(n) {
|
|
1567
|
-
if (n >= MAX_HWM) {
|
|
1568
|
-
n = MAX_HWM;
|
|
1569
|
-
} else {
|
|
1570
|
-
n--;
|
|
1571
|
-
n |= n >>> 1;
|
|
1572
|
-
n |= n >>> 2;
|
|
1573
|
-
n |= n >>> 4;
|
|
1574
|
-
n |= n >>> 8;
|
|
1575
|
-
n |= n >>> 16;
|
|
1576
|
-
n++;
|
|
1577
|
-
}
|
|
1578
|
-
return n;
|
|
1579
|
-
}
|
|
1580
|
-
function howMuchToRead(n, state2) {
|
|
1581
|
-
if (n <= 0 || state2.length === 0 && state2.ended)
|
|
1582
|
-
return 0;
|
|
1583
|
-
if (state2.objectMode)
|
|
1584
|
-
return 1;
|
|
1585
|
-
if (n !== n) {
|
|
1586
|
-
if (state2.flowing && state2.length)
|
|
1587
|
-
return state2.buffer.head.data.length;
|
|
1588
|
-
else
|
|
1589
|
-
return state2.length;
|
|
1590
|
-
}
|
|
1591
|
-
if (n > state2.highWaterMark)
|
|
1592
|
-
state2.highWaterMark = computeNewHighWaterMark(n);
|
|
1593
|
-
if (n <= state2.length)
|
|
1594
|
-
return n;
|
|
1595
|
-
if (!state2.ended) {
|
|
1596
|
-
state2.needReadable = true;
|
|
1597
|
-
return 0;
|
|
1598
|
-
}
|
|
1599
|
-
return state2.length;
|
|
1600
|
-
}
|
|
1601
|
-
Readable.prototype.read = function(n) {
|
|
1602
|
-
debug("read", n);
|
|
1603
|
-
n = parseInt(n, 10);
|
|
1604
|
-
var state2 = this._readableState;
|
|
1605
|
-
var nOrig = n;
|
|
1606
|
-
if (n !== 0)
|
|
1607
|
-
state2.emittedReadable = false;
|
|
1608
|
-
if (n === 0 && state2.needReadable && ((state2.highWaterMark !== 0 ? state2.length >= state2.highWaterMark : state2.length > 0) || state2.ended)) {
|
|
1609
|
-
debug("read: emitReadable", state2.length, state2.ended);
|
|
1610
|
-
if (state2.length === 0 && state2.ended)
|
|
1611
|
-
endReadable(this);
|
|
1612
|
-
else
|
|
1613
|
-
emitReadable(this);
|
|
1614
|
-
return null;
|
|
1615
|
-
}
|
|
1616
|
-
n = howMuchToRead(n, state2);
|
|
1617
|
-
if (n === 0 && state2.ended) {
|
|
1618
|
-
if (state2.length === 0)
|
|
1619
|
-
endReadable(this);
|
|
1620
|
-
return null;
|
|
1621
|
-
}
|
|
1622
|
-
var doRead = state2.needReadable;
|
|
1623
|
-
debug("need readable", doRead);
|
|
1624
|
-
if (state2.length === 0 || state2.length - n < state2.highWaterMark) {
|
|
1625
|
-
doRead = true;
|
|
1626
|
-
debug("length less than watermark", doRead);
|
|
1627
|
-
}
|
|
1628
|
-
if (state2.ended || state2.reading) {
|
|
1629
|
-
doRead = false;
|
|
1630
|
-
debug("reading or ended", doRead);
|
|
1631
|
-
} else if (doRead) {
|
|
1632
|
-
debug("do read");
|
|
1633
|
-
state2.reading = true;
|
|
1634
|
-
state2.sync = true;
|
|
1635
|
-
if (state2.length === 0)
|
|
1636
|
-
state2.needReadable = true;
|
|
1637
|
-
this._read(state2.highWaterMark);
|
|
1638
|
-
state2.sync = false;
|
|
1639
|
-
if (!state2.reading)
|
|
1640
|
-
n = howMuchToRead(nOrig, state2);
|
|
1641
|
-
}
|
|
1642
|
-
var ret;
|
|
1643
|
-
if (n > 0)
|
|
1644
|
-
ret = fromList(n, state2);
|
|
1645
|
-
else
|
|
1646
|
-
ret = null;
|
|
1647
|
-
if (ret === null) {
|
|
1648
|
-
state2.needReadable = state2.length <= state2.highWaterMark;
|
|
1649
|
-
n = 0;
|
|
1650
|
-
} else {
|
|
1651
|
-
state2.length -= n;
|
|
1652
|
-
state2.awaitDrain = 0;
|
|
1653
|
-
}
|
|
1654
|
-
if (state2.length === 0) {
|
|
1655
|
-
if (!state2.ended)
|
|
1656
|
-
state2.needReadable = true;
|
|
1657
|
-
if (nOrig !== n && state2.ended)
|
|
1658
|
-
endReadable(this);
|
|
1659
|
-
}
|
|
1660
|
-
if (ret !== null)
|
|
1661
|
-
this.emit("data", ret);
|
|
1662
|
-
return ret;
|
|
1663
|
-
};
|
|
1664
|
-
function onEofChunk(stream, state2) {
|
|
1665
|
-
debug("onEofChunk");
|
|
1666
|
-
if (state2.ended)
|
|
1667
|
-
return;
|
|
1668
|
-
if (state2.decoder) {
|
|
1669
|
-
var chunk = state2.decoder.end();
|
|
1670
|
-
if (chunk && chunk.length) {
|
|
1671
|
-
state2.buffer.push(chunk);
|
|
1672
|
-
state2.length += state2.objectMode ? 1 : chunk.length;
|
|
1673
|
-
}
|
|
1674
|
-
}
|
|
1675
|
-
state2.ended = true;
|
|
1676
|
-
if (state2.sync) {
|
|
1677
|
-
emitReadable(stream);
|
|
1678
|
-
} else {
|
|
1679
|
-
state2.needReadable = false;
|
|
1680
|
-
if (!state2.emittedReadable) {
|
|
1681
|
-
state2.emittedReadable = true;
|
|
1682
|
-
emitReadable_(stream);
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
}
|
|
1686
|
-
function emitReadable(stream) {
|
|
1687
|
-
var state2 = stream._readableState;
|
|
1688
|
-
debug("emitReadable", state2.needReadable, state2.emittedReadable);
|
|
1689
|
-
state2.needReadable = false;
|
|
1690
|
-
if (!state2.emittedReadable) {
|
|
1691
|
-
debug("emitReadable", state2.flowing);
|
|
1692
|
-
state2.emittedReadable = true;
|
|
1693
|
-
process.nextTick(emitReadable_, stream);
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
function emitReadable_(stream) {
|
|
1697
|
-
var state2 = stream._readableState;
|
|
1698
|
-
debug("emitReadable_", state2.destroyed, state2.length, state2.ended);
|
|
1699
|
-
if (!state2.destroyed && (state2.length || state2.ended)) {
|
|
1700
|
-
stream.emit("readable");
|
|
1701
|
-
state2.emittedReadable = false;
|
|
1702
|
-
}
|
|
1703
|
-
state2.needReadable = !state2.flowing && !state2.ended && state2.length <= state2.highWaterMark;
|
|
1704
|
-
flow(stream);
|
|
1705
|
-
}
|
|
1706
|
-
function maybeReadMore(stream, state2) {
|
|
1707
|
-
if (!state2.readingMore) {
|
|
1708
|
-
state2.readingMore = true;
|
|
1709
|
-
process.nextTick(maybeReadMore_, stream, state2);
|
|
1710
|
-
}
|
|
1711
|
-
}
|
|
1712
|
-
function maybeReadMore_(stream, state2) {
|
|
1713
|
-
while (!state2.reading && !state2.ended && (state2.length < state2.highWaterMark || state2.flowing && state2.length === 0)) {
|
|
1714
|
-
var len = state2.length;
|
|
1715
|
-
debug("maybeReadMore read 0");
|
|
1716
|
-
stream.read(0);
|
|
1717
|
-
if (len === state2.length)
|
|
1718
|
-
break;
|
|
1719
|
-
}
|
|
1720
|
-
state2.readingMore = false;
|
|
1721
|
-
}
|
|
1722
|
-
Readable.prototype._read = function(n) {
|
|
1723
|
-
errorOrDestroy2(this, new ERR_METHOD_NOT_IMPLEMENTED("_read()"));
|
|
1724
|
-
};
|
|
1725
|
-
Readable.prototype.pipe = function(dest, pipeOpts) {
|
|
1726
|
-
var src = this;
|
|
1727
|
-
var state2 = this._readableState;
|
|
1728
|
-
switch (state2.pipesCount) {
|
|
1729
|
-
case 0:
|
|
1730
|
-
state2.pipes = dest;
|
|
1731
|
-
break;
|
|
1732
|
-
case 1:
|
|
1733
|
-
state2.pipes = [state2.pipes, dest];
|
|
1734
|
-
break;
|
|
1735
|
-
default:
|
|
1736
|
-
state2.pipes.push(dest);
|
|
1737
|
-
break;
|
|
1738
|
-
}
|
|
1739
|
-
state2.pipesCount += 1;
|
|
1740
|
-
debug("pipe count=%d opts=%j", state2.pipesCount, pipeOpts);
|
|
1741
|
-
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
|
|
1742
|
-
var endFn = doEnd ? onend : unpipe;
|
|
1743
|
-
if (state2.endEmitted)
|
|
1744
|
-
process.nextTick(endFn);
|
|
1745
|
-
else
|
|
1746
|
-
src.once("end", endFn);
|
|
1747
|
-
dest.on("unpipe", onunpipe);
|
|
1748
|
-
function onunpipe(readable, unpipeInfo) {
|
|
1749
|
-
debug("onunpipe");
|
|
1750
|
-
if (readable === src) {
|
|
1751
|
-
if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
|
|
1752
|
-
unpipeInfo.hasUnpiped = true;
|
|
1753
|
-
cleanup();
|
|
1754
|
-
}
|
|
1755
|
-
}
|
|
1756
|
-
}
|
|
1757
|
-
function onend() {
|
|
1758
|
-
debug("onend");
|
|
1759
|
-
dest.end();
|
|
1760
|
-
}
|
|
1761
|
-
var ondrain = pipeOnDrain(src);
|
|
1762
|
-
dest.on("drain", ondrain);
|
|
1763
|
-
var cleanedUp = false;
|
|
1764
|
-
function cleanup() {
|
|
1765
|
-
debug("cleanup");
|
|
1766
|
-
dest.removeListener("close", onclose);
|
|
1767
|
-
dest.removeListener("finish", onfinish);
|
|
1768
|
-
dest.removeListener("drain", ondrain);
|
|
1769
|
-
dest.removeListener("error", onerror);
|
|
1770
|
-
dest.removeListener("unpipe", onunpipe);
|
|
1771
|
-
src.removeListener("end", onend);
|
|
1772
|
-
src.removeListener("end", unpipe);
|
|
1773
|
-
src.removeListener("data", ondata);
|
|
1774
|
-
cleanedUp = true;
|
|
1775
|
-
if (state2.awaitDrain && (!dest._writableState || dest._writableState.needDrain))
|
|
1776
|
-
ondrain();
|
|
1777
|
-
}
|
|
1778
|
-
src.on("data", ondata);
|
|
1779
|
-
function ondata(chunk) {
|
|
1780
|
-
debug("ondata");
|
|
1781
|
-
var ret = dest.write(chunk);
|
|
1782
|
-
debug("dest.write", ret);
|
|
1783
|
-
if (ret === false) {
|
|
1784
|
-
if ((state2.pipesCount === 1 && state2.pipes === dest || state2.pipesCount > 1 && indexOf(state2.pipes, dest) !== -1) && !cleanedUp) {
|
|
1785
|
-
debug("false write response, pause", state2.awaitDrain);
|
|
1786
|
-
state2.awaitDrain++;
|
|
1787
|
-
}
|
|
1788
|
-
src.pause();
|
|
1789
|
-
}
|
|
1790
|
-
}
|
|
1791
|
-
function onerror(er) {
|
|
1792
|
-
debug("onerror", er);
|
|
1793
|
-
unpipe();
|
|
1794
|
-
dest.removeListener("error", onerror);
|
|
1795
|
-
if (EElistenerCount(dest, "error") === 0)
|
|
1796
|
-
errorOrDestroy2(dest, er);
|
|
1797
|
-
}
|
|
1798
|
-
prependListener(dest, "error", onerror);
|
|
1799
|
-
function onclose() {
|
|
1800
|
-
dest.removeListener("finish", onfinish);
|
|
1801
|
-
unpipe();
|
|
1802
|
-
}
|
|
1803
|
-
dest.once("close", onclose);
|
|
1804
|
-
function onfinish() {
|
|
1805
|
-
debug("onfinish");
|
|
1806
|
-
dest.removeListener("close", onclose);
|
|
1807
|
-
unpipe();
|
|
1808
|
-
}
|
|
1809
|
-
dest.once("finish", onfinish);
|
|
1810
|
-
function unpipe() {
|
|
1811
|
-
debug("unpipe");
|
|
1812
|
-
src.unpipe(dest);
|
|
1813
|
-
}
|
|
1814
|
-
dest.emit("pipe", src);
|
|
1815
|
-
if (!state2.flowing) {
|
|
1816
|
-
debug("pipe resume");
|
|
1817
|
-
src.resume();
|
|
1818
|
-
}
|
|
1819
|
-
return dest;
|
|
1820
|
-
};
|
|
1821
|
-
function pipeOnDrain(src) {
|
|
1822
|
-
return function pipeOnDrainFunctionResult() {
|
|
1823
|
-
var state2 = src._readableState;
|
|
1824
|
-
debug("pipeOnDrain", state2.awaitDrain);
|
|
1825
|
-
if (state2.awaitDrain)
|
|
1826
|
-
state2.awaitDrain--;
|
|
1827
|
-
if (state2.awaitDrain === 0 && EElistenerCount(src, "data")) {
|
|
1828
|
-
state2.flowing = true;
|
|
1829
|
-
flow(src);
|
|
1830
|
-
}
|
|
1831
|
-
};
|
|
1832
|
-
}
|
|
1833
|
-
Readable.prototype.unpipe = function(dest) {
|
|
1834
|
-
var state2 = this._readableState;
|
|
1835
|
-
var unpipeInfo = {
|
|
1836
|
-
hasUnpiped: false
|
|
1837
|
-
};
|
|
1838
|
-
if (state2.pipesCount === 0)
|
|
1839
|
-
return this;
|
|
1840
|
-
if (state2.pipesCount === 1) {
|
|
1841
|
-
if (dest && dest !== state2.pipes)
|
|
1842
|
-
return this;
|
|
1843
|
-
if (!dest)
|
|
1844
|
-
dest = state2.pipes;
|
|
1845
|
-
state2.pipes = null;
|
|
1846
|
-
state2.pipesCount = 0;
|
|
1847
|
-
state2.flowing = false;
|
|
1848
|
-
if (dest)
|
|
1849
|
-
dest.emit("unpipe", this, unpipeInfo);
|
|
1850
|
-
return this;
|
|
1851
|
-
}
|
|
1852
|
-
if (!dest) {
|
|
1853
|
-
var dests = state2.pipes;
|
|
1854
|
-
var len = state2.pipesCount;
|
|
1855
|
-
state2.pipes = null;
|
|
1856
|
-
state2.pipesCount = 0;
|
|
1857
|
-
state2.flowing = false;
|
|
1858
|
-
for (var i = 0; i < len; i++)
|
|
1859
|
-
dests[i].emit("unpipe", this, {
|
|
1860
|
-
hasUnpiped: false
|
|
1861
|
-
});
|
|
1862
|
-
return this;
|
|
1863
|
-
}
|
|
1864
|
-
var index = indexOf(state2.pipes, dest);
|
|
1865
|
-
if (index === -1)
|
|
1866
|
-
return this;
|
|
1867
|
-
state2.pipes.splice(index, 1);
|
|
1868
|
-
state2.pipesCount -= 1;
|
|
1869
|
-
if (state2.pipesCount === 1)
|
|
1870
|
-
state2.pipes = state2.pipes[0];
|
|
1871
|
-
dest.emit("unpipe", this, unpipeInfo);
|
|
1872
|
-
return this;
|
|
1873
|
-
};
|
|
1874
|
-
Readable.prototype.on = function(ev, fn) {
|
|
1875
|
-
var res = Stream.prototype.on.call(this, ev, fn);
|
|
1876
|
-
var state2 = this._readableState;
|
|
1877
|
-
if (ev === "data") {
|
|
1878
|
-
state2.readableListening = this.listenerCount("readable") > 0;
|
|
1879
|
-
if (state2.flowing !== false)
|
|
1880
|
-
this.resume();
|
|
1881
|
-
} else if (ev === "readable") {
|
|
1882
|
-
if (!state2.endEmitted && !state2.readableListening) {
|
|
1883
|
-
state2.readableListening = state2.needReadable = true;
|
|
1884
|
-
state2.flowing = false;
|
|
1885
|
-
state2.emittedReadable = false;
|
|
1886
|
-
debug("on readable", state2.length, state2.reading);
|
|
1887
|
-
if (state2.length) {
|
|
1888
|
-
emitReadable(this);
|
|
1889
|
-
} else if (!state2.reading) {
|
|
1890
|
-
process.nextTick(nReadingNextTick, this);
|
|
1891
|
-
}
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
return res;
|
|
1895
|
-
};
|
|
1896
|
-
Readable.prototype.addListener = Readable.prototype.on;
|
|
1897
|
-
Readable.prototype.removeListener = function(ev, fn) {
|
|
1898
|
-
var res = Stream.prototype.removeListener.call(this, ev, fn);
|
|
1899
|
-
if (ev === "readable") {
|
|
1900
|
-
process.nextTick(updateReadableListening, this);
|
|
1901
|
-
}
|
|
1902
|
-
return res;
|
|
1903
|
-
};
|
|
1904
|
-
Readable.prototype.removeAllListeners = function(ev) {
|
|
1905
|
-
var res = Stream.prototype.removeAllListeners.apply(this, arguments);
|
|
1906
|
-
if (ev === "readable" || ev === void 0) {
|
|
1907
|
-
process.nextTick(updateReadableListening, this);
|
|
1908
|
-
}
|
|
1909
|
-
return res;
|
|
1910
|
-
};
|
|
1911
|
-
function updateReadableListening(self2) {
|
|
1912
|
-
var state2 = self2._readableState;
|
|
1913
|
-
state2.readableListening = self2.listenerCount("readable") > 0;
|
|
1914
|
-
if (state2.resumeScheduled && !state2.paused) {
|
|
1915
|
-
state2.flowing = true;
|
|
1916
|
-
} else if (self2.listenerCount("data") > 0) {
|
|
1917
|
-
self2.resume();
|
|
1918
|
-
}
|
|
1919
|
-
}
|
|
1920
|
-
function nReadingNextTick(self2) {
|
|
1921
|
-
debug("readable nexttick read 0");
|
|
1922
|
-
self2.read(0);
|
|
1923
|
-
}
|
|
1924
|
-
Readable.prototype.resume = function() {
|
|
1925
|
-
var state2 = this._readableState;
|
|
1926
|
-
if (!state2.flowing) {
|
|
1927
|
-
debug("resume");
|
|
1928
|
-
state2.flowing = !state2.readableListening;
|
|
1929
|
-
resume(this, state2);
|
|
1930
|
-
}
|
|
1931
|
-
state2.paused = false;
|
|
1932
|
-
return this;
|
|
1933
|
-
};
|
|
1934
|
-
function resume(stream, state2) {
|
|
1935
|
-
if (!state2.resumeScheduled) {
|
|
1936
|
-
state2.resumeScheduled = true;
|
|
1937
|
-
process.nextTick(resume_, stream, state2);
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
1940
|
-
function resume_(stream, state2) {
|
|
1941
|
-
debug("resume", state2.reading);
|
|
1942
|
-
if (!state2.reading) {
|
|
1943
|
-
stream.read(0);
|
|
1944
|
-
}
|
|
1945
|
-
state2.resumeScheduled = false;
|
|
1946
|
-
stream.emit("resume");
|
|
1947
|
-
flow(stream);
|
|
1948
|
-
if (state2.flowing && !state2.reading)
|
|
1949
|
-
stream.read(0);
|
|
1950
|
-
}
|
|
1951
|
-
Readable.prototype.pause = function() {
|
|
1952
|
-
debug("call pause flowing=%j", this._readableState.flowing);
|
|
1953
|
-
if (this._readableState.flowing !== false) {
|
|
1954
|
-
debug("pause");
|
|
1955
|
-
this._readableState.flowing = false;
|
|
1956
|
-
this.emit("pause");
|
|
1957
|
-
}
|
|
1958
|
-
this._readableState.paused = true;
|
|
1959
|
-
return this;
|
|
1960
|
-
};
|
|
1961
|
-
function flow(stream) {
|
|
1962
|
-
var state2 = stream._readableState;
|
|
1963
|
-
debug("flow", state2.flowing);
|
|
1964
|
-
while (state2.flowing && stream.read() !== null)
|
|
1965
|
-
;
|
|
1966
|
-
}
|
|
1967
|
-
Readable.prototype.wrap = function(stream) {
|
|
1968
|
-
var _this = this;
|
|
1969
|
-
var state2 = this._readableState;
|
|
1970
|
-
var paused = false;
|
|
1971
|
-
stream.on("end", function() {
|
|
1972
|
-
debug("wrapped end");
|
|
1973
|
-
if (state2.decoder && !state2.ended) {
|
|
1974
|
-
var chunk = state2.decoder.end();
|
|
1975
|
-
if (chunk && chunk.length)
|
|
1976
|
-
_this.push(chunk);
|
|
1977
|
-
}
|
|
1978
|
-
_this.push(null);
|
|
1979
|
-
});
|
|
1980
|
-
stream.on("data", function(chunk) {
|
|
1981
|
-
debug("wrapped data");
|
|
1982
|
-
if (state2.decoder)
|
|
1983
|
-
chunk = state2.decoder.write(chunk);
|
|
1984
|
-
if (state2.objectMode && (chunk === null || chunk === void 0))
|
|
1985
|
-
return;
|
|
1986
|
-
else if (!state2.objectMode && (!chunk || !chunk.length))
|
|
1987
|
-
return;
|
|
1988
|
-
var ret = _this.push(chunk);
|
|
1989
|
-
if (!ret) {
|
|
1990
|
-
paused = true;
|
|
1991
|
-
stream.pause();
|
|
1992
|
-
}
|
|
1993
|
-
});
|
|
1994
|
-
for (var i in stream) {
|
|
1995
|
-
if (this[i] === void 0 && typeof stream[i] === "function") {
|
|
1996
|
-
this[i] = function methodWrap(method) {
|
|
1997
|
-
return function methodWrapReturnFunction() {
|
|
1998
|
-
return stream[method].apply(stream, arguments);
|
|
1999
|
-
};
|
|
2000
|
-
}(i);
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2003
|
-
for (var n = 0; n < kProxyEvents.length; n++) {
|
|
2004
|
-
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
|
|
2005
|
-
}
|
|
2006
|
-
this._read = function(n2) {
|
|
2007
|
-
debug("wrapped _read", n2);
|
|
2008
|
-
if (paused) {
|
|
2009
|
-
paused = false;
|
|
2010
|
-
stream.resume();
|
|
2011
|
-
}
|
|
2012
|
-
};
|
|
2013
|
-
return this;
|
|
2014
|
-
};
|
|
2015
|
-
if (typeof Symbol === "function") {
|
|
2016
|
-
Readable.prototype[Symbol.asyncIterator] = function() {
|
|
2017
|
-
if (createReadableStreamAsyncIterator === void 0) {
|
|
2018
|
-
createReadableStreamAsyncIterator = requireAsync_iterator();
|
|
2019
|
-
}
|
|
2020
|
-
return createReadableStreamAsyncIterator(this);
|
|
2021
|
-
};
|
|
2022
|
-
}
|
|
2023
|
-
Object.defineProperty(Readable.prototype, "readableHighWaterMark", {
|
|
2024
|
-
// making it explicit this property is not enumerable
|
|
2025
|
-
// because otherwise some prototype manipulation in
|
|
2026
|
-
// userland will fail
|
|
2027
|
-
enumerable: false,
|
|
2028
|
-
get: function get() {
|
|
2029
|
-
return this._readableState.highWaterMark;
|
|
2030
|
-
}
|
|
2031
|
-
});
|
|
2032
|
-
Object.defineProperty(Readable.prototype, "readableBuffer", {
|
|
2033
|
-
// making it explicit this property is not enumerable
|
|
2034
|
-
// because otherwise some prototype manipulation in
|
|
2035
|
-
// userland will fail
|
|
2036
|
-
enumerable: false,
|
|
2037
|
-
get: function get() {
|
|
2038
|
-
return this._readableState && this._readableState.buffer;
|
|
2039
|
-
}
|
|
2040
|
-
});
|
|
2041
|
-
Object.defineProperty(Readable.prototype, "readableFlowing", {
|
|
2042
|
-
// making it explicit this property is not enumerable
|
|
2043
|
-
// because otherwise some prototype manipulation in
|
|
2044
|
-
// userland will fail
|
|
2045
|
-
enumerable: false,
|
|
2046
|
-
get: function get() {
|
|
2047
|
-
return this._readableState.flowing;
|
|
2048
|
-
},
|
|
2049
|
-
set: function set(state2) {
|
|
2050
|
-
if (this._readableState) {
|
|
2051
|
-
this._readableState.flowing = state2;
|
|
2052
|
-
}
|
|
2053
|
-
}
|
|
2054
|
-
});
|
|
2055
|
-
Readable._fromList = fromList;
|
|
2056
|
-
Object.defineProperty(Readable.prototype, "readableLength", {
|
|
2057
|
-
// making it explicit this property is not enumerable
|
|
2058
|
-
// because otherwise some prototype manipulation in
|
|
2059
|
-
// userland will fail
|
|
2060
|
-
enumerable: false,
|
|
2061
|
-
get: function get() {
|
|
2062
|
-
return this._readableState.length;
|
|
2063
|
-
}
|
|
2064
|
-
});
|
|
2065
|
-
function fromList(n, state2) {
|
|
2066
|
-
if (state2.length === 0)
|
|
2067
|
-
return null;
|
|
2068
|
-
var ret;
|
|
2069
|
-
if (state2.objectMode)
|
|
2070
|
-
ret = state2.buffer.shift();
|
|
2071
|
-
else if (!n || n >= state2.length) {
|
|
2072
|
-
if (state2.decoder)
|
|
2073
|
-
ret = state2.buffer.join("");
|
|
2074
|
-
else if (state2.buffer.length === 1)
|
|
2075
|
-
ret = state2.buffer.first();
|
|
2076
|
-
else
|
|
2077
|
-
ret = state2.buffer.concat(state2.length);
|
|
2078
|
-
state2.buffer.clear();
|
|
2079
|
-
} else {
|
|
2080
|
-
ret = state2.buffer.consume(n, state2.decoder);
|
|
2081
|
-
}
|
|
2082
|
-
return ret;
|
|
2083
|
-
}
|
|
2084
|
-
function endReadable(stream) {
|
|
2085
|
-
var state2 = stream._readableState;
|
|
2086
|
-
debug("endReadable", state2.endEmitted);
|
|
2087
|
-
if (!state2.endEmitted) {
|
|
2088
|
-
state2.ended = true;
|
|
2089
|
-
process.nextTick(endReadableNT, state2, stream);
|
|
2090
|
-
}
|
|
2091
|
-
}
|
|
2092
|
-
function endReadableNT(state2, stream) {
|
|
2093
|
-
debug("endReadableNT", state2.endEmitted, state2.length);
|
|
2094
|
-
if (!state2.endEmitted && state2.length === 0) {
|
|
2095
|
-
state2.endEmitted = true;
|
|
2096
|
-
stream.readable = false;
|
|
2097
|
-
stream.emit("end");
|
|
2098
|
-
if (state2.autoDestroy) {
|
|
2099
|
-
var wState = stream._writableState;
|
|
2100
|
-
if (!wState || wState.autoDestroy && wState.finished) {
|
|
2101
|
-
stream.destroy();
|
|
2102
|
-
}
|
|
2103
|
-
}
|
|
2104
|
-
}
|
|
2105
|
-
}
|
|
2106
|
-
if (typeof Symbol === "function") {
|
|
2107
|
-
Readable.from = function(iterable, opts) {
|
|
2108
|
-
if (from === void 0) {
|
|
2109
|
-
from = requireFromBrowser();
|
|
2110
|
-
}
|
|
2111
|
-
return from(Readable, iterable, opts);
|
|
2112
|
-
};
|
|
2113
|
-
}
|
|
2114
|
-
function indexOf(xs, x) {
|
|
2115
|
-
for (var i = 0, l = xs.length; i < l; i++) {
|
|
2116
|
-
if (xs[i] === x)
|
|
2117
|
-
return i;
|
|
2118
|
-
}
|
|
2119
|
-
return -1;
|
|
2120
|
-
}
|
|
2121
|
-
return _stream_readable;
|
|
2122
|
-
}
|
|
2123
|
-
var _stream_duplex;
|
|
2124
|
-
var hasRequired_stream_duplex;
|
|
2125
|
-
function require_stream_duplex() {
|
|
2126
|
-
if (hasRequired_stream_duplex)
|
|
2127
|
-
return _stream_duplex;
|
|
2128
|
-
hasRequired_stream_duplex = 1;
|
|
2129
|
-
var objectKeys = Object.keys || function(obj) {
|
|
2130
|
-
var keys2 = [];
|
|
2131
|
-
for (var key in obj)
|
|
2132
|
-
keys2.push(key);
|
|
2133
|
-
return keys2;
|
|
2134
|
-
};
|
|
2135
|
-
_stream_duplex = Duplex;
|
|
2136
|
-
var Readable = require_stream_readable();
|
|
2137
|
-
var Writable = require_stream_writable();
|
|
2138
|
-
inherits_browserExports(Duplex, Readable);
|
|
2139
|
-
{
|
|
2140
|
-
var keys = objectKeys(Writable.prototype);
|
|
2141
|
-
for (var v = 0; v < keys.length; v++) {
|
|
2142
|
-
var method = keys[v];
|
|
2143
|
-
if (!Duplex.prototype[method])
|
|
2144
|
-
Duplex.prototype[method] = Writable.prototype[method];
|
|
2145
|
-
}
|
|
2146
|
-
}
|
|
2147
|
-
function Duplex(options) {
|
|
2148
|
-
if (!(this instanceof Duplex))
|
|
2149
|
-
return new Duplex(options);
|
|
2150
|
-
Readable.call(this, options);
|
|
2151
|
-
Writable.call(this, options);
|
|
2152
|
-
this.allowHalfOpen = true;
|
|
2153
|
-
if (options) {
|
|
2154
|
-
if (options.readable === false)
|
|
2155
|
-
this.readable = false;
|
|
2156
|
-
if (options.writable === false)
|
|
2157
|
-
this.writable = false;
|
|
2158
|
-
if (options.allowHalfOpen === false) {
|
|
2159
|
-
this.allowHalfOpen = false;
|
|
2160
|
-
this.once("end", onend);
|
|
2161
|
-
}
|
|
2162
|
-
}
|
|
2163
|
-
}
|
|
2164
|
-
Object.defineProperty(Duplex.prototype, "writableHighWaterMark", {
|
|
2165
|
-
// making it explicit this property is not enumerable
|
|
2166
|
-
// because otherwise some prototype manipulation in
|
|
2167
|
-
// userland will fail
|
|
2168
|
-
enumerable: false,
|
|
2169
|
-
get: function get() {
|
|
2170
|
-
return this._writableState.highWaterMark;
|
|
2171
|
-
}
|
|
2172
|
-
});
|
|
2173
|
-
Object.defineProperty(Duplex.prototype, "writableBuffer", {
|
|
2174
|
-
// making it explicit this property is not enumerable
|
|
2175
|
-
// because otherwise some prototype manipulation in
|
|
2176
|
-
// userland will fail
|
|
2177
|
-
enumerable: false,
|
|
2178
|
-
get: function get() {
|
|
2179
|
-
return this._writableState && this._writableState.getBuffer();
|
|
2180
|
-
}
|
|
2181
|
-
});
|
|
2182
|
-
Object.defineProperty(Duplex.prototype, "writableLength", {
|
|
2183
|
-
// making it explicit this property is not enumerable
|
|
2184
|
-
// because otherwise some prototype manipulation in
|
|
2185
|
-
// userland will fail
|
|
2186
|
-
enumerable: false,
|
|
2187
|
-
get: function get() {
|
|
2188
|
-
return this._writableState.length;
|
|
2189
|
-
}
|
|
2190
|
-
});
|
|
2191
|
-
function onend() {
|
|
2192
|
-
if (this._writableState.ended)
|
|
2193
|
-
return;
|
|
2194
|
-
process.nextTick(onEndNT, this);
|
|
2195
|
-
}
|
|
2196
|
-
function onEndNT(self2) {
|
|
2197
|
-
self2.end();
|
|
2198
|
-
}
|
|
2199
|
-
Object.defineProperty(Duplex.prototype, "destroyed", {
|
|
2200
|
-
// making it explicit this property is not enumerable
|
|
2201
|
-
// because otherwise some prototype manipulation in
|
|
2202
|
-
// userland will fail
|
|
2203
|
-
enumerable: false,
|
|
2204
|
-
get: function get() {
|
|
2205
|
-
if (this._readableState === void 0 || this._writableState === void 0) {
|
|
2206
|
-
return false;
|
|
2207
|
-
}
|
|
2208
|
-
return this._readableState.destroyed && this._writableState.destroyed;
|
|
2209
|
-
},
|
|
2210
|
-
set: function set(value) {
|
|
2211
|
-
if (this._readableState === void 0 || this._writableState === void 0) {
|
|
2212
|
-
return;
|
|
2213
|
-
}
|
|
2214
|
-
this._readableState.destroyed = value;
|
|
2215
|
-
this._writableState.destroyed = value;
|
|
2216
|
-
}
|
|
2217
|
-
});
|
|
2218
|
-
return _stream_duplex;
|
|
2219
|
-
}
|
|
2220
|
-
var _stream_writable;
|
|
2221
|
-
var hasRequired_stream_writable;
|
|
2222
|
-
function require_stream_writable() {
|
|
2223
|
-
if (hasRequired_stream_writable)
|
|
2224
|
-
return _stream_writable;
|
|
2225
|
-
hasRequired_stream_writable = 1;
|
|
2226
|
-
_stream_writable = Writable;
|
|
2227
|
-
function CorkedRequest(state2) {
|
|
2228
|
-
var _this = this;
|
|
2229
|
-
this.next = null;
|
|
2230
|
-
this.entry = null;
|
|
2231
|
-
this.finish = function() {
|
|
2232
|
-
onCorkedFinish(_this, state2);
|
|
2233
|
-
};
|
|
2234
|
-
}
|
|
2235
|
-
var Duplex;
|
|
2236
|
-
Writable.WritableState = WritableState;
|
|
2237
|
-
var internalUtil = {
|
|
2238
|
-
deprecate: browser
|
|
2239
|
-
};
|
|
2240
|
-
var Stream = streamBrowser;
|
|
2241
|
-
var Buffer2 = require$$0$1.Buffer;
|
|
2242
|
-
var OurUint8Array = (typeof commonjsGlobal !== "undefined" ? commonjsGlobal : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() {
|
|
2243
|
-
};
|
|
2244
|
-
function _uint8ArrayToBuffer(chunk) {
|
|
2245
|
-
return Buffer2.from(chunk);
|
|
2246
|
-
}
|
|
2247
|
-
function _isUint8Array(obj) {
|
|
2248
|
-
return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
2249
|
-
}
|
|
2250
|
-
var destroyImpl = destroy_1;
|
|
2251
|
-
var _require = state, getHighWaterMark2 = _require.getHighWaterMark;
|
|
2252
|
-
var _require$codes = errorsBrowser.codes, ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE, ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED, ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES, ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END, ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
|
|
2253
|
-
var errorOrDestroy2 = destroyImpl.errorOrDestroy;
|
|
2254
|
-
inherits_browserExports(Writable, Stream);
|
|
2255
|
-
function nop() {
|
|
2256
|
-
}
|
|
2257
|
-
function WritableState(options, stream, isDuplex) {
|
|
2258
|
-
Duplex = Duplex || require_stream_duplex();
|
|
2259
|
-
options = options || {};
|
|
2260
|
-
if (typeof isDuplex !== "boolean")
|
|
2261
|
-
isDuplex = stream instanceof Duplex;
|
|
2262
|
-
this.objectMode = !!options.objectMode;
|
|
2263
|
-
if (isDuplex)
|
|
2264
|
-
this.objectMode = this.objectMode || !!options.writableObjectMode;
|
|
2265
|
-
this.highWaterMark = getHighWaterMark2(this, options, "writableHighWaterMark", isDuplex);
|
|
2266
|
-
this.finalCalled = false;
|
|
2267
|
-
this.needDrain = false;
|
|
2268
|
-
this.ending = false;
|
|
2269
|
-
this.ended = false;
|
|
2270
|
-
this.finished = false;
|
|
2271
|
-
this.destroyed = false;
|
|
2272
|
-
var noDecode = options.decodeStrings === false;
|
|
2273
|
-
this.decodeStrings = !noDecode;
|
|
2274
|
-
this.defaultEncoding = options.defaultEncoding || "utf8";
|
|
2275
|
-
this.length = 0;
|
|
2276
|
-
this.writing = false;
|
|
2277
|
-
this.corked = 0;
|
|
2278
|
-
this.sync = true;
|
|
2279
|
-
this.bufferProcessing = false;
|
|
2280
|
-
this.onwrite = function(er) {
|
|
2281
|
-
onwrite(stream, er);
|
|
2282
|
-
};
|
|
2283
|
-
this.writecb = null;
|
|
2284
|
-
this.writelen = 0;
|
|
2285
|
-
this.bufferedRequest = null;
|
|
2286
|
-
this.lastBufferedRequest = null;
|
|
2287
|
-
this.pendingcb = 0;
|
|
2288
|
-
this.prefinished = false;
|
|
2289
|
-
this.errorEmitted = false;
|
|
2290
|
-
this.emitClose = options.emitClose !== false;
|
|
2291
|
-
this.autoDestroy = !!options.autoDestroy;
|
|
2292
|
-
this.bufferedRequestCount = 0;
|
|
2293
|
-
this.corkedRequestsFree = new CorkedRequest(this);
|
|
2294
|
-
}
|
|
2295
|
-
WritableState.prototype.getBuffer = function getBuffer() {
|
|
2296
|
-
var current = this.bufferedRequest;
|
|
2297
|
-
var out = [];
|
|
2298
|
-
while (current) {
|
|
2299
|
-
out.push(current);
|
|
2300
|
-
current = current.next;
|
|
2301
|
-
}
|
|
2302
|
-
return out;
|
|
2303
|
-
};
|
|
2304
|
-
(function() {
|
|
2305
|
-
try {
|
|
2306
|
-
Object.defineProperty(WritableState.prototype, "buffer", {
|
|
2307
|
-
get: internalUtil.deprecate(function writableStateBufferGetter() {
|
|
2308
|
-
return this.getBuffer();
|
|
2309
|
-
}, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003")
|
|
2310
|
-
});
|
|
2311
|
-
} catch (_) {
|
|
2312
|
-
}
|
|
2313
|
-
})();
|
|
2314
|
-
var realHasInstance;
|
|
2315
|
-
if (typeof Symbol === "function" && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === "function") {
|
|
2316
|
-
realHasInstance = Function.prototype[Symbol.hasInstance];
|
|
2317
|
-
Object.defineProperty(Writable, Symbol.hasInstance, {
|
|
2318
|
-
value: function value(object) {
|
|
2319
|
-
if (realHasInstance.call(this, object))
|
|
2320
|
-
return true;
|
|
2321
|
-
if (this !== Writable)
|
|
2322
|
-
return false;
|
|
2323
|
-
return object && object._writableState instanceof WritableState;
|
|
2324
|
-
}
|
|
2325
|
-
});
|
|
2326
|
-
} else {
|
|
2327
|
-
realHasInstance = function realHasInstance2(object) {
|
|
2328
|
-
return object instanceof this;
|
|
2329
|
-
};
|
|
2330
|
-
}
|
|
2331
|
-
function Writable(options) {
|
|
2332
|
-
Duplex = Duplex || require_stream_duplex();
|
|
2333
|
-
var isDuplex = this instanceof Duplex;
|
|
2334
|
-
if (!isDuplex && !realHasInstance.call(Writable, this))
|
|
2335
|
-
return new Writable(options);
|
|
2336
|
-
this._writableState = new WritableState(options, this, isDuplex);
|
|
2337
|
-
this.writable = true;
|
|
2338
|
-
if (options) {
|
|
2339
|
-
if (typeof options.write === "function")
|
|
2340
|
-
this._write = options.write;
|
|
2341
|
-
if (typeof options.writev === "function")
|
|
2342
|
-
this._writev = options.writev;
|
|
2343
|
-
if (typeof options.destroy === "function")
|
|
2344
|
-
this._destroy = options.destroy;
|
|
2345
|
-
if (typeof options.final === "function")
|
|
2346
|
-
this._final = options.final;
|
|
2347
|
-
}
|
|
2348
|
-
Stream.call(this);
|
|
2349
|
-
}
|
|
2350
|
-
Writable.prototype.pipe = function() {
|
|
2351
|
-
errorOrDestroy2(this, new ERR_STREAM_CANNOT_PIPE());
|
|
2352
|
-
};
|
|
2353
|
-
function writeAfterEnd(stream, cb) {
|
|
2354
|
-
var er = new ERR_STREAM_WRITE_AFTER_END();
|
|
2355
|
-
errorOrDestroy2(stream, er);
|
|
2356
|
-
process.nextTick(cb, er);
|
|
2357
|
-
}
|
|
2358
|
-
function validChunk(stream, state2, chunk, cb) {
|
|
2359
|
-
var er;
|
|
2360
|
-
if (chunk === null) {
|
|
2361
|
-
er = new ERR_STREAM_NULL_VALUES();
|
|
2362
|
-
} else if (typeof chunk !== "string" && !state2.objectMode) {
|
|
2363
|
-
er = new ERR_INVALID_ARG_TYPE("chunk", ["string", "Buffer"], chunk);
|
|
2364
|
-
}
|
|
2365
|
-
if (er) {
|
|
2366
|
-
errorOrDestroy2(stream, er);
|
|
2367
|
-
process.nextTick(cb, er);
|
|
2368
|
-
return false;
|
|
2369
|
-
}
|
|
2370
|
-
return true;
|
|
2371
|
-
}
|
|
2372
|
-
Writable.prototype.write = function(chunk, encoding, cb) {
|
|
2373
|
-
var state2 = this._writableState;
|
|
2374
|
-
var ret = false;
|
|
2375
|
-
var isBuf = !state2.objectMode && _isUint8Array(chunk);
|
|
2376
|
-
if (isBuf && !Buffer2.isBuffer(chunk)) {
|
|
2377
|
-
chunk = _uint8ArrayToBuffer(chunk);
|
|
2378
|
-
}
|
|
2379
|
-
if (typeof encoding === "function") {
|
|
2380
|
-
cb = encoding;
|
|
2381
|
-
encoding = null;
|
|
2382
|
-
}
|
|
2383
|
-
if (isBuf)
|
|
2384
|
-
encoding = "buffer";
|
|
2385
|
-
else if (!encoding)
|
|
2386
|
-
encoding = state2.defaultEncoding;
|
|
2387
|
-
if (typeof cb !== "function")
|
|
2388
|
-
cb = nop;
|
|
2389
|
-
if (state2.ending)
|
|
2390
|
-
writeAfterEnd(this, cb);
|
|
2391
|
-
else if (isBuf || validChunk(this, state2, chunk, cb)) {
|
|
2392
|
-
state2.pendingcb++;
|
|
2393
|
-
ret = writeOrBuffer(this, state2, isBuf, chunk, encoding, cb);
|
|
2394
|
-
}
|
|
2395
|
-
return ret;
|
|
2396
|
-
};
|
|
2397
|
-
Writable.prototype.cork = function() {
|
|
2398
|
-
this._writableState.corked++;
|
|
2399
|
-
};
|
|
2400
|
-
Writable.prototype.uncork = function() {
|
|
2401
|
-
var state2 = this._writableState;
|
|
2402
|
-
if (state2.corked) {
|
|
2403
|
-
state2.corked--;
|
|
2404
|
-
if (!state2.writing && !state2.corked && !state2.bufferProcessing && state2.bufferedRequest)
|
|
2405
|
-
clearBuffer(this, state2);
|
|
2406
|
-
}
|
|
2407
|
-
};
|
|
2408
|
-
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
|
2409
|
-
if (typeof encoding === "string")
|
|
2410
|
-
encoding = encoding.toLowerCase();
|
|
2411
|
-
if (!(["hex", "utf8", "utf-8", "ascii", "binary", "base64", "ucs2", "ucs-2", "utf16le", "utf-16le", "raw"].indexOf((encoding + "").toLowerCase()) > -1))
|
|
2412
|
-
throw new ERR_UNKNOWN_ENCODING(encoding);
|
|
2413
|
-
this._writableState.defaultEncoding = encoding;
|
|
2414
|
-
return this;
|
|
2415
|
-
};
|
|
2416
|
-
Object.defineProperty(Writable.prototype, "writableBuffer", {
|
|
2417
|
-
// making it explicit this property is not enumerable
|
|
2418
|
-
// because otherwise some prototype manipulation in
|
|
2419
|
-
// userland will fail
|
|
2420
|
-
enumerable: false,
|
|
2421
|
-
get: function get() {
|
|
2422
|
-
return this._writableState && this._writableState.getBuffer();
|
|
2423
|
-
}
|
|
2424
|
-
});
|
|
2425
|
-
function decodeChunk(state2, chunk, encoding) {
|
|
2426
|
-
if (!state2.objectMode && state2.decodeStrings !== false && typeof chunk === "string") {
|
|
2427
|
-
chunk = Buffer2.from(chunk, encoding);
|
|
2428
|
-
}
|
|
2429
|
-
return chunk;
|
|
2430
|
-
}
|
|
2431
|
-
Object.defineProperty(Writable.prototype, "writableHighWaterMark", {
|
|
2432
|
-
// making it explicit this property is not enumerable
|
|
2433
|
-
// because otherwise some prototype manipulation in
|
|
2434
|
-
// userland will fail
|
|
2435
|
-
enumerable: false,
|
|
2436
|
-
get: function get() {
|
|
2437
|
-
return this._writableState.highWaterMark;
|
|
2438
|
-
}
|
|
2439
|
-
});
|
|
2440
|
-
function writeOrBuffer(stream, state2, isBuf, chunk, encoding, cb) {
|
|
2441
|
-
if (!isBuf) {
|
|
2442
|
-
var newChunk = decodeChunk(state2, chunk, encoding);
|
|
2443
|
-
if (chunk !== newChunk) {
|
|
2444
|
-
isBuf = true;
|
|
2445
|
-
encoding = "buffer";
|
|
2446
|
-
chunk = newChunk;
|
|
2447
|
-
}
|
|
2448
|
-
}
|
|
2449
|
-
var len = state2.objectMode ? 1 : chunk.length;
|
|
2450
|
-
state2.length += len;
|
|
2451
|
-
var ret = state2.length < state2.highWaterMark;
|
|
2452
|
-
if (!ret)
|
|
2453
|
-
state2.needDrain = true;
|
|
2454
|
-
if (state2.writing || state2.corked) {
|
|
2455
|
-
var last = state2.lastBufferedRequest;
|
|
2456
|
-
state2.lastBufferedRequest = {
|
|
2457
|
-
chunk,
|
|
2458
|
-
encoding,
|
|
2459
|
-
isBuf,
|
|
2460
|
-
callback: cb,
|
|
2461
|
-
next: null
|
|
2462
|
-
};
|
|
2463
|
-
if (last) {
|
|
2464
|
-
last.next = state2.lastBufferedRequest;
|
|
2465
|
-
} else {
|
|
2466
|
-
state2.bufferedRequest = state2.lastBufferedRequest;
|
|
2467
|
-
}
|
|
2468
|
-
state2.bufferedRequestCount += 1;
|
|
2469
|
-
} else {
|
|
2470
|
-
doWrite(stream, state2, false, len, chunk, encoding, cb);
|
|
2471
|
-
}
|
|
2472
|
-
return ret;
|
|
2473
|
-
}
|
|
2474
|
-
function doWrite(stream, state2, writev, len, chunk, encoding, cb) {
|
|
2475
|
-
state2.writelen = len;
|
|
2476
|
-
state2.writecb = cb;
|
|
2477
|
-
state2.writing = true;
|
|
2478
|
-
state2.sync = true;
|
|
2479
|
-
if (state2.destroyed)
|
|
2480
|
-
state2.onwrite(new ERR_STREAM_DESTROYED("write"));
|
|
2481
|
-
else if (writev)
|
|
2482
|
-
stream._writev(chunk, state2.onwrite);
|
|
2483
|
-
else
|
|
2484
|
-
stream._write(chunk, encoding, state2.onwrite);
|
|
2485
|
-
state2.sync = false;
|
|
2486
|
-
}
|
|
2487
|
-
function onwriteError(stream, state2, sync, er, cb) {
|
|
2488
|
-
--state2.pendingcb;
|
|
2489
|
-
if (sync) {
|
|
2490
|
-
process.nextTick(cb, er);
|
|
2491
|
-
process.nextTick(finishMaybe, stream, state2);
|
|
2492
|
-
stream._writableState.errorEmitted = true;
|
|
2493
|
-
errorOrDestroy2(stream, er);
|
|
2494
|
-
} else {
|
|
2495
|
-
cb(er);
|
|
2496
|
-
stream._writableState.errorEmitted = true;
|
|
2497
|
-
errorOrDestroy2(stream, er);
|
|
2498
|
-
finishMaybe(stream, state2);
|
|
2499
|
-
}
|
|
2500
|
-
}
|
|
2501
|
-
function onwriteStateUpdate(state2) {
|
|
2502
|
-
state2.writing = false;
|
|
2503
|
-
state2.writecb = null;
|
|
2504
|
-
state2.length -= state2.writelen;
|
|
2505
|
-
state2.writelen = 0;
|
|
2506
|
-
}
|
|
2507
|
-
function onwrite(stream, er) {
|
|
2508
|
-
var state2 = stream._writableState;
|
|
2509
|
-
var sync = state2.sync;
|
|
2510
|
-
var cb = state2.writecb;
|
|
2511
|
-
if (typeof cb !== "function")
|
|
2512
|
-
throw new ERR_MULTIPLE_CALLBACK();
|
|
2513
|
-
onwriteStateUpdate(state2);
|
|
2514
|
-
if (er)
|
|
2515
|
-
onwriteError(stream, state2, sync, er, cb);
|
|
2516
|
-
else {
|
|
2517
|
-
var finished = needFinish(state2) || stream.destroyed;
|
|
2518
|
-
if (!finished && !state2.corked && !state2.bufferProcessing && state2.bufferedRequest) {
|
|
2519
|
-
clearBuffer(stream, state2);
|
|
2520
|
-
}
|
|
2521
|
-
if (sync) {
|
|
2522
|
-
process.nextTick(afterWrite, stream, state2, finished, cb);
|
|
2523
|
-
} else {
|
|
2524
|
-
afterWrite(stream, state2, finished, cb);
|
|
2525
|
-
}
|
|
2526
|
-
}
|
|
2527
|
-
}
|
|
2528
|
-
function afterWrite(stream, state2, finished, cb) {
|
|
2529
|
-
if (!finished)
|
|
2530
|
-
onwriteDrain(stream, state2);
|
|
2531
|
-
state2.pendingcb--;
|
|
2532
|
-
cb();
|
|
2533
|
-
finishMaybe(stream, state2);
|
|
2534
|
-
}
|
|
2535
|
-
function onwriteDrain(stream, state2) {
|
|
2536
|
-
if (state2.length === 0 && state2.needDrain) {
|
|
2537
|
-
state2.needDrain = false;
|
|
2538
|
-
stream.emit("drain");
|
|
2539
|
-
}
|
|
2540
|
-
}
|
|
2541
|
-
function clearBuffer(stream, state2) {
|
|
2542
|
-
state2.bufferProcessing = true;
|
|
2543
|
-
var entry = state2.bufferedRequest;
|
|
2544
|
-
if (stream._writev && entry && entry.next) {
|
|
2545
|
-
var l = state2.bufferedRequestCount;
|
|
2546
|
-
var buffer = new Array(l);
|
|
2547
|
-
var holder = state2.corkedRequestsFree;
|
|
2548
|
-
holder.entry = entry;
|
|
2549
|
-
var count = 0;
|
|
2550
|
-
var allBuffers = true;
|
|
2551
|
-
while (entry) {
|
|
2552
|
-
buffer[count] = entry;
|
|
2553
|
-
if (!entry.isBuf)
|
|
2554
|
-
allBuffers = false;
|
|
2555
|
-
entry = entry.next;
|
|
2556
|
-
count += 1;
|
|
2557
|
-
}
|
|
2558
|
-
buffer.allBuffers = allBuffers;
|
|
2559
|
-
doWrite(stream, state2, true, state2.length, buffer, "", holder.finish);
|
|
2560
|
-
state2.pendingcb++;
|
|
2561
|
-
state2.lastBufferedRequest = null;
|
|
2562
|
-
if (holder.next) {
|
|
2563
|
-
state2.corkedRequestsFree = holder.next;
|
|
2564
|
-
holder.next = null;
|
|
2565
|
-
} else {
|
|
2566
|
-
state2.corkedRequestsFree = new CorkedRequest(state2);
|
|
2567
|
-
}
|
|
2568
|
-
state2.bufferedRequestCount = 0;
|
|
2569
|
-
} else {
|
|
2570
|
-
while (entry) {
|
|
2571
|
-
var chunk = entry.chunk;
|
|
2572
|
-
var encoding = entry.encoding;
|
|
2573
|
-
var cb = entry.callback;
|
|
2574
|
-
var len = state2.objectMode ? 1 : chunk.length;
|
|
2575
|
-
doWrite(stream, state2, false, len, chunk, encoding, cb);
|
|
2576
|
-
entry = entry.next;
|
|
2577
|
-
state2.bufferedRequestCount--;
|
|
2578
|
-
if (state2.writing) {
|
|
2579
|
-
break;
|
|
2580
|
-
}
|
|
2581
|
-
}
|
|
2582
|
-
if (entry === null)
|
|
2583
|
-
state2.lastBufferedRequest = null;
|
|
2584
|
-
}
|
|
2585
|
-
state2.bufferedRequest = entry;
|
|
2586
|
-
state2.bufferProcessing = false;
|
|
2587
|
-
}
|
|
2588
|
-
Writable.prototype._write = function(chunk, encoding, cb) {
|
|
2589
|
-
cb(new ERR_METHOD_NOT_IMPLEMENTED("_write()"));
|
|
2590
|
-
};
|
|
2591
|
-
Writable.prototype._writev = null;
|
|
2592
|
-
Writable.prototype.end = function(chunk, encoding, cb) {
|
|
2593
|
-
var state2 = this._writableState;
|
|
2594
|
-
if (typeof chunk === "function") {
|
|
2595
|
-
cb = chunk;
|
|
2596
|
-
chunk = null;
|
|
2597
|
-
encoding = null;
|
|
2598
|
-
} else if (typeof encoding === "function") {
|
|
2599
|
-
cb = encoding;
|
|
2600
|
-
encoding = null;
|
|
2601
|
-
}
|
|
2602
|
-
if (chunk !== null && chunk !== void 0)
|
|
2603
|
-
this.write(chunk, encoding);
|
|
2604
|
-
if (state2.corked) {
|
|
2605
|
-
state2.corked = 1;
|
|
2606
|
-
this.uncork();
|
|
2607
|
-
}
|
|
2608
|
-
if (!state2.ending)
|
|
2609
|
-
endWritable(this, state2, cb);
|
|
2610
|
-
return this;
|
|
2611
|
-
};
|
|
2612
|
-
Object.defineProperty(Writable.prototype, "writableLength", {
|
|
2613
|
-
// making it explicit this property is not enumerable
|
|
2614
|
-
// because otherwise some prototype manipulation in
|
|
2615
|
-
// userland will fail
|
|
2616
|
-
enumerable: false,
|
|
2617
|
-
get: function get() {
|
|
2618
|
-
return this._writableState.length;
|
|
2619
|
-
}
|
|
2620
|
-
});
|
|
2621
|
-
function needFinish(state2) {
|
|
2622
|
-
return state2.ending && state2.length === 0 && state2.bufferedRequest === null && !state2.finished && !state2.writing;
|
|
2623
|
-
}
|
|
2624
|
-
function callFinal(stream, state2) {
|
|
2625
|
-
stream._final(function(err) {
|
|
2626
|
-
state2.pendingcb--;
|
|
2627
|
-
if (err) {
|
|
2628
|
-
errorOrDestroy2(stream, err);
|
|
2629
|
-
}
|
|
2630
|
-
state2.prefinished = true;
|
|
2631
|
-
stream.emit("prefinish");
|
|
2632
|
-
finishMaybe(stream, state2);
|
|
2633
|
-
});
|
|
2634
|
-
}
|
|
2635
|
-
function prefinish(stream, state2) {
|
|
2636
|
-
if (!state2.prefinished && !state2.finalCalled) {
|
|
2637
|
-
if (typeof stream._final === "function" && !state2.destroyed) {
|
|
2638
|
-
state2.pendingcb++;
|
|
2639
|
-
state2.finalCalled = true;
|
|
2640
|
-
process.nextTick(callFinal, stream, state2);
|
|
2641
|
-
} else {
|
|
2642
|
-
state2.prefinished = true;
|
|
2643
|
-
stream.emit("prefinish");
|
|
2644
|
-
}
|
|
2645
|
-
}
|
|
2646
|
-
}
|
|
2647
|
-
function finishMaybe(stream, state2) {
|
|
2648
|
-
var need = needFinish(state2);
|
|
2649
|
-
if (need) {
|
|
2650
|
-
prefinish(stream, state2);
|
|
2651
|
-
if (state2.pendingcb === 0) {
|
|
2652
|
-
state2.finished = true;
|
|
2653
|
-
stream.emit("finish");
|
|
2654
|
-
if (state2.autoDestroy) {
|
|
2655
|
-
var rState = stream._readableState;
|
|
2656
|
-
if (!rState || rState.autoDestroy && rState.endEmitted) {
|
|
2657
|
-
stream.destroy();
|
|
2658
|
-
}
|
|
2659
|
-
}
|
|
2660
|
-
}
|
|
2661
|
-
}
|
|
2662
|
-
return need;
|
|
2663
|
-
}
|
|
2664
|
-
function endWritable(stream, state2, cb) {
|
|
2665
|
-
state2.ending = true;
|
|
2666
|
-
finishMaybe(stream, state2);
|
|
2667
|
-
if (cb) {
|
|
2668
|
-
if (state2.finished)
|
|
2669
|
-
process.nextTick(cb);
|
|
2670
|
-
else
|
|
2671
|
-
stream.once("finish", cb);
|
|
2672
|
-
}
|
|
2673
|
-
state2.ended = true;
|
|
2674
|
-
stream.writable = false;
|
|
2675
|
-
}
|
|
2676
|
-
function onCorkedFinish(corkReq, state2, err) {
|
|
2677
|
-
var entry = corkReq.entry;
|
|
2678
|
-
corkReq.entry = null;
|
|
2679
|
-
while (entry) {
|
|
2680
|
-
var cb = entry.callback;
|
|
2681
|
-
state2.pendingcb--;
|
|
2682
|
-
cb(err);
|
|
2683
|
-
entry = entry.next;
|
|
2684
|
-
}
|
|
2685
|
-
state2.corkedRequestsFree.next = corkReq;
|
|
2686
|
-
}
|
|
2687
|
-
Object.defineProperty(Writable.prototype, "destroyed", {
|
|
2688
|
-
// making it explicit this property is not enumerable
|
|
2689
|
-
// because otherwise some prototype manipulation in
|
|
2690
|
-
// userland will fail
|
|
2691
|
-
enumerable: false,
|
|
2692
|
-
get: function get() {
|
|
2693
|
-
if (this._writableState === void 0) {
|
|
2694
|
-
return false;
|
|
2695
|
-
}
|
|
2696
|
-
return this._writableState.destroyed;
|
|
2697
|
-
},
|
|
2698
|
-
set: function set(value) {
|
|
2699
|
-
if (!this._writableState) {
|
|
2700
|
-
return;
|
|
2701
|
-
}
|
|
2702
|
-
this._writableState.destroyed = value;
|
|
2703
|
-
}
|
|
2704
|
-
});
|
|
2705
|
-
Writable.prototype.destroy = destroyImpl.destroy;
|
|
2706
|
-
Writable.prototype._undestroy = destroyImpl.undestroy;
|
|
2707
|
-
Writable.prototype._destroy = function(err, cb) {
|
|
2708
|
-
cb(err);
|
|
2709
|
-
};
|
|
2710
|
-
return _stream_writable;
|
|
2711
|
-
}
|
|
2712
|
-
var tripleBeam = {};
|
|
2713
|
-
var config = {};
|
|
2714
|
-
var cli = {};
|
|
2715
|
-
cli.levels = {
|
|
2716
|
-
error: 0,
|
|
2717
|
-
warn: 1,
|
|
2718
|
-
help: 2,
|
|
2719
|
-
data: 3,
|
|
2720
|
-
info: 4,
|
|
2721
|
-
debug: 5,
|
|
2722
|
-
prompt: 6,
|
|
2723
|
-
verbose: 7,
|
|
2724
|
-
input: 8,
|
|
2725
|
-
silly: 9
|
|
2726
|
-
};
|
|
2727
|
-
cli.colors = {
|
|
2728
|
-
error: "red",
|
|
2729
|
-
warn: "yellow",
|
|
2730
|
-
help: "cyan",
|
|
2731
|
-
data: "grey",
|
|
2732
|
-
info: "green",
|
|
2733
|
-
debug: "blue",
|
|
2734
|
-
prompt: "grey",
|
|
2735
|
-
verbose: "cyan",
|
|
2736
|
-
input: "grey",
|
|
2737
|
-
silly: "magenta"
|
|
2738
|
-
};
|
|
2739
|
-
var npm = {};
|
|
2740
|
-
npm.levels = {
|
|
2741
|
-
error: 0,
|
|
2742
|
-
warn: 1,
|
|
2743
|
-
info: 2,
|
|
2744
|
-
http: 3,
|
|
2745
|
-
verbose: 4,
|
|
2746
|
-
debug: 5,
|
|
2747
|
-
silly: 6
|
|
2748
|
-
};
|
|
2749
|
-
npm.colors = {
|
|
2750
|
-
error: "red",
|
|
2751
|
-
warn: "yellow",
|
|
2752
|
-
info: "green",
|
|
2753
|
-
http: "green",
|
|
2754
|
-
verbose: "cyan",
|
|
2755
|
-
debug: "blue",
|
|
2756
|
-
silly: "magenta"
|
|
2757
|
-
};
|
|
2758
|
-
var syslog = {};
|
|
2759
|
-
syslog.levels = {
|
|
2760
|
-
emerg: 0,
|
|
2761
|
-
alert: 1,
|
|
2762
|
-
crit: 2,
|
|
2763
|
-
error: 3,
|
|
2764
|
-
warning: 4,
|
|
2765
|
-
notice: 5,
|
|
2766
|
-
info: 6,
|
|
2767
|
-
debug: 7
|
|
2768
|
-
};
|
|
2769
|
-
syslog.colors = {
|
|
2770
|
-
emerg: "red",
|
|
2771
|
-
alert: "yellow",
|
|
2772
|
-
crit: "red",
|
|
2773
|
-
error: "red",
|
|
2774
|
-
warning: "red",
|
|
2775
|
-
notice: "yellow",
|
|
2776
|
-
info: "green",
|
|
2777
|
-
debug: "blue"
|
|
2778
|
-
};
|
|
2779
|
-
(function(exports) {
|
|
2780
|
-
Object.defineProperty(exports, "cli", {
|
|
2781
|
-
value: cli
|
|
2782
|
-
});
|
|
2783
|
-
Object.defineProperty(exports, "npm", {
|
|
2784
|
-
value: npm
|
|
2785
|
-
});
|
|
2786
|
-
Object.defineProperty(exports, "syslog", {
|
|
2787
|
-
value: syslog
|
|
2788
|
-
});
|
|
2789
|
-
})(config);
|
|
2790
|
-
(function(exports) {
|
|
2791
|
-
Object.defineProperty(exports, "LEVEL", {
|
|
2792
|
-
value: Symbol.for("level")
|
|
2793
|
-
});
|
|
2794
|
-
Object.defineProperty(exports, "MESSAGE", {
|
|
2795
|
-
value: Symbol.for("message")
|
|
2796
|
-
});
|
|
2797
|
-
Object.defineProperty(exports, "SPLAT", {
|
|
2798
|
-
value: Symbol.for("splat")
|
|
2799
|
-
});
|
|
2800
|
-
Object.defineProperty(exports, "configs", {
|
|
2801
|
-
value: config
|
|
2802
|
-
});
|
|
2803
|
-
})(tripleBeam);
|
|
2804
|
-
var legacy = { exports: {} };
|
|
2805
|
-
var hasRequiredLegacy;
|
|
2806
|
-
function requireLegacy() {
|
|
2807
|
-
if (hasRequiredLegacy)
|
|
2808
|
-
return legacy.exports;
|
|
2809
|
-
hasRequiredLegacy = 1;
|
|
2810
|
-
var util = require$$0$2;
|
|
2811
|
-
var _require = tripleBeam, LEVEL = _require.LEVEL;
|
|
2812
|
-
var TransportStream = requireDist();
|
|
2813
|
-
var LegacyTransportStream = legacy.exports = function LegacyTransportStream2() {
|
|
2814
|
-
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
2815
|
-
TransportStream.call(this, options);
|
|
2816
|
-
if (!options.transport || typeof options.transport.log !== "function") {
|
|
2817
|
-
throw new Error("Invalid transport, must be an object with a log method.");
|
|
2818
|
-
}
|
|
2819
|
-
this.transport = options.transport;
|
|
2820
|
-
this.level = this.level || options.transport.level;
|
|
2821
|
-
this.handleExceptions = this.handleExceptions || options.transport.handleExceptions;
|
|
2822
|
-
this._deprecated();
|
|
2823
|
-
function transportError(err) {
|
|
2824
|
-
this.emit("error", err, this.transport);
|
|
2825
|
-
}
|
|
2826
|
-
if (!this.transport.__winstonError) {
|
|
2827
|
-
this.transport.__winstonError = transportError.bind(this);
|
|
2828
|
-
this.transport.on("error", this.transport.__winstonError);
|
|
2829
|
-
}
|
|
2830
|
-
};
|
|
2831
|
-
util.inherits(LegacyTransportStream, TransportStream);
|
|
2832
|
-
LegacyTransportStream.prototype._write = function _write(info, enc, callback) {
|
|
2833
|
-
if (this.silent || info.exception === true && !this.handleExceptions) {
|
|
2834
|
-
return callback(null);
|
|
2835
|
-
}
|
|
2836
|
-
if (!this.level || this.levels[this.level] >= this.levels[info[LEVEL]]) {
|
|
2837
|
-
this.transport.log(info[LEVEL], info.message, info, this._nop);
|
|
2838
|
-
}
|
|
2839
|
-
callback(null);
|
|
2840
|
-
};
|
|
2841
|
-
LegacyTransportStream.prototype._writev = function _writev(chunks, callback) {
|
|
2842
|
-
for (var i = 0; i < chunks.length; i++) {
|
|
2843
|
-
if (this._accept(chunks[i])) {
|
|
2844
|
-
this.transport.log(chunks[i].chunk[LEVEL], chunks[i].chunk.message, chunks[i].chunk, this._nop);
|
|
2845
|
-
chunks[i].callback();
|
|
2846
|
-
}
|
|
2847
|
-
}
|
|
2848
|
-
return callback(null);
|
|
2849
|
-
};
|
|
2850
|
-
LegacyTransportStream.prototype._deprecated = function _deprecated() {
|
|
2851
|
-
console.error([this.transport.name + " is a legacy winston transport. Consider upgrading: ", "- Upgrade docs: https://github.com/winstonjs/winston/blob/master/UPGRADE-3.0.md"].join("\n"));
|
|
2852
|
-
};
|
|
2853
|
-
LegacyTransportStream.prototype.close = function close() {
|
|
2854
|
-
if (this.transport.close) {
|
|
2855
|
-
this.transport.close();
|
|
2856
|
-
}
|
|
2857
|
-
if (this.transport.__winstonError) {
|
|
2858
|
-
this.transport.removeListener("error", this.transport.__winstonError);
|
|
2859
|
-
this.transport.__winstonError = null;
|
|
2860
|
-
}
|
|
2861
|
-
};
|
|
2862
|
-
return legacy.exports;
|
|
2863
|
-
}
|
|
2864
|
-
var hasRequiredDist;
|
|
2865
|
-
function requireDist() {
|
|
2866
|
-
if (hasRequiredDist)
|
|
2867
|
-
return dist.exports;
|
|
2868
|
-
hasRequiredDist = 1;
|
|
2869
|
-
var util = require$$0$2;
|
|
2870
|
-
var Writable = require_stream_writable();
|
|
2871
|
-
var _require = tripleBeam, LEVEL = _require.LEVEL;
|
|
2872
|
-
var TransportStream = dist.exports = function TransportStream2() {
|
|
2873
|
-
var _this = this;
|
|
2874
|
-
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
2875
|
-
Writable.call(this, { objectMode: true, highWaterMark: options.highWaterMark });
|
|
2876
|
-
this.format = options.format;
|
|
2877
|
-
this.level = options.level;
|
|
2878
|
-
this.handleExceptions = options.handleExceptions;
|
|
2879
|
-
this.handleRejections = options.handleRejections;
|
|
2880
|
-
this.silent = options.silent;
|
|
2881
|
-
if (options.log)
|
|
2882
|
-
this.log = options.log;
|
|
2883
|
-
if (options.logv)
|
|
2884
|
-
this.logv = options.logv;
|
|
2885
|
-
if (options.close)
|
|
2886
|
-
this.close = options.close;
|
|
2887
|
-
this.once("pipe", function(logger) {
|
|
2888
|
-
_this.levels = logger.levels;
|
|
2889
|
-
_this.parent = logger;
|
|
2890
|
-
});
|
|
2891
|
-
this.once("unpipe", function(src) {
|
|
2892
|
-
if (src === _this.parent) {
|
|
2893
|
-
_this.parent = null;
|
|
2894
|
-
if (_this.close) {
|
|
2895
|
-
_this.close();
|
|
2896
|
-
}
|
|
2897
|
-
}
|
|
2898
|
-
});
|
|
2899
|
-
};
|
|
2900
|
-
util.inherits(TransportStream, Writable);
|
|
2901
|
-
TransportStream.prototype._write = function _write(info, enc, callback) {
|
|
2902
|
-
if (this.silent || info.exception === true && !this.handleExceptions) {
|
|
2903
|
-
return callback(null);
|
|
2904
|
-
}
|
|
2905
|
-
var level = this.level || this.parent && this.parent.level;
|
|
2906
|
-
if (!level || this.levels[level] >= this.levels[info[LEVEL]]) {
|
|
2907
|
-
if (info && !this.format) {
|
|
2908
|
-
return this.log(info, callback);
|
|
2909
|
-
}
|
|
2910
|
-
var errState = void 0;
|
|
2911
|
-
var transformed = void 0;
|
|
2912
|
-
try {
|
|
2913
|
-
transformed = this.format.transform(Object.assign({}, info), this.format.options);
|
|
2914
|
-
} catch (err) {
|
|
2915
|
-
errState = err;
|
|
2916
|
-
}
|
|
2917
|
-
if (errState || !transformed) {
|
|
2918
|
-
callback();
|
|
2919
|
-
if (errState)
|
|
2920
|
-
throw errState;
|
|
2921
|
-
return;
|
|
2922
|
-
}
|
|
2923
|
-
return this.log(transformed, callback);
|
|
2924
|
-
}
|
|
2925
|
-
this._writableState.sync = false;
|
|
2926
|
-
return callback(null);
|
|
2927
|
-
};
|
|
2928
|
-
TransportStream.prototype._writev = function _writev(chunks, callback) {
|
|
2929
|
-
if (this.logv) {
|
|
2930
|
-
var infos = chunks.filter(this._accept, this);
|
|
2931
|
-
if (!infos.length) {
|
|
2932
|
-
return callback(null);
|
|
2933
|
-
}
|
|
2934
|
-
return this.logv(infos, callback);
|
|
2935
|
-
}
|
|
2936
|
-
for (var i = 0; i < chunks.length; i++) {
|
|
2937
|
-
if (!this._accept(chunks[i]))
|
|
2938
|
-
continue;
|
|
2939
|
-
if (chunks[i].chunk && !this.format) {
|
|
2940
|
-
this.log(chunks[i].chunk, chunks[i].callback);
|
|
2941
|
-
continue;
|
|
2942
|
-
}
|
|
2943
|
-
var errState = void 0;
|
|
2944
|
-
var transformed = void 0;
|
|
2945
|
-
try {
|
|
2946
|
-
transformed = this.format.transform(Object.assign({}, chunks[i].chunk), this.format.options);
|
|
2947
|
-
} catch (err) {
|
|
2948
|
-
errState = err;
|
|
2949
|
-
}
|
|
2950
|
-
if (errState || !transformed) {
|
|
2951
|
-
chunks[i].callback();
|
|
2952
|
-
if (errState) {
|
|
2953
|
-
callback(null);
|
|
2954
|
-
throw errState;
|
|
2955
|
-
}
|
|
2956
|
-
} else {
|
|
2957
|
-
this.log(transformed, chunks[i].callback);
|
|
2958
|
-
}
|
|
2959
|
-
}
|
|
2960
|
-
return callback(null);
|
|
2961
|
-
};
|
|
2962
|
-
TransportStream.prototype._accept = function _accept(write) {
|
|
2963
|
-
var info = write.chunk;
|
|
2964
|
-
if (this.silent) {
|
|
2965
|
-
return false;
|
|
2966
|
-
}
|
|
2967
|
-
var level = this.level || this.parent && this.parent.level;
|
|
2968
|
-
if (info.exception === true || !level || this.levels[level] >= this.levels[info[LEVEL]]) {
|
|
2969
|
-
if (this.handleExceptions || info.exception !== true) {
|
|
2970
|
-
return true;
|
|
2971
|
-
}
|
|
2972
|
-
}
|
|
2973
|
-
return false;
|
|
2974
|
-
};
|
|
2975
|
-
TransportStream.prototype._nop = function _nop() {
|
|
2976
|
-
return void 0;
|
|
2977
|
-
};
|
|
2978
|
-
dist.exports.LegacyTransportStream = requireLegacy();
|
|
2979
|
-
return dist.exports;
|
|
2980
|
-
}
|
|
2981
|
-
var distExports = requireDist();
|
|
2982
|
-
const Transport = /* @__PURE__ */ getDefaultExportFromCjs(distExports);
|
|
2983
|
-
class STSWinstonTransport extends Transport {
|
|
2984
|
-
constructor(opts) {
|
|
2985
|
-
super(opts);
|
|
2986
|
-
__publicField(this, "myopts");
|
|
2987
|
-
this.myopts = opts;
|
|
2988
|
-
}
|
|
2989
|
-
get debugger() {
|
|
2990
|
-
return this.myopts.debugger;
|
|
2991
|
-
}
|
|
2992
|
-
set debugger(newDebugger) {
|
|
2993
|
-
this.myopts.debugger = newDebugger;
|
|
2994
|
-
}
|
|
2995
|
-
log(info, callback) {
|
|
2996
|
-
if (info[Symbol.for("level")] == "debug") {
|
|
2997
|
-
if (this.myopts.debugger) {
|
|
2998
|
-
this.myopts.debugger(info.message);
|
|
2999
|
-
}
|
|
3000
|
-
}
|
|
3001
|
-
this.emit("logged", info);
|
|
3002
|
-
callback();
|
|
3003
|
-
}
|
|
3004
|
-
}
|
|
3005
170
|
var ModelDelimeter = /* @__PURE__ */ ((ModelDelimeter2) => {
|
|
3006
171
|
ModelDelimeter2["ROOT"] = "_";
|
|
3007
172
|
ModelDelimeter2["SEPERATOR"] = "|";
|
|
@@ -3036,7 +201,6 @@ export {
|
|
|
3036
201
|
OIDCAddressClaim,
|
|
3037
202
|
OIDCStandardClaim,
|
|
3038
203
|
STSOptionsBase,
|
|
3039
|
-
STSWinstonTransport,
|
|
3040
204
|
Sleep,
|
|
3041
205
|
Validate,
|
|
3042
206
|
compareParameterTypes
|