genesys-cloud-streaming-client 13.4.2-branch.develop.1 → 13.4.2-branch.develop.2
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/es/index.bundle.js
CHANGED
|
@@ -9686,7 +9686,7 @@ var _polyfillNode_punycode = /*#__PURE__*/Object.freeze({
|
|
|
9686
9686
|
'default': Punycode
|
|
9687
9687
|
});
|
|
9688
9688
|
|
|
9689
|
-
var readableBrowser
|
|
9689
|
+
var readableBrowser = {exports: {}};
|
|
9690
9690
|
|
|
9691
9691
|
var processNextickArgs = {exports: {}};
|
|
9692
9692
|
|
|
@@ -9740,30 +9740,30 @@ function requireProcessNextickArgs () {
|
|
|
9740
9740
|
return processNextickArgs.exports;
|
|
9741
9741
|
}
|
|
9742
9742
|
|
|
9743
|
-
var isarray
|
|
9744
|
-
var hasRequiredIsarray
|
|
9743
|
+
var isarray;
|
|
9744
|
+
var hasRequiredIsarray;
|
|
9745
9745
|
|
|
9746
|
-
function requireIsarray
|
|
9747
|
-
if (hasRequiredIsarray
|
|
9748
|
-
hasRequiredIsarray
|
|
9746
|
+
function requireIsarray () {
|
|
9747
|
+
if (hasRequiredIsarray) return isarray;
|
|
9748
|
+
hasRequiredIsarray = 1;
|
|
9749
9749
|
var toString = {}.toString;
|
|
9750
9750
|
|
|
9751
|
-
isarray
|
|
9751
|
+
isarray = Array.isArray || function (arr) {
|
|
9752
9752
|
return toString.call(arr) == '[object Array]';
|
|
9753
9753
|
};
|
|
9754
|
-
return isarray
|
|
9754
|
+
return isarray;
|
|
9755
9755
|
}
|
|
9756
9756
|
|
|
9757
9757
|
var require$$0$3 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_events);
|
|
9758
9758
|
|
|
9759
|
-
var streamBrowser
|
|
9760
|
-
var hasRequiredStreamBrowser
|
|
9759
|
+
var streamBrowser;
|
|
9760
|
+
var hasRequiredStreamBrowser;
|
|
9761
9761
|
|
|
9762
|
-
function requireStreamBrowser
|
|
9763
|
-
if (hasRequiredStreamBrowser
|
|
9764
|
-
hasRequiredStreamBrowser
|
|
9765
|
-
streamBrowser
|
|
9766
|
-
return streamBrowser
|
|
9762
|
+
function requireStreamBrowser () {
|
|
9763
|
+
if (hasRequiredStreamBrowser) return streamBrowser;
|
|
9764
|
+
hasRequiredStreamBrowser = 1;
|
|
9765
|
+
streamBrowser = require$$0$3.EventEmitter;
|
|
9766
|
+
return streamBrowser;
|
|
9767
9767
|
}
|
|
9768
9768
|
|
|
9769
9769
|
var safeBuffer = {exports: {}};
|
|
@@ -9843,7 +9843,7 @@ function requireSafeBuffer () {
|
|
|
9843
9843
|
return safeBuffer.exports;
|
|
9844
9844
|
}
|
|
9845
9845
|
|
|
9846
|
-
var util$
|
|
9846
|
+
var util$2 = {};
|
|
9847
9847
|
|
|
9848
9848
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
9849
9849
|
//
|
|
@@ -9875,67 +9875,67 @@ function isArray$2(arg) {
|
|
|
9875
9875
|
}
|
|
9876
9876
|
return objectToString$2(arg) === '[object Array]';
|
|
9877
9877
|
}
|
|
9878
|
-
util$
|
|
9878
|
+
util$2.isArray = isArray$2;
|
|
9879
9879
|
|
|
9880
9880
|
function isBoolean$1(arg) {
|
|
9881
9881
|
return typeof arg === 'boolean';
|
|
9882
9882
|
}
|
|
9883
|
-
util$
|
|
9883
|
+
util$2.isBoolean = isBoolean$1;
|
|
9884
9884
|
|
|
9885
9885
|
function isNull$1(arg) {
|
|
9886
9886
|
return arg === null;
|
|
9887
9887
|
}
|
|
9888
|
-
util$
|
|
9888
|
+
util$2.isNull = isNull$1;
|
|
9889
9889
|
|
|
9890
9890
|
function isNullOrUndefined$1(arg) {
|
|
9891
9891
|
return arg == null;
|
|
9892
9892
|
}
|
|
9893
|
-
util$
|
|
9893
|
+
util$2.isNullOrUndefined = isNullOrUndefined$1;
|
|
9894
9894
|
|
|
9895
9895
|
function isNumber$1(arg) {
|
|
9896
9896
|
return typeof arg === 'number';
|
|
9897
9897
|
}
|
|
9898
|
-
util$
|
|
9898
|
+
util$2.isNumber = isNumber$1;
|
|
9899
9899
|
|
|
9900
9900
|
function isString$1(arg) {
|
|
9901
9901
|
return typeof arg === 'string';
|
|
9902
9902
|
}
|
|
9903
|
-
util$
|
|
9903
|
+
util$2.isString = isString$1;
|
|
9904
9904
|
|
|
9905
9905
|
function isSymbol$2(arg) {
|
|
9906
9906
|
return typeof arg === 'symbol';
|
|
9907
9907
|
}
|
|
9908
|
-
util$
|
|
9908
|
+
util$2.isSymbol = isSymbol$2;
|
|
9909
9909
|
|
|
9910
9910
|
function isUndefined$1(arg) {
|
|
9911
9911
|
return arg === void 0;
|
|
9912
9912
|
}
|
|
9913
|
-
util$
|
|
9913
|
+
util$2.isUndefined = isUndefined$1;
|
|
9914
9914
|
|
|
9915
9915
|
function isRegExp$1(re) {
|
|
9916
9916
|
return objectToString$2(re) === '[object RegExp]';
|
|
9917
9917
|
}
|
|
9918
|
-
util$
|
|
9918
|
+
util$2.isRegExp = isRegExp$1;
|
|
9919
9919
|
|
|
9920
9920
|
function isObject$6(arg) {
|
|
9921
9921
|
return typeof arg === 'object' && arg !== null;
|
|
9922
9922
|
}
|
|
9923
|
-
util$
|
|
9923
|
+
util$2.isObject = isObject$6;
|
|
9924
9924
|
|
|
9925
9925
|
function isDate$1(d) {
|
|
9926
9926
|
return objectToString$2(d) === '[object Date]';
|
|
9927
9927
|
}
|
|
9928
|
-
util$
|
|
9928
|
+
util$2.isDate = isDate$1;
|
|
9929
9929
|
|
|
9930
9930
|
function isError$1(e) {
|
|
9931
9931
|
return (objectToString$2(e) === '[object Error]' || e instanceof Error);
|
|
9932
9932
|
}
|
|
9933
|
-
util$
|
|
9933
|
+
util$2.isError = isError$1;
|
|
9934
9934
|
|
|
9935
9935
|
function isFunction$1(arg) {
|
|
9936
9936
|
return typeof arg === 'function';
|
|
9937
9937
|
}
|
|
9938
|
-
util$
|
|
9938
|
+
util$2.isFunction = isFunction$1;
|
|
9939
9939
|
|
|
9940
9940
|
function isPrimitive$1(arg) {
|
|
9941
9941
|
return arg === null ||
|
|
@@ -9945,9 +9945,9 @@ function isPrimitive$1(arg) {
|
|
|
9945
9945
|
typeof arg === 'symbol' || // ES6 symbol
|
|
9946
9946
|
typeof arg === 'undefined';
|
|
9947
9947
|
}
|
|
9948
|
-
util$
|
|
9948
|
+
util$2.isPrimitive = isPrimitive$1;
|
|
9949
9949
|
|
|
9950
|
-
util$
|
|
9950
|
+
util$2.isBuffer = Buffer.isBuffer;
|
|
9951
9951
|
|
|
9952
9952
|
function objectToString$2(o) {
|
|
9953
9953
|
return Object.prototype.toString.call(o);
|
|
@@ -10594,13 +10594,13 @@ var _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({
|
|
|
10594
10594
|
|
|
10595
10595
|
var require$$7 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_util$1);
|
|
10596
10596
|
|
|
10597
|
-
var BufferList
|
|
10597
|
+
var BufferList = {exports: {}};
|
|
10598
10598
|
|
|
10599
|
-
var hasRequiredBufferList
|
|
10599
|
+
var hasRequiredBufferList;
|
|
10600
10600
|
|
|
10601
|
-
function requireBufferList
|
|
10602
|
-
if (hasRequiredBufferList
|
|
10603
|
-
hasRequiredBufferList
|
|
10601
|
+
function requireBufferList () {
|
|
10602
|
+
if (hasRequiredBufferList) return BufferList.exports;
|
|
10603
|
+
hasRequiredBufferList = 1;
|
|
10604
10604
|
(function (module) {
|
|
10605
10605
|
|
|
10606
10606
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -10680,16 +10680,16 @@ function requireBufferList$1 () {
|
|
|
10680
10680
|
return this.constructor.name + ' ' + obj;
|
|
10681
10681
|
};
|
|
10682
10682
|
}
|
|
10683
|
-
} (BufferList
|
|
10684
|
-
return BufferList
|
|
10683
|
+
} (BufferList));
|
|
10684
|
+
return BufferList.exports;
|
|
10685
10685
|
}
|
|
10686
10686
|
|
|
10687
|
-
var destroy_1
|
|
10688
|
-
var hasRequiredDestroy
|
|
10687
|
+
var destroy_1;
|
|
10688
|
+
var hasRequiredDestroy;
|
|
10689
10689
|
|
|
10690
|
-
function requireDestroy
|
|
10691
|
-
if (hasRequiredDestroy
|
|
10692
|
-
hasRequiredDestroy
|
|
10690
|
+
function requireDestroy () {
|
|
10691
|
+
if (hasRequiredDestroy) return destroy_1;
|
|
10692
|
+
hasRequiredDestroy = 1;
|
|
10693
10693
|
|
|
10694
10694
|
/*<replacement>*/
|
|
10695
10695
|
|
|
@@ -10759,11 +10759,11 @@ function requireDestroy$1 () {
|
|
|
10759
10759
|
self.emit('error', err);
|
|
10760
10760
|
}
|
|
10761
10761
|
|
|
10762
|
-
destroy_1
|
|
10762
|
+
destroy_1 = {
|
|
10763
10763
|
destroy: destroy,
|
|
10764
10764
|
undestroy: undestroy
|
|
10765
10765
|
};
|
|
10766
|
-
return destroy_1
|
|
10766
|
+
return destroy_1;
|
|
10767
10767
|
}
|
|
10768
10768
|
|
|
10769
10769
|
var browser;
|
|
@@ -10841,19 +10841,19 @@ function requireBrowser () {
|
|
|
10841
10841
|
return browser;
|
|
10842
10842
|
}
|
|
10843
10843
|
|
|
10844
|
-
var _stream_writable
|
|
10845
|
-
var hasRequired_stream_writable
|
|
10844
|
+
var _stream_writable;
|
|
10845
|
+
var hasRequired_stream_writable;
|
|
10846
10846
|
|
|
10847
|
-
function require_stream_writable
|
|
10848
|
-
if (hasRequired_stream_writable
|
|
10849
|
-
hasRequired_stream_writable
|
|
10847
|
+
function require_stream_writable () {
|
|
10848
|
+
if (hasRequired_stream_writable) return _stream_writable;
|
|
10849
|
+
hasRequired_stream_writable = 1;
|
|
10850
10850
|
|
|
10851
10851
|
/*<replacement>*/
|
|
10852
10852
|
|
|
10853
10853
|
var pna = requireProcessNextickArgs();
|
|
10854
10854
|
/*</replacement>*/
|
|
10855
10855
|
|
|
10856
|
-
_stream_writable
|
|
10856
|
+
_stream_writable = Writable;
|
|
10857
10857
|
|
|
10858
10858
|
// It seems a linked list but it is not
|
|
10859
10859
|
// there will be only 2 of these for each stream
|
|
@@ -10879,7 +10879,7 @@ function require_stream_writable$1 () {
|
|
|
10879
10879
|
Writable.WritableState = WritableState;
|
|
10880
10880
|
|
|
10881
10881
|
/*<replacement>*/
|
|
10882
|
-
var util = Object.create(util$
|
|
10882
|
+
var util = Object.create(util$2);
|
|
10883
10883
|
util.inherits = require$$2$2;
|
|
10884
10884
|
/*</replacement>*/
|
|
10885
10885
|
|
|
@@ -10890,7 +10890,7 @@ function require_stream_writable$1 () {
|
|
|
10890
10890
|
/*</replacement>*/
|
|
10891
10891
|
|
|
10892
10892
|
/*<replacement>*/
|
|
10893
|
-
var Stream = requireStreamBrowser
|
|
10893
|
+
var Stream = requireStreamBrowser();
|
|
10894
10894
|
/*</replacement>*/
|
|
10895
10895
|
|
|
10896
10896
|
/*<replacement>*/
|
|
@@ -10906,14 +10906,14 @@ function require_stream_writable$1 () {
|
|
|
10906
10906
|
|
|
10907
10907
|
/*</replacement>*/
|
|
10908
10908
|
|
|
10909
|
-
var destroyImpl = requireDestroy
|
|
10909
|
+
var destroyImpl = requireDestroy();
|
|
10910
10910
|
|
|
10911
10911
|
util.inherits(Writable, Stream);
|
|
10912
10912
|
|
|
10913
10913
|
function nop() {}
|
|
10914
10914
|
|
|
10915
10915
|
function WritableState(options, stream) {
|
|
10916
|
-
Duplex = Duplex || require_stream_duplex
|
|
10916
|
+
Duplex = Duplex || require_stream_duplex();
|
|
10917
10917
|
|
|
10918
10918
|
options = options || {};
|
|
10919
10919
|
|
|
@@ -11063,7 +11063,7 @@ function require_stream_writable$1 () {
|
|
|
11063
11063
|
}
|
|
11064
11064
|
|
|
11065
11065
|
function Writable(options) {
|
|
11066
|
-
Duplex = Duplex || require_stream_duplex
|
|
11066
|
+
Duplex = Duplex || require_stream_duplex();
|
|
11067
11067
|
|
|
11068
11068
|
// Writable ctor is applied to Duplexes, too.
|
|
11069
11069
|
// `realHasInstance` is necessary because using plain `instanceof`
|
|
@@ -11500,15 +11500,15 @@ function require_stream_writable$1 () {
|
|
|
11500
11500
|
this.end();
|
|
11501
11501
|
cb(err);
|
|
11502
11502
|
};
|
|
11503
|
-
return _stream_writable
|
|
11503
|
+
return _stream_writable;
|
|
11504
11504
|
}
|
|
11505
11505
|
|
|
11506
|
-
var _stream_duplex
|
|
11507
|
-
var hasRequired_stream_duplex
|
|
11506
|
+
var _stream_duplex;
|
|
11507
|
+
var hasRequired_stream_duplex;
|
|
11508
11508
|
|
|
11509
|
-
function require_stream_duplex
|
|
11510
|
-
if (hasRequired_stream_duplex
|
|
11511
|
-
hasRequired_stream_duplex
|
|
11509
|
+
function require_stream_duplex () {
|
|
11510
|
+
if (hasRequired_stream_duplex) return _stream_duplex;
|
|
11511
|
+
hasRequired_stream_duplex = 1;
|
|
11512
11512
|
|
|
11513
11513
|
/*<replacement>*/
|
|
11514
11514
|
|
|
@@ -11524,15 +11524,15 @@ function require_stream_duplex$1 () {
|
|
|
11524
11524
|
};
|
|
11525
11525
|
/*</replacement>*/
|
|
11526
11526
|
|
|
11527
|
-
_stream_duplex
|
|
11527
|
+
_stream_duplex = Duplex;
|
|
11528
11528
|
|
|
11529
11529
|
/*<replacement>*/
|
|
11530
|
-
var util = Object.create(util$
|
|
11530
|
+
var util = Object.create(util$2);
|
|
11531
11531
|
util.inherits = require$$2$2;
|
|
11532
11532
|
/*</replacement>*/
|
|
11533
11533
|
|
|
11534
|
-
var Readable = require_stream_readable
|
|
11535
|
-
var Writable = require_stream_writable
|
|
11534
|
+
var Readable = require_stream_readable();
|
|
11535
|
+
var Writable = require_stream_writable();
|
|
11536
11536
|
|
|
11537
11537
|
util.inherits(Duplex, Readable);
|
|
11538
11538
|
|
|
@@ -11613,7 +11613,7 @@ function require_stream_duplex$1 () {
|
|
|
11613
11613
|
|
|
11614
11614
|
pna.nextTick(cb, err);
|
|
11615
11615
|
};
|
|
11616
|
-
return _stream_duplex
|
|
11616
|
+
return _stream_duplex;
|
|
11617
11617
|
}
|
|
11618
11618
|
|
|
11619
11619
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
@@ -11822,22 +11822,22 @@ var _polyfillNode_string_decoder = /*#__PURE__*/Object.freeze({
|
|
|
11822
11822
|
|
|
11823
11823
|
var require$$11 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_string_decoder);
|
|
11824
11824
|
|
|
11825
|
-
var _stream_readable
|
|
11826
|
-
var hasRequired_stream_readable
|
|
11825
|
+
var _stream_readable;
|
|
11826
|
+
var hasRequired_stream_readable;
|
|
11827
11827
|
|
|
11828
|
-
function require_stream_readable
|
|
11829
|
-
if (hasRequired_stream_readable
|
|
11830
|
-
hasRequired_stream_readable
|
|
11828
|
+
function require_stream_readable () {
|
|
11829
|
+
if (hasRequired_stream_readable) return _stream_readable;
|
|
11830
|
+
hasRequired_stream_readable = 1;
|
|
11831
11831
|
|
|
11832
11832
|
/*<replacement>*/
|
|
11833
11833
|
|
|
11834
11834
|
var pna = requireProcessNextickArgs();
|
|
11835
11835
|
/*</replacement>*/
|
|
11836
11836
|
|
|
11837
|
-
_stream_readable
|
|
11837
|
+
_stream_readable = Readable;
|
|
11838
11838
|
|
|
11839
11839
|
/*<replacement>*/
|
|
11840
|
-
var isArray = requireIsarray
|
|
11840
|
+
var isArray = requireIsarray();
|
|
11841
11841
|
/*</replacement>*/
|
|
11842
11842
|
|
|
11843
11843
|
/*<replacement>*/
|
|
@@ -11855,7 +11855,7 @@ function require_stream_readable$1 () {
|
|
|
11855
11855
|
/*</replacement>*/
|
|
11856
11856
|
|
|
11857
11857
|
/*<replacement>*/
|
|
11858
|
-
var Stream = requireStreamBrowser
|
|
11858
|
+
var Stream = requireStreamBrowser();
|
|
11859
11859
|
/*</replacement>*/
|
|
11860
11860
|
|
|
11861
11861
|
/*<replacement>*/
|
|
@@ -11872,7 +11872,7 @@ function require_stream_readable$1 () {
|
|
|
11872
11872
|
/*</replacement>*/
|
|
11873
11873
|
|
|
11874
11874
|
/*<replacement>*/
|
|
11875
|
-
var util = Object.create(util$
|
|
11875
|
+
var util = Object.create(util$2);
|
|
11876
11876
|
util.inherits = require$$2$2;
|
|
11877
11877
|
/*</replacement>*/
|
|
11878
11878
|
|
|
@@ -11886,8 +11886,8 @@ function require_stream_readable$1 () {
|
|
|
11886
11886
|
}
|
|
11887
11887
|
/*</replacement>*/
|
|
11888
11888
|
|
|
11889
|
-
var BufferList = requireBufferList
|
|
11890
|
-
var destroyImpl = requireDestroy
|
|
11889
|
+
var BufferList = requireBufferList();
|
|
11890
|
+
var destroyImpl = requireDestroy();
|
|
11891
11891
|
var StringDecoder;
|
|
11892
11892
|
|
|
11893
11893
|
util.inherits(Readable, Stream);
|
|
@@ -11907,7 +11907,7 @@ function require_stream_readable$1 () {
|
|
|
11907
11907
|
}
|
|
11908
11908
|
|
|
11909
11909
|
function ReadableState(options, stream) {
|
|
11910
|
-
Duplex = Duplex || require_stream_duplex
|
|
11910
|
+
Duplex = Duplex || require_stream_duplex();
|
|
11911
11911
|
|
|
11912
11912
|
options = options || {};
|
|
11913
11913
|
|
|
@@ -11984,7 +11984,7 @@ function require_stream_readable$1 () {
|
|
|
11984
11984
|
}
|
|
11985
11985
|
|
|
11986
11986
|
function Readable(options) {
|
|
11987
|
-
Duplex = Duplex || require_stream_duplex
|
|
11987
|
+
Duplex = Duplex || require_stream_duplex();
|
|
11988
11988
|
|
|
11989
11989
|
if (!(this instanceof Readable)) return new Readable(options);
|
|
11990
11990
|
|
|
@@ -12825,21 +12825,21 @@ function require_stream_readable$1 () {
|
|
|
12825
12825
|
}
|
|
12826
12826
|
return -1;
|
|
12827
12827
|
}
|
|
12828
|
-
return _stream_readable
|
|
12828
|
+
return _stream_readable;
|
|
12829
12829
|
}
|
|
12830
12830
|
|
|
12831
|
-
var _stream_transform
|
|
12831
|
+
var _stream_transform = Transform$1;
|
|
12832
12832
|
|
|
12833
|
-
var Duplex
|
|
12833
|
+
var Duplex = require_stream_duplex();
|
|
12834
12834
|
|
|
12835
12835
|
/*<replacement>*/
|
|
12836
|
-
var util$
|
|
12837
|
-
util$
|
|
12836
|
+
var util$1 = Object.create(util$2);
|
|
12837
|
+
util$1.inherits = require$$2$2;
|
|
12838
12838
|
/*</replacement>*/
|
|
12839
12839
|
|
|
12840
|
-
util$
|
|
12840
|
+
util$1.inherits(Transform$1, Duplex);
|
|
12841
12841
|
|
|
12842
|
-
function afterTransform
|
|
12842
|
+
function afterTransform(er, data) {
|
|
12843
12843
|
var ts = this._transformState;
|
|
12844
12844
|
ts.transforming = false;
|
|
12845
12845
|
|
|
@@ -12864,13 +12864,13 @@ function afterTransform$1(er, data) {
|
|
|
12864
12864
|
}
|
|
12865
12865
|
}
|
|
12866
12866
|
|
|
12867
|
-
function Transform$
|
|
12868
|
-
if (!(this instanceof Transform$
|
|
12867
|
+
function Transform$1(options) {
|
|
12868
|
+
if (!(this instanceof Transform$1)) return new Transform$1(options);
|
|
12869
12869
|
|
|
12870
|
-
Duplex
|
|
12870
|
+
Duplex.call(this, options);
|
|
12871
12871
|
|
|
12872
12872
|
this._transformState = {
|
|
12873
|
-
afterTransform: afterTransform
|
|
12873
|
+
afterTransform: afterTransform.bind(this),
|
|
12874
12874
|
needTransform: false,
|
|
12875
12875
|
transforming: false,
|
|
12876
12876
|
writecb: null,
|
|
@@ -12893,24 +12893,24 @@ function Transform$3(options) {
|
|
|
12893
12893
|
}
|
|
12894
12894
|
|
|
12895
12895
|
// When the writable side finishes, then flush out anything remaining.
|
|
12896
|
-
this.on('prefinish', prefinish
|
|
12896
|
+
this.on('prefinish', prefinish);
|
|
12897
12897
|
}
|
|
12898
12898
|
|
|
12899
|
-
function prefinish
|
|
12899
|
+
function prefinish() {
|
|
12900
12900
|
var _this = this;
|
|
12901
12901
|
|
|
12902
12902
|
if (typeof this._flush === 'function') {
|
|
12903
12903
|
this._flush(function (er, data) {
|
|
12904
|
-
done
|
|
12904
|
+
done(_this, er, data);
|
|
12905
12905
|
});
|
|
12906
12906
|
} else {
|
|
12907
|
-
done
|
|
12907
|
+
done(this, null, null);
|
|
12908
12908
|
}
|
|
12909
12909
|
}
|
|
12910
12910
|
|
|
12911
|
-
Transform$
|
|
12911
|
+
Transform$1.prototype.push = function (chunk, encoding) {
|
|
12912
12912
|
this._transformState.needTransform = false;
|
|
12913
|
-
return Duplex
|
|
12913
|
+
return Duplex.prototype.push.call(this, chunk, encoding);
|
|
12914
12914
|
};
|
|
12915
12915
|
|
|
12916
12916
|
// This is the part where you do stuff!
|
|
@@ -12923,11 +12923,11 @@ Transform$3.prototype.push = function (chunk, encoding) {
|
|
|
12923
12923
|
// Call `cb(err)` when you are done with this chunk. If you pass
|
|
12924
12924
|
// an error, then that'll put the hurt on the whole operation. If you
|
|
12925
12925
|
// never call cb(), then you'll never get another chunk.
|
|
12926
|
-
Transform$
|
|
12926
|
+
Transform$1.prototype._transform = function (chunk, encoding, cb) {
|
|
12927
12927
|
throw new Error('_transform() is not implemented');
|
|
12928
12928
|
};
|
|
12929
12929
|
|
|
12930
|
-
Transform$
|
|
12930
|
+
Transform$1.prototype._write = function (chunk, encoding, cb) {
|
|
12931
12931
|
var ts = this._transformState;
|
|
12932
12932
|
ts.writecb = cb;
|
|
12933
12933
|
ts.writechunk = chunk;
|
|
@@ -12941,7 +12941,7 @@ Transform$3.prototype._write = function (chunk, encoding, cb) {
|
|
|
12941
12941
|
// Doesn't matter what the args are here.
|
|
12942
12942
|
// _transform does all the work.
|
|
12943
12943
|
// That we got here means that the readable side wants more data.
|
|
12944
|
-
Transform$
|
|
12944
|
+
Transform$1.prototype._read = function (n) {
|
|
12945
12945
|
var ts = this._transformState;
|
|
12946
12946
|
|
|
12947
12947
|
if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
|
|
@@ -12954,16 +12954,16 @@ Transform$3.prototype._read = function (n) {
|
|
|
12954
12954
|
}
|
|
12955
12955
|
};
|
|
12956
12956
|
|
|
12957
|
-
Transform$
|
|
12957
|
+
Transform$1.prototype._destroy = function (err, cb) {
|
|
12958
12958
|
var _this2 = this;
|
|
12959
12959
|
|
|
12960
|
-
Duplex
|
|
12960
|
+
Duplex.prototype._destroy.call(this, err, function (err2) {
|
|
12961
12961
|
cb(err2);
|
|
12962
12962
|
_this2.emit('close');
|
|
12963
12963
|
});
|
|
12964
12964
|
};
|
|
12965
12965
|
|
|
12966
|
-
function done
|
|
12966
|
+
function done(stream, er, data) {
|
|
12967
12967
|
if (er) return stream.emit('error', er);
|
|
12968
12968
|
|
|
12969
12969
|
if (data != null) // single equals check for both `null` and `undefined`
|
|
@@ -12978,36 +12978,36 @@ function done$1(stream, er, data) {
|
|
|
12978
12978
|
return stream.push(null);
|
|
12979
12979
|
}
|
|
12980
12980
|
|
|
12981
|
-
var _stream_passthrough
|
|
12981
|
+
var _stream_passthrough = PassThrough;
|
|
12982
12982
|
|
|
12983
|
-
var Transform
|
|
12983
|
+
var Transform = _stream_transform;
|
|
12984
12984
|
|
|
12985
12985
|
/*<replacement>*/
|
|
12986
|
-
var util
|
|
12987
|
-
util
|
|
12986
|
+
var util = Object.create(util$2);
|
|
12987
|
+
util.inherits = require$$2$2;
|
|
12988
12988
|
/*</replacement>*/
|
|
12989
12989
|
|
|
12990
|
-
util
|
|
12990
|
+
util.inherits(PassThrough, Transform);
|
|
12991
12991
|
|
|
12992
|
-
function PassThrough
|
|
12993
|
-
if (!(this instanceof PassThrough
|
|
12992
|
+
function PassThrough(options) {
|
|
12993
|
+
if (!(this instanceof PassThrough)) return new PassThrough(options);
|
|
12994
12994
|
|
|
12995
|
-
Transform
|
|
12995
|
+
Transform.call(this, options);
|
|
12996
12996
|
}
|
|
12997
12997
|
|
|
12998
|
-
PassThrough
|
|
12998
|
+
PassThrough.prototype._transform = function (chunk, encoding, cb) {
|
|
12999
12999
|
cb(null, chunk);
|
|
13000
13000
|
};
|
|
13001
13001
|
|
|
13002
13002
|
(function (module, exports) {
|
|
13003
|
-
exports = module.exports = require_stream_readable
|
|
13003
|
+
exports = module.exports = require_stream_readable();
|
|
13004
13004
|
exports.Stream = exports;
|
|
13005
13005
|
exports.Readable = exports;
|
|
13006
|
-
exports.Writable = require_stream_writable
|
|
13007
|
-
exports.Duplex = require_stream_duplex
|
|
13008
|
-
exports.Transform = _stream_transform
|
|
13009
|
-
exports.PassThrough = _stream_passthrough
|
|
13010
|
-
} (readableBrowser
|
|
13006
|
+
exports.Writable = require_stream_writable();
|
|
13007
|
+
exports.Duplex = require_stream_duplex();
|
|
13008
|
+
exports.Transform = _stream_transform;
|
|
13009
|
+
exports.PassThrough = _stream_passthrough;
|
|
13010
|
+
} (readableBrowser, readableBrowser.exports));
|
|
13011
13011
|
|
|
13012
13012
|
var sdp = {exports: {}};
|
|
13013
13013
|
|
|
@@ -17174,7 +17174,7 @@ function pubsubItemContentAliases$1() {
|
|
|
17174
17174
|
*
|
|
17175
17175
|
* Derived from: ltx, Copyright © 2010 Stephan Maka
|
|
17176
17176
|
*/
|
|
17177
|
-
class StreamParser$2 extends readableBrowser
|
|
17177
|
+
class StreamParser$2 extends readableBrowser.exports.Transform {
|
|
17178
17178
|
constructor(opts) {
|
|
17179
17179
|
super({ objectMode: true });
|
|
17180
17180
|
this.closedStream = false;
|
|
@@ -17295,7 +17295,7 @@ class StreamParser$2 extends readableBrowser$1.exports.Transform {
|
|
|
17295
17295
|
* - cipher-base, Copyright (c) 2017 crypto-browserify contributors
|
|
17296
17296
|
* - create-hash, Copyright (c) 2017 crypto-browserify contributors
|
|
17297
17297
|
*/
|
|
17298
|
-
class Hash$1 extends readableBrowser
|
|
17298
|
+
class Hash$1 extends readableBrowser.exports.Transform {
|
|
17299
17299
|
constructor(blockSize, finalSize, endian = 'be') {
|
|
17300
17300
|
super();
|
|
17301
17301
|
this._block = Buffer.alloc(blockSize);
|
|
@@ -18125,7 +18125,7 @@ function createHash$1(alg) {
|
|
|
18125
18125
|
* - randombytes, Copyright (c) 2017 crypto-browserify
|
|
18126
18126
|
*/
|
|
18127
18127
|
const ZEROS$1 = Buffer.alloc(128);
|
|
18128
|
-
class Hmac$1 extends readableBrowser
|
|
18128
|
+
class Hmac$1 extends readableBrowser.exports.Transform {
|
|
18129
18129
|
constructor(alg, key) {
|
|
18130
18130
|
super();
|
|
18131
18131
|
if (typeof key === 'string') {
|
|
@@ -27275,7 +27275,7 @@ class RequestChannel {
|
|
|
27275
27275
|
});
|
|
27276
27276
|
}
|
|
27277
27277
|
}
|
|
27278
|
-
class BOSH extends readableBrowser
|
|
27278
|
+
class BOSH extends readableBrowser.exports.Duplex {
|
|
27279
27279
|
constructor(client, sm, stanzas) {
|
|
27280
27280
|
super({
|
|
27281
27281
|
objectMode: true
|
|
@@ -27515,7 +27515,7 @@ class BOSH extends readableBrowser$1.exports.Duplex {
|
|
|
27515
27515
|
}
|
|
27516
27516
|
|
|
27517
27517
|
const WS_OPEN = 1;
|
|
27518
|
-
class WSConnection extends readableBrowser
|
|
27518
|
+
class WSConnection extends readableBrowser.exports.Duplex {
|
|
27519
27519
|
constructor(client, sm, stanzas) {
|
|
27520
27520
|
super({ objectMode: true });
|
|
27521
27521
|
this.sm = sm;
|
|
@@ -31120,37 +31120,40 @@ class LogUploader {
|
|
|
31120
31120
|
constructor(url, debugMode = false) {
|
|
31121
31121
|
this.url = url;
|
|
31122
31122
|
this.debugMode = debugMode;
|
|
31123
|
-
this.hasPendingRequest = false;
|
|
31124
31123
|
this.sendQueue = [];
|
|
31124
|
+
this.hasPendingRequest = false;
|
|
31125
31125
|
}
|
|
31126
31126
|
postLogsToEndpoint(requestParams) {
|
|
31127
|
-
|
|
31128
|
-
|
|
31129
|
-
|
|
31130
|
-
|
|
31131
|
-
|
|
31132
|
-
|
|
31133
|
-
|
|
31134
|
-
hasPendingRequest: this.hasPendingRequest
|
|
31135
|
-
});
|
|
31136
|
-
return deferred.promise;
|
|
31127
|
+
const deferred = getDeferred();
|
|
31128
|
+
this.sendQueue.push({ requestParams, deferred });
|
|
31129
|
+
this.sendNextQueuedLogToServer();
|
|
31130
|
+
this.debug('adding requestParams to sendQueue', {
|
|
31131
|
+
requestParams,
|
|
31132
|
+
updatedSendQueue: this.sendQueue.map(i => i.requestParams),
|
|
31133
|
+
hasPendingRequest: this.hasPendingRequest
|
|
31137
31134
|
});
|
|
31135
|
+
return deferred.promise;
|
|
31138
31136
|
}
|
|
31139
31137
|
postLogsToEndpointInstantly(requestParams) {
|
|
31140
|
-
|
|
31141
|
-
|
|
31142
|
-
return this.sendPostRequest(requestParams);
|
|
31143
|
-
});
|
|
31138
|
+
this.debug('sending request instantly', { requestParams, sendQueue: this.sendQueue.map(i => i.requestParams) });
|
|
31139
|
+
return this.sendPostRequest(requestParams);
|
|
31144
31140
|
}
|
|
31145
31141
|
sendEntireQueue() {
|
|
31146
31142
|
this.debug('sending all queued requests instantly to clear out sendQueue', {
|
|
31147
31143
|
sendQueue: this.sendQueue.map(i => i.requestParams)
|
|
31148
31144
|
});
|
|
31145
|
+
const promises = [];
|
|
31149
31146
|
let queueItem;
|
|
31150
31147
|
/* eslint-disable-next-line no-cond-assign */
|
|
31151
31148
|
while (queueItem = this.sendQueue.shift()) {
|
|
31152
|
-
this.
|
|
31149
|
+
promises.push(this.postLogsToEndpointInstantly(queueItem.requestParams));
|
|
31153
31150
|
}
|
|
31151
|
+
/* don't want this to be async because this is called from the window 'unload' event */
|
|
31152
|
+
return promises;
|
|
31153
|
+
}
|
|
31154
|
+
resetSendQueue() {
|
|
31155
|
+
this.debug('reseting send queue without sending currently queued data', { queueLength: this.sendQueue.length });
|
|
31156
|
+
this.sendQueue = [];
|
|
31154
31157
|
}
|
|
31155
31158
|
sendNextQueuedLogToServer() {
|
|
31156
31159
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
@@ -31237,6 +31240,15 @@ class ServerLogger {
|
|
|
31237
31240
|
this.debounceLogUploadTime = logger.config.uploadDebounceTime || DEFAULT_UPLOAD_DEBOUNCE;
|
|
31238
31241
|
this.logUploader = getOrCreateLogUploader(logger.config.url, logger.config.debugMode);
|
|
31239
31242
|
window.addEventListener('unload', this.sendAllLogsInstantly.bind(this));
|
|
31243
|
+
/* when we stop server logging, we need to clear everything out */
|
|
31244
|
+
this.logger.on('onStop', (_reason) => {
|
|
31245
|
+
this.debug('`onStop` received. Clearing logBuffer and sendQueue', {
|
|
31246
|
+
logBuffer: this.logBuffer,
|
|
31247
|
+
sendQueue: this.logUploader.sendQueue
|
|
31248
|
+
});
|
|
31249
|
+
this.logBuffer = [];
|
|
31250
|
+
this.logUploader.resetSendQueue();
|
|
31251
|
+
});
|
|
31240
31252
|
}
|
|
31241
31253
|
addLogToSend(logLevel, message, details) {
|
|
31242
31254
|
if (!this.isInitialized) {
|
|
@@ -31305,7 +31317,16 @@ class ServerLogger {
|
|
|
31305
31317
|
this.debug('calling sendLogsToServer()', { logBuffer: this.logBuffer });
|
|
31306
31318
|
this.sendLogsToServer();
|
|
31307
31319
|
}
|
|
31320
|
+
sendAllLogsInstantly() {
|
|
31321
|
+
/* don't want this to be async because this is called from the window 'unload' event */
|
|
31322
|
+
/* this will send any queued up requests */
|
|
31323
|
+
return this.logUploader.sendEntireQueue()
|
|
31324
|
+
.concat(
|
|
31325
|
+
/* this will send any items in the buffer still */
|
|
31326
|
+
this.logBuffer.map((item) => this.logUploader.postLogsToEndpointInstantly(this.convertToRequestParams(item.traces.reverse()))));
|
|
31327
|
+
}
|
|
31308
31328
|
sendLogsToServer(immediate = false) {
|
|
31329
|
+
var _a;
|
|
31309
31330
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31310
31331
|
if (!this.logBuffer.length) {
|
|
31311
31332
|
/* clear timer */
|
|
@@ -31337,8 +31358,14 @@ class ServerLogger {
|
|
|
31337
31358
|
yield this.logUploader.postLogsToEndpoint(this.convertToRequestParams(bufferItem.traces.reverse()));
|
|
31338
31359
|
}
|
|
31339
31360
|
catch (err) {
|
|
31361
|
+
this.logger.emit('onError', err);
|
|
31340
31362
|
this.logger.error('Error sending logs to server', err, { skipServer: true });
|
|
31341
31363
|
/* no-op: the uploader will attempt reties. if the uploader throws, it means this log isn't going to make to the server */
|
|
31364
|
+
const statusCode = `${(_a = err) === null || _a === void 0 ? void 0 : _a.status}`;
|
|
31365
|
+
if (['401', '404'].includes(statusCode)) {
|
|
31366
|
+
this.debug(`received a ${statusCode} from logUploader. stopping logging to server`);
|
|
31367
|
+
this.logger.stopServerLogging(statusCode);
|
|
31368
|
+
}
|
|
31342
31369
|
}
|
|
31343
31370
|
finally {
|
|
31344
31371
|
/* setup the debounce again */
|
|
@@ -31346,13 +31373,6 @@ class ServerLogger {
|
|
|
31346
31373
|
}
|
|
31347
31374
|
});
|
|
31348
31375
|
}
|
|
31349
|
-
sendAllLogsInstantly() {
|
|
31350
|
-
this.logBuffer.forEach((item) => {
|
|
31351
|
-
this.logUploader.postLogsToEndpointInstantly(this.convertToRequestParams(item.traces.reverse()));
|
|
31352
|
-
});
|
|
31353
|
-
/* this will send any queued up requests */
|
|
31354
|
-
return this.logUploader.sendEntireQueue();
|
|
31355
|
-
}
|
|
31356
31376
|
truncateLog(logLevel, log) {
|
|
31357
31377
|
let trace;
|
|
31358
31378
|
let truncatedTraceSize;
|
|
@@ -31432,8 +31452,10 @@ class ServerLogger {
|
|
|
31432
31452
|
}
|
|
31433
31453
|
}
|
|
31434
31454
|
|
|
31435
|
-
class Logger {
|
|
31455
|
+
class Logger extends EventEmitter {
|
|
31456
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
31436
31457
|
constructor(config) {
|
|
31458
|
+
super();
|
|
31437
31459
|
this.defaultFormatter = (logLevel, message, details, messageOptions, next) => {
|
|
31438
31460
|
if (messageOptions.skipDefaultFormatter) {
|
|
31439
31461
|
return next();
|
|
@@ -31454,7 +31476,8 @@ class Logger {
|
|
|
31454
31476
|
if (typeof details !== 'undefined') {
|
|
31455
31477
|
params.push(this.config.stringify ? safeJsonStringify.exports(details) : details);
|
|
31456
31478
|
}
|
|
31457
|
-
|
|
31479
|
+
/* eslint-disable-next-line prefer-spread */
|
|
31480
|
+
this.secondaryLogger[logLevel].apply(this.secondaryLogger, params);
|
|
31458
31481
|
}
|
|
31459
31482
|
catch (error) {
|
|
31460
31483
|
/* don't let custom logger errors stop our logger */
|
|
@@ -31463,6 +31486,7 @@ class Logger {
|
|
|
31463
31486
|
}
|
|
31464
31487
|
/* log to the server */
|
|
31465
31488
|
if (!messageOptions.skipServer &&
|
|
31489
|
+
!this.stopReason &&
|
|
31466
31490
|
this.serverLogger &&
|
|
31467
31491
|
this.logRank(logLevel) >= this.logRank(this.config.logLevel)) {
|
|
31468
31492
|
this.serverLogger.addLogToSend(logLevel, message, details);
|
|
@@ -31490,9 +31514,19 @@ class Logger {
|
|
|
31490
31514
|
if (this.config.initializeServerLogging !== false) {
|
|
31491
31515
|
this.serverLogger = new ServerLogger(this);
|
|
31492
31516
|
}
|
|
31517
|
+
if (this.config.startServerLoggingPaused) {
|
|
31518
|
+
this.stopServerLogging();
|
|
31519
|
+
}
|
|
31520
|
+
}
|
|
31521
|
+
get VERSION() {
|
|
31522
|
+
return Logger.VERSION;
|
|
31493
31523
|
}
|
|
31494
31524
|
setAccessToken(token) {
|
|
31495
31525
|
this.config.accessToken = token;
|
|
31526
|
+
/* if we stopped because of a 401, we will try to start again */
|
|
31527
|
+
if (this.stopReason === '401') {
|
|
31528
|
+
this.startServerLogging();
|
|
31529
|
+
}
|
|
31496
31530
|
}
|
|
31497
31531
|
log(message, details, opts) {
|
|
31498
31532
|
this.formatMessage('log', message, details, opts);
|
|
@@ -31509,6 +31543,46 @@ class Logger {
|
|
|
31509
31543
|
error(message, details, opts) {
|
|
31510
31544
|
this.formatMessage('error', message, details, opts);
|
|
31511
31545
|
}
|
|
31546
|
+
/**
|
|
31547
|
+
* Start sending logs to the server. Only applies if
|
|
31548
|
+
* the logger instance was configured with server logging.
|
|
31549
|
+
*
|
|
31550
|
+
* @returns void
|
|
31551
|
+
*/
|
|
31552
|
+
startServerLogging() {
|
|
31553
|
+
this.stopReason = undefined;
|
|
31554
|
+
if (!this.serverLogger) {
|
|
31555
|
+
return this.warn('`startServerLogging` called but the logger instance is not configured to ' +
|
|
31556
|
+
'send logs to the server. Ignoring call to start sending logs to server.', undefined, { skipServer: true });
|
|
31557
|
+
}
|
|
31558
|
+
this.emit('onStart');
|
|
31559
|
+
}
|
|
31560
|
+
/**
|
|
31561
|
+
* Stop sending logs to the server. Note; this will clear
|
|
31562
|
+
* any items that are currently in the buffer. If you wish
|
|
31563
|
+
* to send any currently pending log items, use
|
|
31564
|
+
* `sendAllLogsInstantly()` before stopping the server loggin.
|
|
31565
|
+
*
|
|
31566
|
+
* @param reason optional; default `'force'`
|
|
31567
|
+
* @returns void
|
|
31568
|
+
*/
|
|
31569
|
+
stopServerLogging(reason = 'force') {
|
|
31570
|
+
/* we never want to override a force stop */
|
|
31571
|
+
if (this.stopReason === 'force' && reason !== 'force') {
|
|
31572
|
+
return;
|
|
31573
|
+
}
|
|
31574
|
+
this.stopReason = reason;
|
|
31575
|
+
this.emit('onStop', reason);
|
|
31576
|
+
}
|
|
31577
|
+
/**
|
|
31578
|
+
* Force send all pending log items to the server.
|
|
31579
|
+
*
|
|
31580
|
+
* @returns an array of HTTP request promises
|
|
31581
|
+
*/
|
|
31582
|
+
sendAllLogsInstantly() {
|
|
31583
|
+
var _a;
|
|
31584
|
+
return ((_a = this.serverLogger) === null || _a === void 0 ? void 0 : _a.sendAllLogsInstantly()) || [];
|
|
31585
|
+
}
|
|
31512
31586
|
formatMessage(level, message, details, opts) {
|
|
31513
31587
|
let formatters = [this.defaultFormatter.bind(this)];
|
|
31514
31588
|
if (this.config.formatters) {
|
|
@@ -31549,6 +31623,8 @@ class Logger {
|
|
|
31549
31623
|
}
|
|
31550
31624
|
}
|
|
31551
31625
|
}
|
|
31626
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
31627
|
+
Logger.VERSION = '4.1.0';
|
|
31552
31628
|
|
|
31553
31629
|
/* istanbul ignore file */
|
|
31554
31630
|
if (!commonjsGlobal) {
|
|
@@ -37520,7 +37596,7 @@ var StreamParser$1 = {};
|
|
|
37520
37596
|
*/
|
|
37521
37597
|
Object.defineProperty(StreamParser$1, "__esModule", { value: true });
|
|
37522
37598
|
const tslib_1$5 = require$$0$1;
|
|
37523
|
-
const readable_stream_1 = readableBrowser
|
|
37599
|
+
const readable_stream_1 = readableBrowser.exports;
|
|
37524
37600
|
const Element_1 = tslib_1$5.__importDefault(Element);
|
|
37525
37601
|
const Error_1 = tslib_1$5.__importDefault(_Error);
|
|
37526
37602
|
const Parser_1 = tslib_1$5.__importDefault(Parser$1);
|
|
@@ -37747,2166 +37823,6 @@ var jingle = {};
|
|
|
37747
37823
|
|
|
37748
37824
|
var FileTransferSession$1 = {};
|
|
37749
37825
|
|
|
37750
|
-
var readableBrowser = {exports: {}};
|
|
37751
|
-
|
|
37752
|
-
var isarray;
|
|
37753
|
-
var hasRequiredIsarray;
|
|
37754
|
-
|
|
37755
|
-
function requireIsarray () {
|
|
37756
|
-
if (hasRequiredIsarray) return isarray;
|
|
37757
|
-
hasRequiredIsarray = 1;
|
|
37758
|
-
var toString = {}.toString;
|
|
37759
|
-
|
|
37760
|
-
isarray = Array.isArray || function (arr) {
|
|
37761
|
-
return toString.call(arr) == '[object Array]';
|
|
37762
|
-
};
|
|
37763
|
-
return isarray;
|
|
37764
|
-
}
|
|
37765
|
-
|
|
37766
|
-
var streamBrowser;
|
|
37767
|
-
var hasRequiredStreamBrowser;
|
|
37768
|
-
|
|
37769
|
-
function requireStreamBrowser () {
|
|
37770
|
-
if (hasRequiredStreamBrowser) return streamBrowser;
|
|
37771
|
-
hasRequiredStreamBrowser = 1;
|
|
37772
|
-
streamBrowser = require$$0$3.EventEmitter;
|
|
37773
|
-
return streamBrowser;
|
|
37774
|
-
}
|
|
37775
|
-
|
|
37776
|
-
var BufferList = {exports: {}};
|
|
37777
|
-
|
|
37778
|
-
var hasRequiredBufferList;
|
|
37779
|
-
|
|
37780
|
-
function requireBufferList () {
|
|
37781
|
-
if (hasRequiredBufferList) return BufferList.exports;
|
|
37782
|
-
hasRequiredBufferList = 1;
|
|
37783
|
-
(function (module) {
|
|
37784
|
-
|
|
37785
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
37786
|
-
|
|
37787
|
-
var Buffer = requireSafeBuffer().Buffer;
|
|
37788
|
-
var util = require$$7;
|
|
37789
|
-
|
|
37790
|
-
function copyBuffer(src, target, offset) {
|
|
37791
|
-
src.copy(target, offset);
|
|
37792
|
-
}
|
|
37793
|
-
|
|
37794
|
-
module.exports = function () {
|
|
37795
|
-
function BufferList() {
|
|
37796
|
-
_classCallCheck(this, BufferList);
|
|
37797
|
-
|
|
37798
|
-
this.head = null;
|
|
37799
|
-
this.tail = null;
|
|
37800
|
-
this.length = 0;
|
|
37801
|
-
}
|
|
37802
|
-
|
|
37803
|
-
BufferList.prototype.push = function push(v) {
|
|
37804
|
-
var entry = { data: v, next: null };
|
|
37805
|
-
if (this.length > 0) this.tail.next = entry;else this.head = entry;
|
|
37806
|
-
this.tail = entry;
|
|
37807
|
-
++this.length;
|
|
37808
|
-
};
|
|
37809
|
-
|
|
37810
|
-
BufferList.prototype.unshift = function unshift(v) {
|
|
37811
|
-
var entry = { data: v, next: this.head };
|
|
37812
|
-
if (this.length === 0) this.tail = entry;
|
|
37813
|
-
this.head = entry;
|
|
37814
|
-
++this.length;
|
|
37815
|
-
};
|
|
37816
|
-
|
|
37817
|
-
BufferList.prototype.shift = function shift() {
|
|
37818
|
-
if (this.length === 0) return;
|
|
37819
|
-
var ret = this.head.data;
|
|
37820
|
-
if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
|
|
37821
|
-
--this.length;
|
|
37822
|
-
return ret;
|
|
37823
|
-
};
|
|
37824
|
-
|
|
37825
|
-
BufferList.prototype.clear = function clear() {
|
|
37826
|
-
this.head = this.tail = null;
|
|
37827
|
-
this.length = 0;
|
|
37828
|
-
};
|
|
37829
|
-
|
|
37830
|
-
BufferList.prototype.join = function join(s) {
|
|
37831
|
-
if (this.length === 0) return '';
|
|
37832
|
-
var p = this.head;
|
|
37833
|
-
var ret = '' + p.data;
|
|
37834
|
-
while (p = p.next) {
|
|
37835
|
-
ret += s + p.data;
|
|
37836
|
-
}return ret;
|
|
37837
|
-
};
|
|
37838
|
-
|
|
37839
|
-
BufferList.prototype.concat = function concat(n) {
|
|
37840
|
-
if (this.length === 0) return Buffer.alloc(0);
|
|
37841
|
-
if (this.length === 1) return this.head.data;
|
|
37842
|
-
var ret = Buffer.allocUnsafe(n >>> 0);
|
|
37843
|
-
var p = this.head;
|
|
37844
|
-
var i = 0;
|
|
37845
|
-
while (p) {
|
|
37846
|
-
copyBuffer(p.data, ret, i);
|
|
37847
|
-
i += p.data.length;
|
|
37848
|
-
p = p.next;
|
|
37849
|
-
}
|
|
37850
|
-
return ret;
|
|
37851
|
-
};
|
|
37852
|
-
|
|
37853
|
-
return BufferList;
|
|
37854
|
-
}();
|
|
37855
|
-
|
|
37856
|
-
if (util && util.inspect && util.inspect.custom) {
|
|
37857
|
-
module.exports.prototype[util.inspect.custom] = function () {
|
|
37858
|
-
var obj = util.inspect({ length: this.length });
|
|
37859
|
-
return this.constructor.name + ' ' + obj;
|
|
37860
|
-
};
|
|
37861
|
-
}
|
|
37862
|
-
} (BufferList));
|
|
37863
|
-
return BufferList.exports;
|
|
37864
|
-
}
|
|
37865
|
-
|
|
37866
|
-
var destroy_1;
|
|
37867
|
-
var hasRequiredDestroy;
|
|
37868
|
-
|
|
37869
|
-
function requireDestroy () {
|
|
37870
|
-
if (hasRequiredDestroy) return destroy_1;
|
|
37871
|
-
hasRequiredDestroy = 1;
|
|
37872
|
-
|
|
37873
|
-
/*<replacement>*/
|
|
37874
|
-
|
|
37875
|
-
var pna = requireProcessNextickArgs();
|
|
37876
|
-
/*</replacement>*/
|
|
37877
|
-
|
|
37878
|
-
// undocumented cb() API, needed for core, not for public API
|
|
37879
|
-
function destroy(err, cb) {
|
|
37880
|
-
var _this = this;
|
|
37881
|
-
|
|
37882
|
-
var readableDestroyed = this._readableState && this._readableState.destroyed;
|
|
37883
|
-
var writableDestroyed = this._writableState && this._writableState.destroyed;
|
|
37884
|
-
|
|
37885
|
-
if (readableDestroyed || writableDestroyed) {
|
|
37886
|
-
if (cb) {
|
|
37887
|
-
cb(err);
|
|
37888
|
-
} else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
|
|
37889
|
-
pna.nextTick(emitErrorNT, this, err);
|
|
37890
|
-
}
|
|
37891
|
-
return this;
|
|
37892
|
-
}
|
|
37893
|
-
|
|
37894
|
-
// we set destroyed to true before firing error callbacks in order
|
|
37895
|
-
// to make it re-entrance safe in case destroy() is called within callbacks
|
|
37896
|
-
|
|
37897
|
-
if (this._readableState) {
|
|
37898
|
-
this._readableState.destroyed = true;
|
|
37899
|
-
}
|
|
37900
|
-
|
|
37901
|
-
// if this is a duplex stream mark the writable part as destroyed as well
|
|
37902
|
-
if (this._writableState) {
|
|
37903
|
-
this._writableState.destroyed = true;
|
|
37904
|
-
}
|
|
37905
|
-
|
|
37906
|
-
this._destroy(err || null, function (err) {
|
|
37907
|
-
if (!cb && err) {
|
|
37908
|
-
pna.nextTick(emitErrorNT, _this, err);
|
|
37909
|
-
if (_this._writableState) {
|
|
37910
|
-
_this._writableState.errorEmitted = true;
|
|
37911
|
-
}
|
|
37912
|
-
} else if (cb) {
|
|
37913
|
-
cb(err);
|
|
37914
|
-
}
|
|
37915
|
-
});
|
|
37916
|
-
|
|
37917
|
-
return this;
|
|
37918
|
-
}
|
|
37919
|
-
|
|
37920
|
-
function undestroy() {
|
|
37921
|
-
if (this._readableState) {
|
|
37922
|
-
this._readableState.destroyed = false;
|
|
37923
|
-
this._readableState.reading = false;
|
|
37924
|
-
this._readableState.ended = false;
|
|
37925
|
-
this._readableState.endEmitted = false;
|
|
37926
|
-
}
|
|
37927
|
-
|
|
37928
|
-
if (this._writableState) {
|
|
37929
|
-
this._writableState.destroyed = false;
|
|
37930
|
-
this._writableState.ended = false;
|
|
37931
|
-
this._writableState.ending = false;
|
|
37932
|
-
this._writableState.finished = false;
|
|
37933
|
-
this._writableState.errorEmitted = false;
|
|
37934
|
-
}
|
|
37935
|
-
}
|
|
37936
|
-
|
|
37937
|
-
function emitErrorNT(self, err) {
|
|
37938
|
-
self.emit('error', err);
|
|
37939
|
-
}
|
|
37940
|
-
|
|
37941
|
-
destroy_1 = {
|
|
37942
|
-
destroy: destroy,
|
|
37943
|
-
undestroy: undestroy
|
|
37944
|
-
};
|
|
37945
|
-
return destroy_1;
|
|
37946
|
-
}
|
|
37947
|
-
|
|
37948
|
-
var _stream_writable;
|
|
37949
|
-
var hasRequired_stream_writable;
|
|
37950
|
-
|
|
37951
|
-
function require_stream_writable () {
|
|
37952
|
-
if (hasRequired_stream_writable) return _stream_writable;
|
|
37953
|
-
hasRequired_stream_writable = 1;
|
|
37954
|
-
|
|
37955
|
-
/*<replacement>*/
|
|
37956
|
-
|
|
37957
|
-
var pna = requireProcessNextickArgs();
|
|
37958
|
-
/*</replacement>*/
|
|
37959
|
-
|
|
37960
|
-
_stream_writable = Writable;
|
|
37961
|
-
|
|
37962
|
-
// It seems a linked list but it is not
|
|
37963
|
-
// there will be only 2 of these for each stream
|
|
37964
|
-
function CorkedRequest(state) {
|
|
37965
|
-
var _this = this;
|
|
37966
|
-
|
|
37967
|
-
this.next = null;
|
|
37968
|
-
this.entry = null;
|
|
37969
|
-
this.finish = function () {
|
|
37970
|
-
onCorkedFinish(_this, state);
|
|
37971
|
-
};
|
|
37972
|
-
}
|
|
37973
|
-
/* </replacement> */
|
|
37974
|
-
|
|
37975
|
-
/*<replacement>*/
|
|
37976
|
-
var asyncWrite = !browser$1$1.browser && ['v0.10', 'v0.9.'].indexOf(browser$1$1.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
|
|
37977
|
-
/*</replacement>*/
|
|
37978
|
-
|
|
37979
|
-
/*<replacement>*/
|
|
37980
|
-
var Duplex;
|
|
37981
|
-
/*</replacement>*/
|
|
37982
|
-
|
|
37983
|
-
Writable.WritableState = WritableState;
|
|
37984
|
-
|
|
37985
|
-
/*<replacement>*/
|
|
37986
|
-
var util = Object.create(util$4);
|
|
37987
|
-
util.inherits = require$$2$2;
|
|
37988
|
-
/*</replacement>*/
|
|
37989
|
-
|
|
37990
|
-
/*<replacement>*/
|
|
37991
|
-
var internalUtil = {
|
|
37992
|
-
deprecate: requireBrowser()
|
|
37993
|
-
};
|
|
37994
|
-
/*</replacement>*/
|
|
37995
|
-
|
|
37996
|
-
/*<replacement>*/
|
|
37997
|
-
var Stream = requireStreamBrowser();
|
|
37998
|
-
/*</replacement>*/
|
|
37999
|
-
|
|
38000
|
-
/*<replacement>*/
|
|
38001
|
-
|
|
38002
|
-
var Buffer = requireSafeBuffer().Buffer;
|
|
38003
|
-
var OurUint8Array = commonjsGlobal.Uint8Array || function () {};
|
|
38004
|
-
function _uint8ArrayToBuffer(chunk) {
|
|
38005
|
-
return Buffer.from(chunk);
|
|
38006
|
-
}
|
|
38007
|
-
function _isUint8Array(obj) {
|
|
38008
|
-
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
38009
|
-
}
|
|
38010
|
-
|
|
38011
|
-
/*</replacement>*/
|
|
38012
|
-
|
|
38013
|
-
var destroyImpl = requireDestroy();
|
|
38014
|
-
|
|
38015
|
-
util.inherits(Writable, Stream);
|
|
38016
|
-
|
|
38017
|
-
function nop() {}
|
|
38018
|
-
|
|
38019
|
-
function WritableState(options, stream) {
|
|
38020
|
-
Duplex = Duplex || require_stream_duplex();
|
|
38021
|
-
|
|
38022
|
-
options = options || {};
|
|
38023
|
-
|
|
38024
|
-
// Duplex streams are both readable and writable, but share
|
|
38025
|
-
// the same options object.
|
|
38026
|
-
// However, some cases require setting options to different
|
|
38027
|
-
// values for the readable and the writable sides of the duplex stream.
|
|
38028
|
-
// These options can be provided separately as readableXXX and writableXXX.
|
|
38029
|
-
var isDuplex = stream instanceof Duplex;
|
|
38030
|
-
|
|
38031
|
-
// object stream flag to indicate whether or not this stream
|
|
38032
|
-
// contains buffers or objects.
|
|
38033
|
-
this.objectMode = !!options.objectMode;
|
|
38034
|
-
|
|
38035
|
-
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
|
|
38036
|
-
|
|
38037
|
-
// the point at which write() starts returning false
|
|
38038
|
-
// Note: 0 is a valid value, means that we always return false if
|
|
38039
|
-
// the entire buffer is not flushed immediately on write()
|
|
38040
|
-
var hwm = options.highWaterMark;
|
|
38041
|
-
var writableHwm = options.writableHighWaterMark;
|
|
38042
|
-
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
|
38043
|
-
|
|
38044
|
-
if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
|
|
38045
|
-
|
|
38046
|
-
// cast to ints.
|
|
38047
|
-
this.highWaterMark = Math.floor(this.highWaterMark);
|
|
38048
|
-
|
|
38049
|
-
// if _final has been called
|
|
38050
|
-
this.finalCalled = false;
|
|
38051
|
-
|
|
38052
|
-
// drain event flag.
|
|
38053
|
-
this.needDrain = false;
|
|
38054
|
-
// at the start of calling end()
|
|
38055
|
-
this.ending = false;
|
|
38056
|
-
// when end() has been called, and returned
|
|
38057
|
-
this.ended = false;
|
|
38058
|
-
// when 'finish' is emitted
|
|
38059
|
-
this.finished = false;
|
|
38060
|
-
|
|
38061
|
-
// has it been destroyed
|
|
38062
|
-
this.destroyed = false;
|
|
38063
|
-
|
|
38064
|
-
// should we decode strings into buffers before passing to _write?
|
|
38065
|
-
// this is here so that some node-core streams can optimize string
|
|
38066
|
-
// handling at a lower level.
|
|
38067
|
-
var noDecode = options.decodeStrings === false;
|
|
38068
|
-
this.decodeStrings = !noDecode;
|
|
38069
|
-
|
|
38070
|
-
// Crypto is kind of old and crusty. Historically, its default string
|
|
38071
|
-
// encoding is 'binary' so we have to make this configurable.
|
|
38072
|
-
// Everything else in the universe uses 'utf8', though.
|
|
38073
|
-
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
|
38074
|
-
|
|
38075
|
-
// not an actual buffer we keep track of, but a measurement
|
|
38076
|
-
// of how much we're waiting to get pushed to some underlying
|
|
38077
|
-
// socket or file.
|
|
38078
|
-
this.length = 0;
|
|
38079
|
-
|
|
38080
|
-
// a flag to see when we're in the middle of a write.
|
|
38081
|
-
this.writing = false;
|
|
38082
|
-
|
|
38083
|
-
// when true all writes will be buffered until .uncork() call
|
|
38084
|
-
this.corked = 0;
|
|
38085
|
-
|
|
38086
|
-
// a flag to be able to tell if the onwrite cb is called immediately,
|
|
38087
|
-
// or on a later tick. We set this to true at first, because any
|
|
38088
|
-
// actions that shouldn't happen until "later" should generally also
|
|
38089
|
-
// not happen before the first write call.
|
|
38090
|
-
this.sync = true;
|
|
38091
|
-
|
|
38092
|
-
// a flag to know if we're processing previously buffered items, which
|
|
38093
|
-
// may call the _write() callback in the same tick, so that we don't
|
|
38094
|
-
// end up in an overlapped onwrite situation.
|
|
38095
|
-
this.bufferProcessing = false;
|
|
38096
|
-
|
|
38097
|
-
// the callback that's passed to _write(chunk,cb)
|
|
38098
|
-
this.onwrite = function (er) {
|
|
38099
|
-
onwrite(stream, er);
|
|
38100
|
-
};
|
|
38101
|
-
|
|
38102
|
-
// the callback that the user supplies to write(chunk,encoding,cb)
|
|
38103
|
-
this.writecb = null;
|
|
38104
|
-
|
|
38105
|
-
// the amount that is being written when _write is called.
|
|
38106
|
-
this.writelen = 0;
|
|
38107
|
-
|
|
38108
|
-
this.bufferedRequest = null;
|
|
38109
|
-
this.lastBufferedRequest = null;
|
|
38110
|
-
|
|
38111
|
-
// number of pending user-supplied write callbacks
|
|
38112
|
-
// this must be 0 before 'finish' can be emitted
|
|
38113
|
-
this.pendingcb = 0;
|
|
38114
|
-
|
|
38115
|
-
// emit prefinish if the only thing we're waiting for is _write cbs
|
|
38116
|
-
// This is relevant for synchronous Transform streams
|
|
38117
|
-
this.prefinished = false;
|
|
38118
|
-
|
|
38119
|
-
// True if the error was already emitted and should not be thrown again
|
|
38120
|
-
this.errorEmitted = false;
|
|
38121
|
-
|
|
38122
|
-
// count buffered requests
|
|
38123
|
-
this.bufferedRequestCount = 0;
|
|
38124
|
-
|
|
38125
|
-
// allocate the first CorkedRequest, there is always
|
|
38126
|
-
// one allocated and free to use, and we maintain at most two
|
|
38127
|
-
this.corkedRequestsFree = new CorkedRequest(this);
|
|
38128
|
-
}
|
|
38129
|
-
|
|
38130
|
-
WritableState.prototype.getBuffer = function getBuffer() {
|
|
38131
|
-
var current = this.bufferedRequest;
|
|
38132
|
-
var out = [];
|
|
38133
|
-
while (current) {
|
|
38134
|
-
out.push(current);
|
|
38135
|
-
current = current.next;
|
|
38136
|
-
}
|
|
38137
|
-
return out;
|
|
38138
|
-
};
|
|
38139
|
-
|
|
38140
|
-
(function () {
|
|
38141
|
-
try {
|
|
38142
|
-
Object.defineProperty(WritableState.prototype, 'buffer', {
|
|
38143
|
-
get: internalUtil.deprecate(function () {
|
|
38144
|
-
return this.getBuffer();
|
|
38145
|
-
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
|
|
38146
|
-
});
|
|
38147
|
-
} catch (_) {}
|
|
38148
|
-
})();
|
|
38149
|
-
|
|
38150
|
-
// Test _writableState for inheritance to account for Duplex streams,
|
|
38151
|
-
// whose prototype chain only points to Readable.
|
|
38152
|
-
var realHasInstance;
|
|
38153
|
-
if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
|
|
38154
|
-
realHasInstance = Function.prototype[Symbol.hasInstance];
|
|
38155
|
-
Object.defineProperty(Writable, Symbol.hasInstance, {
|
|
38156
|
-
value: function (object) {
|
|
38157
|
-
if (realHasInstance.call(this, object)) return true;
|
|
38158
|
-
if (this !== Writable) return false;
|
|
38159
|
-
|
|
38160
|
-
return object && object._writableState instanceof WritableState;
|
|
38161
|
-
}
|
|
38162
|
-
});
|
|
38163
|
-
} else {
|
|
38164
|
-
realHasInstance = function (object) {
|
|
38165
|
-
return object instanceof this;
|
|
38166
|
-
};
|
|
38167
|
-
}
|
|
38168
|
-
|
|
38169
|
-
function Writable(options) {
|
|
38170
|
-
Duplex = Duplex || require_stream_duplex();
|
|
38171
|
-
|
|
38172
|
-
// Writable ctor is applied to Duplexes, too.
|
|
38173
|
-
// `realHasInstance` is necessary because using plain `instanceof`
|
|
38174
|
-
// would return false, as no `_writableState` property is attached.
|
|
38175
|
-
|
|
38176
|
-
// Trying to use the custom `instanceof` for Writable here will also break the
|
|
38177
|
-
// Node.js LazyTransform implementation, which has a non-trivial getter for
|
|
38178
|
-
// `_writableState` that would lead to infinite recursion.
|
|
38179
|
-
if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
|
|
38180
|
-
return new Writable(options);
|
|
38181
|
-
}
|
|
38182
|
-
|
|
38183
|
-
this._writableState = new WritableState(options, this);
|
|
38184
|
-
|
|
38185
|
-
// legacy.
|
|
38186
|
-
this.writable = true;
|
|
38187
|
-
|
|
38188
|
-
if (options) {
|
|
38189
|
-
if (typeof options.write === 'function') this._write = options.write;
|
|
38190
|
-
|
|
38191
|
-
if (typeof options.writev === 'function') this._writev = options.writev;
|
|
38192
|
-
|
|
38193
|
-
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
|
38194
|
-
|
|
38195
|
-
if (typeof options.final === 'function') this._final = options.final;
|
|
38196
|
-
}
|
|
38197
|
-
|
|
38198
|
-
Stream.call(this);
|
|
38199
|
-
}
|
|
38200
|
-
|
|
38201
|
-
// Otherwise people can pipe Writable streams, which is just wrong.
|
|
38202
|
-
Writable.prototype.pipe = function () {
|
|
38203
|
-
this.emit('error', new Error('Cannot pipe, not readable'));
|
|
38204
|
-
};
|
|
38205
|
-
|
|
38206
|
-
function writeAfterEnd(stream, cb) {
|
|
38207
|
-
var er = new Error('write after end');
|
|
38208
|
-
// TODO: defer error events consistently everywhere, not just the cb
|
|
38209
|
-
stream.emit('error', er);
|
|
38210
|
-
pna.nextTick(cb, er);
|
|
38211
|
-
}
|
|
38212
|
-
|
|
38213
|
-
// Checks that a user-supplied chunk is valid, especially for the particular
|
|
38214
|
-
// mode the stream is in. Currently this means that `null` is never accepted
|
|
38215
|
-
// and undefined/non-string values are only allowed in object mode.
|
|
38216
|
-
function validChunk(stream, state, chunk, cb) {
|
|
38217
|
-
var valid = true;
|
|
38218
|
-
var er = false;
|
|
38219
|
-
|
|
38220
|
-
if (chunk === null) {
|
|
38221
|
-
er = new TypeError('May not write null values to stream');
|
|
38222
|
-
} else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
|
|
38223
|
-
er = new TypeError('Invalid non-string/buffer chunk');
|
|
38224
|
-
}
|
|
38225
|
-
if (er) {
|
|
38226
|
-
stream.emit('error', er);
|
|
38227
|
-
pna.nextTick(cb, er);
|
|
38228
|
-
valid = false;
|
|
38229
|
-
}
|
|
38230
|
-
return valid;
|
|
38231
|
-
}
|
|
38232
|
-
|
|
38233
|
-
Writable.prototype.write = function (chunk, encoding, cb) {
|
|
38234
|
-
var state = this._writableState;
|
|
38235
|
-
var ret = false;
|
|
38236
|
-
var isBuf = !state.objectMode && _isUint8Array(chunk);
|
|
38237
|
-
|
|
38238
|
-
if (isBuf && !Buffer.isBuffer(chunk)) {
|
|
38239
|
-
chunk = _uint8ArrayToBuffer(chunk);
|
|
38240
|
-
}
|
|
38241
|
-
|
|
38242
|
-
if (typeof encoding === 'function') {
|
|
38243
|
-
cb = encoding;
|
|
38244
|
-
encoding = null;
|
|
38245
|
-
}
|
|
38246
|
-
|
|
38247
|
-
if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
|
|
38248
|
-
|
|
38249
|
-
if (typeof cb !== 'function') cb = nop;
|
|
38250
|
-
|
|
38251
|
-
if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
|
|
38252
|
-
state.pendingcb++;
|
|
38253
|
-
ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
|
|
38254
|
-
}
|
|
38255
|
-
|
|
38256
|
-
return ret;
|
|
38257
|
-
};
|
|
38258
|
-
|
|
38259
|
-
Writable.prototype.cork = function () {
|
|
38260
|
-
var state = this._writableState;
|
|
38261
|
-
|
|
38262
|
-
state.corked++;
|
|
38263
|
-
};
|
|
38264
|
-
|
|
38265
|
-
Writable.prototype.uncork = function () {
|
|
38266
|
-
var state = this._writableState;
|
|
38267
|
-
|
|
38268
|
-
if (state.corked) {
|
|
38269
|
-
state.corked--;
|
|
38270
|
-
|
|
38271
|
-
if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
|
|
38272
|
-
}
|
|
38273
|
-
};
|
|
38274
|
-
|
|
38275
|
-
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
|
38276
|
-
// node::ParseEncoding() requires lower case.
|
|
38277
|
-
if (typeof encoding === 'string') encoding = encoding.toLowerCase();
|
|
38278
|
-
if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
|
|
38279
|
-
this._writableState.defaultEncoding = encoding;
|
|
38280
|
-
return this;
|
|
38281
|
-
};
|
|
38282
|
-
|
|
38283
|
-
function decodeChunk(state, chunk, encoding) {
|
|
38284
|
-
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
|
|
38285
|
-
chunk = Buffer.from(chunk, encoding);
|
|
38286
|
-
}
|
|
38287
|
-
return chunk;
|
|
38288
|
-
}
|
|
38289
|
-
|
|
38290
|
-
Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
|
|
38291
|
-
// making it explicit this property is not enumerable
|
|
38292
|
-
// because otherwise some prototype manipulation in
|
|
38293
|
-
// userland will fail
|
|
38294
|
-
enumerable: false,
|
|
38295
|
-
get: function () {
|
|
38296
|
-
return this._writableState.highWaterMark;
|
|
38297
|
-
}
|
|
38298
|
-
});
|
|
38299
|
-
|
|
38300
|
-
// if we're already writing something, then just put this
|
|
38301
|
-
// in the queue, and wait our turn. Otherwise, call _write
|
|
38302
|
-
// If we return false, then we need a drain event, so set that flag.
|
|
38303
|
-
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
|
|
38304
|
-
if (!isBuf) {
|
|
38305
|
-
var newChunk = decodeChunk(state, chunk, encoding);
|
|
38306
|
-
if (chunk !== newChunk) {
|
|
38307
|
-
isBuf = true;
|
|
38308
|
-
encoding = 'buffer';
|
|
38309
|
-
chunk = newChunk;
|
|
38310
|
-
}
|
|
38311
|
-
}
|
|
38312
|
-
var len = state.objectMode ? 1 : chunk.length;
|
|
38313
|
-
|
|
38314
|
-
state.length += len;
|
|
38315
|
-
|
|
38316
|
-
var ret = state.length < state.highWaterMark;
|
|
38317
|
-
// we must ensure that previous needDrain will not be reset to false.
|
|
38318
|
-
if (!ret) state.needDrain = true;
|
|
38319
|
-
|
|
38320
|
-
if (state.writing || state.corked) {
|
|
38321
|
-
var last = state.lastBufferedRequest;
|
|
38322
|
-
state.lastBufferedRequest = {
|
|
38323
|
-
chunk: chunk,
|
|
38324
|
-
encoding: encoding,
|
|
38325
|
-
isBuf: isBuf,
|
|
38326
|
-
callback: cb,
|
|
38327
|
-
next: null
|
|
38328
|
-
};
|
|
38329
|
-
if (last) {
|
|
38330
|
-
last.next = state.lastBufferedRequest;
|
|
38331
|
-
} else {
|
|
38332
|
-
state.bufferedRequest = state.lastBufferedRequest;
|
|
38333
|
-
}
|
|
38334
|
-
state.bufferedRequestCount += 1;
|
|
38335
|
-
} else {
|
|
38336
|
-
doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
38337
|
-
}
|
|
38338
|
-
|
|
38339
|
-
return ret;
|
|
38340
|
-
}
|
|
38341
|
-
|
|
38342
|
-
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
|
38343
|
-
state.writelen = len;
|
|
38344
|
-
state.writecb = cb;
|
|
38345
|
-
state.writing = true;
|
|
38346
|
-
state.sync = true;
|
|
38347
|
-
if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
|
|
38348
|
-
state.sync = false;
|
|
38349
|
-
}
|
|
38350
|
-
|
|
38351
|
-
function onwriteError(stream, state, sync, er, cb) {
|
|
38352
|
-
--state.pendingcb;
|
|
38353
|
-
|
|
38354
|
-
if (sync) {
|
|
38355
|
-
// defer the callback if we are being called synchronously
|
|
38356
|
-
// to avoid piling up things on the stack
|
|
38357
|
-
pna.nextTick(cb, er);
|
|
38358
|
-
// this can emit finish, and it will always happen
|
|
38359
|
-
// after error
|
|
38360
|
-
pna.nextTick(finishMaybe, stream, state);
|
|
38361
|
-
stream._writableState.errorEmitted = true;
|
|
38362
|
-
stream.emit('error', er);
|
|
38363
|
-
} else {
|
|
38364
|
-
// the caller expect this to happen before if
|
|
38365
|
-
// it is async
|
|
38366
|
-
cb(er);
|
|
38367
|
-
stream._writableState.errorEmitted = true;
|
|
38368
|
-
stream.emit('error', er);
|
|
38369
|
-
// this can emit finish, but finish must
|
|
38370
|
-
// always follow error
|
|
38371
|
-
finishMaybe(stream, state);
|
|
38372
|
-
}
|
|
38373
|
-
}
|
|
38374
|
-
|
|
38375
|
-
function onwriteStateUpdate(state) {
|
|
38376
|
-
state.writing = false;
|
|
38377
|
-
state.writecb = null;
|
|
38378
|
-
state.length -= state.writelen;
|
|
38379
|
-
state.writelen = 0;
|
|
38380
|
-
}
|
|
38381
|
-
|
|
38382
|
-
function onwrite(stream, er) {
|
|
38383
|
-
var state = stream._writableState;
|
|
38384
|
-
var sync = state.sync;
|
|
38385
|
-
var cb = state.writecb;
|
|
38386
|
-
|
|
38387
|
-
onwriteStateUpdate(state);
|
|
38388
|
-
|
|
38389
|
-
if (er) onwriteError(stream, state, sync, er, cb);else {
|
|
38390
|
-
// Check if we're actually ready to finish, but don't emit yet
|
|
38391
|
-
var finished = needFinish(state);
|
|
38392
|
-
|
|
38393
|
-
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
|
|
38394
|
-
clearBuffer(stream, state);
|
|
38395
|
-
}
|
|
38396
|
-
|
|
38397
|
-
if (sync) {
|
|
38398
|
-
/*<replacement>*/
|
|
38399
|
-
asyncWrite(afterWrite, stream, state, finished, cb);
|
|
38400
|
-
/*</replacement>*/
|
|
38401
|
-
} else {
|
|
38402
|
-
afterWrite(stream, state, finished, cb);
|
|
38403
|
-
}
|
|
38404
|
-
}
|
|
38405
|
-
}
|
|
38406
|
-
|
|
38407
|
-
function afterWrite(stream, state, finished, cb) {
|
|
38408
|
-
if (!finished) onwriteDrain(stream, state);
|
|
38409
|
-
state.pendingcb--;
|
|
38410
|
-
cb();
|
|
38411
|
-
finishMaybe(stream, state);
|
|
38412
|
-
}
|
|
38413
|
-
|
|
38414
|
-
// Must force callback to be called on nextTick, so that we don't
|
|
38415
|
-
// emit 'drain' before the write() consumer gets the 'false' return
|
|
38416
|
-
// value, and has a chance to attach a 'drain' listener.
|
|
38417
|
-
function onwriteDrain(stream, state) {
|
|
38418
|
-
if (state.length === 0 && state.needDrain) {
|
|
38419
|
-
state.needDrain = false;
|
|
38420
|
-
stream.emit('drain');
|
|
38421
|
-
}
|
|
38422
|
-
}
|
|
38423
|
-
|
|
38424
|
-
// if there's something in the buffer waiting, then process it
|
|
38425
|
-
function clearBuffer(stream, state) {
|
|
38426
|
-
state.bufferProcessing = true;
|
|
38427
|
-
var entry = state.bufferedRequest;
|
|
38428
|
-
|
|
38429
|
-
if (stream._writev && entry && entry.next) {
|
|
38430
|
-
// Fast case, write everything using _writev()
|
|
38431
|
-
var l = state.bufferedRequestCount;
|
|
38432
|
-
var buffer = new Array(l);
|
|
38433
|
-
var holder = state.corkedRequestsFree;
|
|
38434
|
-
holder.entry = entry;
|
|
38435
|
-
|
|
38436
|
-
var count = 0;
|
|
38437
|
-
var allBuffers = true;
|
|
38438
|
-
while (entry) {
|
|
38439
|
-
buffer[count] = entry;
|
|
38440
|
-
if (!entry.isBuf) allBuffers = false;
|
|
38441
|
-
entry = entry.next;
|
|
38442
|
-
count += 1;
|
|
38443
|
-
}
|
|
38444
|
-
buffer.allBuffers = allBuffers;
|
|
38445
|
-
|
|
38446
|
-
doWrite(stream, state, true, state.length, buffer, '', holder.finish);
|
|
38447
|
-
|
|
38448
|
-
// doWrite is almost always async, defer these to save a bit of time
|
|
38449
|
-
// as the hot path ends with doWrite
|
|
38450
|
-
state.pendingcb++;
|
|
38451
|
-
state.lastBufferedRequest = null;
|
|
38452
|
-
if (holder.next) {
|
|
38453
|
-
state.corkedRequestsFree = holder.next;
|
|
38454
|
-
holder.next = null;
|
|
38455
|
-
} else {
|
|
38456
|
-
state.corkedRequestsFree = new CorkedRequest(state);
|
|
38457
|
-
}
|
|
38458
|
-
state.bufferedRequestCount = 0;
|
|
38459
|
-
} else {
|
|
38460
|
-
// Slow case, write chunks one-by-one
|
|
38461
|
-
while (entry) {
|
|
38462
|
-
var chunk = entry.chunk;
|
|
38463
|
-
var encoding = entry.encoding;
|
|
38464
|
-
var cb = entry.callback;
|
|
38465
|
-
var len = state.objectMode ? 1 : chunk.length;
|
|
38466
|
-
|
|
38467
|
-
doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
38468
|
-
entry = entry.next;
|
|
38469
|
-
state.bufferedRequestCount--;
|
|
38470
|
-
// if we didn't call the onwrite immediately, then
|
|
38471
|
-
// it means that we need to wait until it does.
|
|
38472
|
-
// also, that means that the chunk and cb are currently
|
|
38473
|
-
// being processed, so move the buffer counter past them.
|
|
38474
|
-
if (state.writing) {
|
|
38475
|
-
break;
|
|
38476
|
-
}
|
|
38477
|
-
}
|
|
38478
|
-
|
|
38479
|
-
if (entry === null) state.lastBufferedRequest = null;
|
|
38480
|
-
}
|
|
38481
|
-
|
|
38482
|
-
state.bufferedRequest = entry;
|
|
38483
|
-
state.bufferProcessing = false;
|
|
38484
|
-
}
|
|
38485
|
-
|
|
38486
|
-
Writable.prototype._write = function (chunk, encoding, cb) {
|
|
38487
|
-
cb(new Error('_write() is not implemented'));
|
|
38488
|
-
};
|
|
38489
|
-
|
|
38490
|
-
Writable.prototype._writev = null;
|
|
38491
|
-
|
|
38492
|
-
Writable.prototype.end = function (chunk, encoding, cb) {
|
|
38493
|
-
var state = this._writableState;
|
|
38494
|
-
|
|
38495
|
-
if (typeof chunk === 'function') {
|
|
38496
|
-
cb = chunk;
|
|
38497
|
-
chunk = null;
|
|
38498
|
-
encoding = null;
|
|
38499
|
-
} else if (typeof encoding === 'function') {
|
|
38500
|
-
cb = encoding;
|
|
38501
|
-
encoding = null;
|
|
38502
|
-
}
|
|
38503
|
-
|
|
38504
|
-
if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
|
|
38505
|
-
|
|
38506
|
-
// .end() fully uncorks
|
|
38507
|
-
if (state.corked) {
|
|
38508
|
-
state.corked = 1;
|
|
38509
|
-
this.uncork();
|
|
38510
|
-
}
|
|
38511
|
-
|
|
38512
|
-
// ignore unnecessary end() calls.
|
|
38513
|
-
if (!state.ending && !state.finished) endWritable(this, state, cb);
|
|
38514
|
-
};
|
|
38515
|
-
|
|
38516
|
-
function needFinish(state) {
|
|
38517
|
-
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
|
38518
|
-
}
|
|
38519
|
-
function callFinal(stream, state) {
|
|
38520
|
-
stream._final(function (err) {
|
|
38521
|
-
state.pendingcb--;
|
|
38522
|
-
if (err) {
|
|
38523
|
-
stream.emit('error', err);
|
|
38524
|
-
}
|
|
38525
|
-
state.prefinished = true;
|
|
38526
|
-
stream.emit('prefinish');
|
|
38527
|
-
finishMaybe(stream, state);
|
|
38528
|
-
});
|
|
38529
|
-
}
|
|
38530
|
-
function prefinish(stream, state) {
|
|
38531
|
-
if (!state.prefinished && !state.finalCalled) {
|
|
38532
|
-
if (typeof stream._final === 'function') {
|
|
38533
|
-
state.pendingcb++;
|
|
38534
|
-
state.finalCalled = true;
|
|
38535
|
-
pna.nextTick(callFinal, stream, state);
|
|
38536
|
-
} else {
|
|
38537
|
-
state.prefinished = true;
|
|
38538
|
-
stream.emit('prefinish');
|
|
38539
|
-
}
|
|
38540
|
-
}
|
|
38541
|
-
}
|
|
38542
|
-
|
|
38543
|
-
function finishMaybe(stream, state) {
|
|
38544
|
-
var need = needFinish(state);
|
|
38545
|
-
if (need) {
|
|
38546
|
-
prefinish(stream, state);
|
|
38547
|
-
if (state.pendingcb === 0) {
|
|
38548
|
-
state.finished = true;
|
|
38549
|
-
stream.emit('finish');
|
|
38550
|
-
}
|
|
38551
|
-
}
|
|
38552
|
-
return need;
|
|
38553
|
-
}
|
|
38554
|
-
|
|
38555
|
-
function endWritable(stream, state, cb) {
|
|
38556
|
-
state.ending = true;
|
|
38557
|
-
finishMaybe(stream, state);
|
|
38558
|
-
if (cb) {
|
|
38559
|
-
if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
|
|
38560
|
-
}
|
|
38561
|
-
state.ended = true;
|
|
38562
|
-
stream.writable = false;
|
|
38563
|
-
}
|
|
38564
|
-
|
|
38565
|
-
function onCorkedFinish(corkReq, state, err) {
|
|
38566
|
-
var entry = corkReq.entry;
|
|
38567
|
-
corkReq.entry = null;
|
|
38568
|
-
while (entry) {
|
|
38569
|
-
var cb = entry.callback;
|
|
38570
|
-
state.pendingcb--;
|
|
38571
|
-
cb(err);
|
|
38572
|
-
entry = entry.next;
|
|
38573
|
-
}
|
|
38574
|
-
if (state.corkedRequestsFree) {
|
|
38575
|
-
state.corkedRequestsFree.next = corkReq;
|
|
38576
|
-
} else {
|
|
38577
|
-
state.corkedRequestsFree = corkReq;
|
|
38578
|
-
}
|
|
38579
|
-
}
|
|
38580
|
-
|
|
38581
|
-
Object.defineProperty(Writable.prototype, 'destroyed', {
|
|
38582
|
-
get: function () {
|
|
38583
|
-
if (this._writableState === undefined) {
|
|
38584
|
-
return false;
|
|
38585
|
-
}
|
|
38586
|
-
return this._writableState.destroyed;
|
|
38587
|
-
},
|
|
38588
|
-
set: function (value) {
|
|
38589
|
-
// we ignore the value if the stream
|
|
38590
|
-
// has not been initialized yet
|
|
38591
|
-
if (!this._writableState) {
|
|
38592
|
-
return;
|
|
38593
|
-
}
|
|
38594
|
-
|
|
38595
|
-
// backward compatibility, the user is explicitly
|
|
38596
|
-
// managing destroyed
|
|
38597
|
-
this._writableState.destroyed = value;
|
|
38598
|
-
}
|
|
38599
|
-
});
|
|
38600
|
-
|
|
38601
|
-
Writable.prototype.destroy = destroyImpl.destroy;
|
|
38602
|
-
Writable.prototype._undestroy = destroyImpl.undestroy;
|
|
38603
|
-
Writable.prototype._destroy = function (err, cb) {
|
|
38604
|
-
this.end();
|
|
38605
|
-
cb(err);
|
|
38606
|
-
};
|
|
38607
|
-
return _stream_writable;
|
|
38608
|
-
}
|
|
38609
|
-
|
|
38610
|
-
var _stream_duplex;
|
|
38611
|
-
var hasRequired_stream_duplex;
|
|
38612
|
-
|
|
38613
|
-
function require_stream_duplex () {
|
|
38614
|
-
if (hasRequired_stream_duplex) return _stream_duplex;
|
|
38615
|
-
hasRequired_stream_duplex = 1;
|
|
38616
|
-
|
|
38617
|
-
/*<replacement>*/
|
|
38618
|
-
|
|
38619
|
-
var pna = requireProcessNextickArgs();
|
|
38620
|
-
/*</replacement>*/
|
|
38621
|
-
|
|
38622
|
-
/*<replacement>*/
|
|
38623
|
-
var objectKeys = Object.keys || function (obj) {
|
|
38624
|
-
var keys = [];
|
|
38625
|
-
for (var key in obj) {
|
|
38626
|
-
keys.push(key);
|
|
38627
|
-
}return keys;
|
|
38628
|
-
};
|
|
38629
|
-
/*</replacement>*/
|
|
38630
|
-
|
|
38631
|
-
_stream_duplex = Duplex;
|
|
38632
|
-
|
|
38633
|
-
/*<replacement>*/
|
|
38634
|
-
var util = Object.create(util$4);
|
|
38635
|
-
util.inherits = require$$2$2;
|
|
38636
|
-
/*</replacement>*/
|
|
38637
|
-
|
|
38638
|
-
var Readable = require_stream_readable();
|
|
38639
|
-
var Writable = require_stream_writable();
|
|
38640
|
-
|
|
38641
|
-
util.inherits(Duplex, Readable);
|
|
38642
|
-
|
|
38643
|
-
{
|
|
38644
|
-
// avoid scope creep, the keys array can then be collected
|
|
38645
|
-
var keys = objectKeys(Writable.prototype);
|
|
38646
|
-
for (var v = 0; v < keys.length; v++) {
|
|
38647
|
-
var method = keys[v];
|
|
38648
|
-
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
|
|
38649
|
-
}
|
|
38650
|
-
}
|
|
38651
|
-
|
|
38652
|
-
function Duplex(options) {
|
|
38653
|
-
if (!(this instanceof Duplex)) return new Duplex(options);
|
|
38654
|
-
|
|
38655
|
-
Readable.call(this, options);
|
|
38656
|
-
Writable.call(this, options);
|
|
38657
|
-
|
|
38658
|
-
if (options && options.readable === false) this.readable = false;
|
|
38659
|
-
|
|
38660
|
-
if (options && options.writable === false) this.writable = false;
|
|
38661
|
-
|
|
38662
|
-
this.allowHalfOpen = true;
|
|
38663
|
-
if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
|
|
38664
|
-
|
|
38665
|
-
this.once('end', onend);
|
|
38666
|
-
}
|
|
38667
|
-
|
|
38668
|
-
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
|
|
38669
|
-
// making it explicit this property is not enumerable
|
|
38670
|
-
// because otherwise some prototype manipulation in
|
|
38671
|
-
// userland will fail
|
|
38672
|
-
enumerable: false,
|
|
38673
|
-
get: function () {
|
|
38674
|
-
return this._writableState.highWaterMark;
|
|
38675
|
-
}
|
|
38676
|
-
});
|
|
38677
|
-
|
|
38678
|
-
// the no-half-open enforcer
|
|
38679
|
-
function onend() {
|
|
38680
|
-
// if we allow half-open state, or if the writable side ended,
|
|
38681
|
-
// then we're ok.
|
|
38682
|
-
if (this.allowHalfOpen || this._writableState.ended) return;
|
|
38683
|
-
|
|
38684
|
-
// no more data can be written.
|
|
38685
|
-
// But allow more writes to happen in this tick.
|
|
38686
|
-
pna.nextTick(onEndNT, this);
|
|
38687
|
-
}
|
|
38688
|
-
|
|
38689
|
-
function onEndNT(self) {
|
|
38690
|
-
self.end();
|
|
38691
|
-
}
|
|
38692
|
-
|
|
38693
|
-
Object.defineProperty(Duplex.prototype, 'destroyed', {
|
|
38694
|
-
get: function () {
|
|
38695
|
-
if (this._readableState === undefined || this._writableState === undefined) {
|
|
38696
|
-
return false;
|
|
38697
|
-
}
|
|
38698
|
-
return this._readableState.destroyed && this._writableState.destroyed;
|
|
38699
|
-
},
|
|
38700
|
-
set: function (value) {
|
|
38701
|
-
// we ignore the value if the stream
|
|
38702
|
-
// has not been initialized yet
|
|
38703
|
-
if (this._readableState === undefined || this._writableState === undefined) {
|
|
38704
|
-
return;
|
|
38705
|
-
}
|
|
38706
|
-
|
|
38707
|
-
// backward compatibility, the user is explicitly
|
|
38708
|
-
// managing destroyed
|
|
38709
|
-
this._readableState.destroyed = value;
|
|
38710
|
-
this._writableState.destroyed = value;
|
|
38711
|
-
}
|
|
38712
|
-
});
|
|
38713
|
-
|
|
38714
|
-
Duplex.prototype._destroy = function (err, cb) {
|
|
38715
|
-
this.push(null);
|
|
38716
|
-
this.end();
|
|
38717
|
-
|
|
38718
|
-
pna.nextTick(cb, err);
|
|
38719
|
-
};
|
|
38720
|
-
return _stream_duplex;
|
|
38721
|
-
}
|
|
38722
|
-
|
|
38723
|
-
var _stream_readable;
|
|
38724
|
-
var hasRequired_stream_readable;
|
|
38725
|
-
|
|
38726
|
-
function require_stream_readable () {
|
|
38727
|
-
if (hasRequired_stream_readable) return _stream_readable;
|
|
38728
|
-
hasRequired_stream_readable = 1;
|
|
38729
|
-
|
|
38730
|
-
/*<replacement>*/
|
|
38731
|
-
|
|
38732
|
-
var pna = requireProcessNextickArgs();
|
|
38733
|
-
/*</replacement>*/
|
|
38734
|
-
|
|
38735
|
-
_stream_readable = Readable;
|
|
38736
|
-
|
|
38737
|
-
/*<replacement>*/
|
|
38738
|
-
var isArray = requireIsarray();
|
|
38739
|
-
/*</replacement>*/
|
|
38740
|
-
|
|
38741
|
-
/*<replacement>*/
|
|
38742
|
-
var Duplex;
|
|
38743
|
-
/*</replacement>*/
|
|
38744
|
-
|
|
38745
|
-
Readable.ReadableState = ReadableState;
|
|
38746
|
-
|
|
38747
|
-
/*<replacement>*/
|
|
38748
|
-
require$$0$3.EventEmitter;
|
|
38749
|
-
|
|
38750
|
-
var EElistenerCount = function (emitter, type) {
|
|
38751
|
-
return emitter.listeners(type).length;
|
|
38752
|
-
};
|
|
38753
|
-
/*</replacement>*/
|
|
38754
|
-
|
|
38755
|
-
/*<replacement>*/
|
|
38756
|
-
var Stream = requireStreamBrowser();
|
|
38757
|
-
/*</replacement>*/
|
|
38758
|
-
|
|
38759
|
-
/*<replacement>*/
|
|
38760
|
-
|
|
38761
|
-
var Buffer = requireSafeBuffer().Buffer;
|
|
38762
|
-
var OurUint8Array = commonjsGlobal.Uint8Array || function () {};
|
|
38763
|
-
function _uint8ArrayToBuffer(chunk) {
|
|
38764
|
-
return Buffer.from(chunk);
|
|
38765
|
-
}
|
|
38766
|
-
function _isUint8Array(obj) {
|
|
38767
|
-
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
38768
|
-
}
|
|
38769
|
-
|
|
38770
|
-
/*</replacement>*/
|
|
38771
|
-
|
|
38772
|
-
/*<replacement>*/
|
|
38773
|
-
var util = Object.create(util$4);
|
|
38774
|
-
util.inherits = require$$2$2;
|
|
38775
|
-
/*</replacement>*/
|
|
38776
|
-
|
|
38777
|
-
/*<replacement>*/
|
|
38778
|
-
var debugUtil = require$$7;
|
|
38779
|
-
var debug = void 0;
|
|
38780
|
-
if (debugUtil && debugUtil.debuglog) {
|
|
38781
|
-
debug = debugUtil.debuglog('stream');
|
|
38782
|
-
} else {
|
|
38783
|
-
debug = function () {};
|
|
38784
|
-
}
|
|
38785
|
-
/*</replacement>*/
|
|
38786
|
-
|
|
38787
|
-
var BufferList = requireBufferList();
|
|
38788
|
-
var destroyImpl = requireDestroy();
|
|
38789
|
-
var StringDecoder;
|
|
38790
|
-
|
|
38791
|
-
util.inherits(Readable, Stream);
|
|
38792
|
-
|
|
38793
|
-
var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
|
|
38794
|
-
|
|
38795
|
-
function prependListener(emitter, event, fn) {
|
|
38796
|
-
// Sadly this is not cacheable as some libraries bundle their own
|
|
38797
|
-
// event emitter implementation with them.
|
|
38798
|
-
if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
|
|
38799
|
-
|
|
38800
|
-
// This is a hack to make sure that our error handler is attached before any
|
|
38801
|
-
// userland ones. NEVER DO THIS. This is here only because this code needs
|
|
38802
|
-
// to continue to work with older versions of Node.js that do not include
|
|
38803
|
-
// the prependListener() method. The goal is to eventually remove this hack.
|
|
38804
|
-
if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
|
|
38805
|
-
}
|
|
38806
|
-
|
|
38807
|
-
function ReadableState(options, stream) {
|
|
38808
|
-
Duplex = Duplex || require_stream_duplex();
|
|
38809
|
-
|
|
38810
|
-
options = options || {};
|
|
38811
|
-
|
|
38812
|
-
// Duplex streams are both readable and writable, but share
|
|
38813
|
-
// the same options object.
|
|
38814
|
-
// However, some cases require setting options to different
|
|
38815
|
-
// values for the readable and the writable sides of the duplex stream.
|
|
38816
|
-
// These options can be provided separately as readableXXX and writableXXX.
|
|
38817
|
-
var isDuplex = stream instanceof Duplex;
|
|
38818
|
-
|
|
38819
|
-
// object stream flag. Used to make read(n) ignore n and to
|
|
38820
|
-
// make all the buffer merging and length checks go away
|
|
38821
|
-
this.objectMode = !!options.objectMode;
|
|
38822
|
-
|
|
38823
|
-
if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
|
|
38824
|
-
|
|
38825
|
-
// the point at which it stops calling _read() to fill the buffer
|
|
38826
|
-
// Note: 0 is a valid value, means "don't call _read preemptively ever"
|
|
38827
|
-
var hwm = options.highWaterMark;
|
|
38828
|
-
var readableHwm = options.readableHighWaterMark;
|
|
38829
|
-
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
|
38830
|
-
|
|
38831
|
-
if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
|
|
38832
|
-
|
|
38833
|
-
// cast to ints.
|
|
38834
|
-
this.highWaterMark = Math.floor(this.highWaterMark);
|
|
38835
|
-
|
|
38836
|
-
// A linked list is used to store data chunks instead of an array because the
|
|
38837
|
-
// linked list can remove elements from the beginning faster than
|
|
38838
|
-
// array.shift()
|
|
38839
|
-
this.buffer = new BufferList();
|
|
38840
|
-
this.length = 0;
|
|
38841
|
-
this.pipes = null;
|
|
38842
|
-
this.pipesCount = 0;
|
|
38843
|
-
this.flowing = null;
|
|
38844
|
-
this.ended = false;
|
|
38845
|
-
this.endEmitted = false;
|
|
38846
|
-
this.reading = false;
|
|
38847
|
-
|
|
38848
|
-
// a flag to be able to tell if the event 'readable'/'data' is emitted
|
|
38849
|
-
// immediately, or on a later tick. We set this to true at first, because
|
|
38850
|
-
// any actions that shouldn't happen until "later" should generally also
|
|
38851
|
-
// not happen before the first read call.
|
|
38852
|
-
this.sync = true;
|
|
38853
|
-
|
|
38854
|
-
// whenever we return null, then we set a flag to say
|
|
38855
|
-
// that we're awaiting a 'readable' event emission.
|
|
38856
|
-
this.needReadable = false;
|
|
38857
|
-
this.emittedReadable = false;
|
|
38858
|
-
this.readableListening = false;
|
|
38859
|
-
this.resumeScheduled = false;
|
|
38860
|
-
|
|
38861
|
-
// has it been destroyed
|
|
38862
|
-
this.destroyed = false;
|
|
38863
|
-
|
|
38864
|
-
// Crypto is kind of old and crusty. Historically, its default string
|
|
38865
|
-
// encoding is 'binary' so we have to make this configurable.
|
|
38866
|
-
// Everything else in the universe uses 'utf8', though.
|
|
38867
|
-
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
|
38868
|
-
|
|
38869
|
-
// the number of writers that are awaiting a drain event in .pipe()s
|
|
38870
|
-
this.awaitDrain = 0;
|
|
38871
|
-
|
|
38872
|
-
// if true, a maybeReadMore has been scheduled
|
|
38873
|
-
this.readingMore = false;
|
|
38874
|
-
|
|
38875
|
-
this.decoder = null;
|
|
38876
|
-
this.encoding = null;
|
|
38877
|
-
if (options.encoding) {
|
|
38878
|
-
if (!StringDecoder) StringDecoder = require$$11.StringDecoder;
|
|
38879
|
-
this.decoder = new StringDecoder(options.encoding);
|
|
38880
|
-
this.encoding = options.encoding;
|
|
38881
|
-
}
|
|
38882
|
-
}
|
|
38883
|
-
|
|
38884
|
-
function Readable(options) {
|
|
38885
|
-
Duplex = Duplex || require_stream_duplex();
|
|
38886
|
-
|
|
38887
|
-
if (!(this instanceof Readable)) return new Readable(options);
|
|
38888
|
-
|
|
38889
|
-
this._readableState = new ReadableState(options, this);
|
|
38890
|
-
|
|
38891
|
-
// legacy
|
|
38892
|
-
this.readable = true;
|
|
38893
|
-
|
|
38894
|
-
if (options) {
|
|
38895
|
-
if (typeof options.read === 'function') this._read = options.read;
|
|
38896
|
-
|
|
38897
|
-
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
|
38898
|
-
}
|
|
38899
|
-
|
|
38900
|
-
Stream.call(this);
|
|
38901
|
-
}
|
|
38902
|
-
|
|
38903
|
-
Object.defineProperty(Readable.prototype, 'destroyed', {
|
|
38904
|
-
get: function () {
|
|
38905
|
-
if (this._readableState === undefined) {
|
|
38906
|
-
return false;
|
|
38907
|
-
}
|
|
38908
|
-
return this._readableState.destroyed;
|
|
38909
|
-
},
|
|
38910
|
-
set: function (value) {
|
|
38911
|
-
// we ignore the value if the stream
|
|
38912
|
-
// has not been initialized yet
|
|
38913
|
-
if (!this._readableState) {
|
|
38914
|
-
return;
|
|
38915
|
-
}
|
|
38916
|
-
|
|
38917
|
-
// backward compatibility, the user is explicitly
|
|
38918
|
-
// managing destroyed
|
|
38919
|
-
this._readableState.destroyed = value;
|
|
38920
|
-
}
|
|
38921
|
-
});
|
|
38922
|
-
|
|
38923
|
-
Readable.prototype.destroy = destroyImpl.destroy;
|
|
38924
|
-
Readable.prototype._undestroy = destroyImpl.undestroy;
|
|
38925
|
-
Readable.prototype._destroy = function (err, cb) {
|
|
38926
|
-
this.push(null);
|
|
38927
|
-
cb(err);
|
|
38928
|
-
};
|
|
38929
|
-
|
|
38930
|
-
// Manually shove something into the read() buffer.
|
|
38931
|
-
// This returns true if the highWaterMark has not been hit yet,
|
|
38932
|
-
// similar to how Writable.write() returns true if you should
|
|
38933
|
-
// write() some more.
|
|
38934
|
-
Readable.prototype.push = function (chunk, encoding) {
|
|
38935
|
-
var state = this._readableState;
|
|
38936
|
-
var skipChunkCheck;
|
|
38937
|
-
|
|
38938
|
-
if (!state.objectMode) {
|
|
38939
|
-
if (typeof chunk === 'string') {
|
|
38940
|
-
encoding = encoding || state.defaultEncoding;
|
|
38941
|
-
if (encoding !== state.encoding) {
|
|
38942
|
-
chunk = Buffer.from(chunk, encoding);
|
|
38943
|
-
encoding = '';
|
|
38944
|
-
}
|
|
38945
|
-
skipChunkCheck = true;
|
|
38946
|
-
}
|
|
38947
|
-
} else {
|
|
38948
|
-
skipChunkCheck = true;
|
|
38949
|
-
}
|
|
38950
|
-
|
|
38951
|
-
return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
|
|
38952
|
-
};
|
|
38953
|
-
|
|
38954
|
-
// Unshift should *always* be something directly out of read()
|
|
38955
|
-
Readable.prototype.unshift = function (chunk) {
|
|
38956
|
-
return readableAddChunk(this, chunk, null, true, false);
|
|
38957
|
-
};
|
|
38958
|
-
|
|
38959
|
-
function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
|
|
38960
|
-
var state = stream._readableState;
|
|
38961
|
-
if (chunk === null) {
|
|
38962
|
-
state.reading = false;
|
|
38963
|
-
onEofChunk(stream, state);
|
|
38964
|
-
} else {
|
|
38965
|
-
var er;
|
|
38966
|
-
if (!skipChunkCheck) er = chunkInvalid(state, chunk);
|
|
38967
|
-
if (er) {
|
|
38968
|
-
stream.emit('error', er);
|
|
38969
|
-
} else if (state.objectMode || chunk && chunk.length > 0) {
|
|
38970
|
-
if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
|
|
38971
|
-
chunk = _uint8ArrayToBuffer(chunk);
|
|
38972
|
-
}
|
|
38973
|
-
|
|
38974
|
-
if (addToFront) {
|
|
38975
|
-
if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
|
|
38976
|
-
} else if (state.ended) {
|
|
38977
|
-
stream.emit('error', new Error('stream.push() after EOF'));
|
|
38978
|
-
} else {
|
|
38979
|
-
state.reading = false;
|
|
38980
|
-
if (state.decoder && !encoding) {
|
|
38981
|
-
chunk = state.decoder.write(chunk);
|
|
38982
|
-
if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
|
|
38983
|
-
} else {
|
|
38984
|
-
addChunk(stream, state, chunk, false);
|
|
38985
|
-
}
|
|
38986
|
-
}
|
|
38987
|
-
} else if (!addToFront) {
|
|
38988
|
-
state.reading = false;
|
|
38989
|
-
}
|
|
38990
|
-
}
|
|
38991
|
-
|
|
38992
|
-
return needMoreData(state);
|
|
38993
|
-
}
|
|
38994
|
-
|
|
38995
|
-
function addChunk(stream, state, chunk, addToFront) {
|
|
38996
|
-
if (state.flowing && state.length === 0 && !state.sync) {
|
|
38997
|
-
stream.emit('data', chunk);
|
|
38998
|
-
stream.read(0);
|
|
38999
|
-
} else {
|
|
39000
|
-
// update the buffer info.
|
|
39001
|
-
state.length += state.objectMode ? 1 : chunk.length;
|
|
39002
|
-
if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
|
|
39003
|
-
|
|
39004
|
-
if (state.needReadable) emitReadable(stream);
|
|
39005
|
-
}
|
|
39006
|
-
maybeReadMore(stream, state);
|
|
39007
|
-
}
|
|
39008
|
-
|
|
39009
|
-
function chunkInvalid(state, chunk) {
|
|
39010
|
-
var er;
|
|
39011
|
-
if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
|
|
39012
|
-
er = new TypeError('Invalid non-string/buffer chunk');
|
|
39013
|
-
}
|
|
39014
|
-
return er;
|
|
39015
|
-
}
|
|
39016
|
-
|
|
39017
|
-
// if it's past the high water mark, we can push in some more.
|
|
39018
|
-
// Also, if we have no data yet, we can stand some
|
|
39019
|
-
// more bytes. This is to work around cases where hwm=0,
|
|
39020
|
-
// such as the repl. Also, if the push() triggered a
|
|
39021
|
-
// readable event, and the user called read(largeNumber) such that
|
|
39022
|
-
// needReadable was set, then we ought to push more, so that another
|
|
39023
|
-
// 'readable' event will be triggered.
|
|
39024
|
-
function needMoreData(state) {
|
|
39025
|
-
return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
|
|
39026
|
-
}
|
|
39027
|
-
|
|
39028
|
-
Readable.prototype.isPaused = function () {
|
|
39029
|
-
return this._readableState.flowing === false;
|
|
39030
|
-
};
|
|
39031
|
-
|
|
39032
|
-
// backwards compatibility.
|
|
39033
|
-
Readable.prototype.setEncoding = function (enc) {
|
|
39034
|
-
if (!StringDecoder) StringDecoder = require$$11.StringDecoder;
|
|
39035
|
-
this._readableState.decoder = new StringDecoder(enc);
|
|
39036
|
-
this._readableState.encoding = enc;
|
|
39037
|
-
return this;
|
|
39038
|
-
};
|
|
39039
|
-
|
|
39040
|
-
// Don't raise the hwm > 8MB
|
|
39041
|
-
var MAX_HWM = 0x800000;
|
|
39042
|
-
function computeNewHighWaterMark(n) {
|
|
39043
|
-
if (n >= MAX_HWM) {
|
|
39044
|
-
n = MAX_HWM;
|
|
39045
|
-
} else {
|
|
39046
|
-
// Get the next highest power of 2 to prevent increasing hwm excessively in
|
|
39047
|
-
// tiny amounts
|
|
39048
|
-
n--;
|
|
39049
|
-
n |= n >>> 1;
|
|
39050
|
-
n |= n >>> 2;
|
|
39051
|
-
n |= n >>> 4;
|
|
39052
|
-
n |= n >>> 8;
|
|
39053
|
-
n |= n >>> 16;
|
|
39054
|
-
n++;
|
|
39055
|
-
}
|
|
39056
|
-
return n;
|
|
39057
|
-
}
|
|
39058
|
-
|
|
39059
|
-
// This function is designed to be inlinable, so please take care when making
|
|
39060
|
-
// changes to the function body.
|
|
39061
|
-
function howMuchToRead(n, state) {
|
|
39062
|
-
if (n <= 0 || state.length === 0 && state.ended) return 0;
|
|
39063
|
-
if (state.objectMode) return 1;
|
|
39064
|
-
if (n !== n) {
|
|
39065
|
-
// Only flow one buffer at a time
|
|
39066
|
-
if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
|
|
39067
|
-
}
|
|
39068
|
-
// If we're asking for more than the current hwm, then raise the hwm.
|
|
39069
|
-
if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
|
|
39070
|
-
if (n <= state.length) return n;
|
|
39071
|
-
// Don't have enough
|
|
39072
|
-
if (!state.ended) {
|
|
39073
|
-
state.needReadable = true;
|
|
39074
|
-
return 0;
|
|
39075
|
-
}
|
|
39076
|
-
return state.length;
|
|
39077
|
-
}
|
|
39078
|
-
|
|
39079
|
-
// you can override either this method, or the async _read(n) below.
|
|
39080
|
-
Readable.prototype.read = function (n) {
|
|
39081
|
-
debug('read', n);
|
|
39082
|
-
n = parseInt(n, 10);
|
|
39083
|
-
var state = this._readableState;
|
|
39084
|
-
var nOrig = n;
|
|
39085
|
-
|
|
39086
|
-
if (n !== 0) state.emittedReadable = false;
|
|
39087
|
-
|
|
39088
|
-
// if we're doing read(0) to trigger a readable event, but we
|
|
39089
|
-
// already have a bunch of data in the buffer, then just trigger
|
|
39090
|
-
// the 'readable' event and move on.
|
|
39091
|
-
if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
|
|
39092
|
-
debug('read: emitReadable', state.length, state.ended);
|
|
39093
|
-
if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
|
|
39094
|
-
return null;
|
|
39095
|
-
}
|
|
39096
|
-
|
|
39097
|
-
n = howMuchToRead(n, state);
|
|
39098
|
-
|
|
39099
|
-
// if we've ended, and we're now clear, then finish it up.
|
|
39100
|
-
if (n === 0 && state.ended) {
|
|
39101
|
-
if (state.length === 0) endReadable(this);
|
|
39102
|
-
return null;
|
|
39103
|
-
}
|
|
39104
|
-
|
|
39105
|
-
// All the actual chunk generation logic needs to be
|
|
39106
|
-
// *below* the call to _read. The reason is that in certain
|
|
39107
|
-
// synthetic stream cases, such as passthrough streams, _read
|
|
39108
|
-
// may be a completely synchronous operation which may change
|
|
39109
|
-
// the state of the read buffer, providing enough data when
|
|
39110
|
-
// before there was *not* enough.
|
|
39111
|
-
//
|
|
39112
|
-
// So, the steps are:
|
|
39113
|
-
// 1. Figure out what the state of things will be after we do
|
|
39114
|
-
// a read from the buffer.
|
|
39115
|
-
//
|
|
39116
|
-
// 2. If that resulting state will trigger a _read, then call _read.
|
|
39117
|
-
// Note that this may be asynchronous, or synchronous. Yes, it is
|
|
39118
|
-
// deeply ugly to write APIs this way, but that still doesn't mean
|
|
39119
|
-
// that the Readable class should behave improperly, as streams are
|
|
39120
|
-
// designed to be sync/async agnostic.
|
|
39121
|
-
// Take note if the _read call is sync or async (ie, if the read call
|
|
39122
|
-
// has returned yet), so that we know whether or not it's safe to emit
|
|
39123
|
-
// 'readable' etc.
|
|
39124
|
-
//
|
|
39125
|
-
// 3. Actually pull the requested chunks out of the buffer and return.
|
|
39126
|
-
|
|
39127
|
-
// if we need a readable event, then we need to do some reading.
|
|
39128
|
-
var doRead = state.needReadable;
|
|
39129
|
-
debug('need readable', doRead);
|
|
39130
|
-
|
|
39131
|
-
// if we currently have less than the highWaterMark, then also read some
|
|
39132
|
-
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
|
39133
|
-
doRead = true;
|
|
39134
|
-
debug('length less than watermark', doRead);
|
|
39135
|
-
}
|
|
39136
|
-
|
|
39137
|
-
// however, if we've ended, then there's no point, and if we're already
|
|
39138
|
-
// reading, then it's unnecessary.
|
|
39139
|
-
if (state.ended || state.reading) {
|
|
39140
|
-
doRead = false;
|
|
39141
|
-
debug('reading or ended', doRead);
|
|
39142
|
-
} else if (doRead) {
|
|
39143
|
-
debug('do read');
|
|
39144
|
-
state.reading = true;
|
|
39145
|
-
state.sync = true;
|
|
39146
|
-
// if the length is currently zero, then we *need* a readable event.
|
|
39147
|
-
if (state.length === 0) state.needReadable = true;
|
|
39148
|
-
// call internal read method
|
|
39149
|
-
this._read(state.highWaterMark);
|
|
39150
|
-
state.sync = false;
|
|
39151
|
-
// If _read pushed data synchronously, then `reading` will be false,
|
|
39152
|
-
// and we need to re-evaluate how much data we can return to the user.
|
|
39153
|
-
if (!state.reading) n = howMuchToRead(nOrig, state);
|
|
39154
|
-
}
|
|
39155
|
-
|
|
39156
|
-
var ret;
|
|
39157
|
-
if (n > 0) ret = fromList(n, state);else ret = null;
|
|
39158
|
-
|
|
39159
|
-
if (ret === null) {
|
|
39160
|
-
state.needReadable = true;
|
|
39161
|
-
n = 0;
|
|
39162
|
-
} else {
|
|
39163
|
-
state.length -= n;
|
|
39164
|
-
}
|
|
39165
|
-
|
|
39166
|
-
if (state.length === 0) {
|
|
39167
|
-
// If we have nothing in the buffer, then we want to know
|
|
39168
|
-
// as soon as we *do* get something into the buffer.
|
|
39169
|
-
if (!state.ended) state.needReadable = true;
|
|
39170
|
-
|
|
39171
|
-
// If we tried to read() past the EOF, then emit end on the next tick.
|
|
39172
|
-
if (nOrig !== n && state.ended) endReadable(this);
|
|
39173
|
-
}
|
|
39174
|
-
|
|
39175
|
-
if (ret !== null) this.emit('data', ret);
|
|
39176
|
-
|
|
39177
|
-
return ret;
|
|
39178
|
-
};
|
|
39179
|
-
|
|
39180
|
-
function onEofChunk(stream, state) {
|
|
39181
|
-
if (state.ended) return;
|
|
39182
|
-
if (state.decoder) {
|
|
39183
|
-
var chunk = state.decoder.end();
|
|
39184
|
-
if (chunk && chunk.length) {
|
|
39185
|
-
state.buffer.push(chunk);
|
|
39186
|
-
state.length += state.objectMode ? 1 : chunk.length;
|
|
39187
|
-
}
|
|
39188
|
-
}
|
|
39189
|
-
state.ended = true;
|
|
39190
|
-
|
|
39191
|
-
// emit 'readable' now to make sure it gets picked up.
|
|
39192
|
-
emitReadable(stream);
|
|
39193
|
-
}
|
|
39194
|
-
|
|
39195
|
-
// Don't emit readable right away in sync mode, because this can trigger
|
|
39196
|
-
// another read() call => stack overflow. This way, it might trigger
|
|
39197
|
-
// a nextTick recursion warning, but that's not so bad.
|
|
39198
|
-
function emitReadable(stream) {
|
|
39199
|
-
var state = stream._readableState;
|
|
39200
|
-
state.needReadable = false;
|
|
39201
|
-
if (!state.emittedReadable) {
|
|
39202
|
-
debug('emitReadable', state.flowing);
|
|
39203
|
-
state.emittedReadable = true;
|
|
39204
|
-
if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
|
|
39205
|
-
}
|
|
39206
|
-
}
|
|
39207
|
-
|
|
39208
|
-
function emitReadable_(stream) {
|
|
39209
|
-
debug('emit readable');
|
|
39210
|
-
stream.emit('readable');
|
|
39211
|
-
flow(stream);
|
|
39212
|
-
}
|
|
39213
|
-
|
|
39214
|
-
// at this point, the user has presumably seen the 'readable' event,
|
|
39215
|
-
// and called read() to consume some data. that may have triggered
|
|
39216
|
-
// in turn another _read(n) call, in which case reading = true if
|
|
39217
|
-
// it's in progress.
|
|
39218
|
-
// However, if we're not ended, or reading, and the length < hwm,
|
|
39219
|
-
// then go ahead and try to read some more preemptively.
|
|
39220
|
-
function maybeReadMore(stream, state) {
|
|
39221
|
-
if (!state.readingMore) {
|
|
39222
|
-
state.readingMore = true;
|
|
39223
|
-
pna.nextTick(maybeReadMore_, stream, state);
|
|
39224
|
-
}
|
|
39225
|
-
}
|
|
39226
|
-
|
|
39227
|
-
function maybeReadMore_(stream, state) {
|
|
39228
|
-
var len = state.length;
|
|
39229
|
-
while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
|
|
39230
|
-
debug('maybeReadMore read 0');
|
|
39231
|
-
stream.read(0);
|
|
39232
|
-
if (len === state.length)
|
|
39233
|
-
// didn't get any data, stop spinning.
|
|
39234
|
-
break;else len = state.length;
|
|
39235
|
-
}
|
|
39236
|
-
state.readingMore = false;
|
|
39237
|
-
}
|
|
39238
|
-
|
|
39239
|
-
// abstract method. to be overridden in specific implementation classes.
|
|
39240
|
-
// call cb(er, data) where data is <= n in length.
|
|
39241
|
-
// for virtual (non-string, non-buffer) streams, "length" is somewhat
|
|
39242
|
-
// arbitrary, and perhaps not very meaningful.
|
|
39243
|
-
Readable.prototype._read = function (n) {
|
|
39244
|
-
this.emit('error', new Error('_read() is not implemented'));
|
|
39245
|
-
};
|
|
39246
|
-
|
|
39247
|
-
Readable.prototype.pipe = function (dest, pipeOpts) {
|
|
39248
|
-
var src = this;
|
|
39249
|
-
var state = this._readableState;
|
|
39250
|
-
|
|
39251
|
-
switch (state.pipesCount) {
|
|
39252
|
-
case 0:
|
|
39253
|
-
state.pipes = dest;
|
|
39254
|
-
break;
|
|
39255
|
-
case 1:
|
|
39256
|
-
state.pipes = [state.pipes, dest];
|
|
39257
|
-
break;
|
|
39258
|
-
default:
|
|
39259
|
-
state.pipes.push(dest);
|
|
39260
|
-
break;
|
|
39261
|
-
}
|
|
39262
|
-
state.pipesCount += 1;
|
|
39263
|
-
debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
|
|
39264
|
-
|
|
39265
|
-
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== browser$1$1.stdout && dest !== browser$1$1.stderr;
|
|
39266
|
-
|
|
39267
|
-
var endFn = doEnd ? onend : unpipe;
|
|
39268
|
-
if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
|
|
39269
|
-
|
|
39270
|
-
dest.on('unpipe', onunpipe);
|
|
39271
|
-
function onunpipe(readable, unpipeInfo) {
|
|
39272
|
-
debug('onunpipe');
|
|
39273
|
-
if (readable === src) {
|
|
39274
|
-
if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
|
|
39275
|
-
unpipeInfo.hasUnpiped = true;
|
|
39276
|
-
cleanup();
|
|
39277
|
-
}
|
|
39278
|
-
}
|
|
39279
|
-
}
|
|
39280
|
-
|
|
39281
|
-
function onend() {
|
|
39282
|
-
debug('onend');
|
|
39283
|
-
dest.end();
|
|
39284
|
-
}
|
|
39285
|
-
|
|
39286
|
-
// when the dest drains, it reduces the awaitDrain counter
|
|
39287
|
-
// on the source. This would be more elegant with a .once()
|
|
39288
|
-
// handler in flow(), but adding and removing repeatedly is
|
|
39289
|
-
// too slow.
|
|
39290
|
-
var ondrain = pipeOnDrain(src);
|
|
39291
|
-
dest.on('drain', ondrain);
|
|
39292
|
-
|
|
39293
|
-
var cleanedUp = false;
|
|
39294
|
-
function cleanup() {
|
|
39295
|
-
debug('cleanup');
|
|
39296
|
-
// cleanup event handlers once the pipe is broken
|
|
39297
|
-
dest.removeListener('close', onclose);
|
|
39298
|
-
dest.removeListener('finish', onfinish);
|
|
39299
|
-
dest.removeListener('drain', ondrain);
|
|
39300
|
-
dest.removeListener('error', onerror);
|
|
39301
|
-
dest.removeListener('unpipe', onunpipe);
|
|
39302
|
-
src.removeListener('end', onend);
|
|
39303
|
-
src.removeListener('end', unpipe);
|
|
39304
|
-
src.removeListener('data', ondata);
|
|
39305
|
-
|
|
39306
|
-
cleanedUp = true;
|
|
39307
|
-
|
|
39308
|
-
// if the reader is waiting for a drain event from this
|
|
39309
|
-
// specific writer, then it would cause it to never start
|
|
39310
|
-
// flowing again.
|
|
39311
|
-
// So, if this is awaiting a drain, then we just call it now.
|
|
39312
|
-
// If we don't know, then assume that we are waiting for one.
|
|
39313
|
-
if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
|
|
39314
|
-
}
|
|
39315
|
-
|
|
39316
|
-
// If the user pushes more data while we're writing to dest then we'll end up
|
|
39317
|
-
// in ondata again. However, we only want to increase awaitDrain once because
|
|
39318
|
-
// dest will only emit one 'drain' event for the multiple writes.
|
|
39319
|
-
// => Introduce a guard on increasing awaitDrain.
|
|
39320
|
-
var increasedAwaitDrain = false;
|
|
39321
|
-
src.on('data', ondata);
|
|
39322
|
-
function ondata(chunk) {
|
|
39323
|
-
debug('ondata');
|
|
39324
|
-
increasedAwaitDrain = false;
|
|
39325
|
-
var ret = dest.write(chunk);
|
|
39326
|
-
if (false === ret && !increasedAwaitDrain) {
|
|
39327
|
-
// If the user unpiped during `dest.write()`, it is possible
|
|
39328
|
-
// to get stuck in a permanently paused state if that write
|
|
39329
|
-
// also returned false.
|
|
39330
|
-
// => Check whether `dest` is still a piping destination.
|
|
39331
|
-
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
|
|
39332
|
-
debug('false write response, pause', src._readableState.awaitDrain);
|
|
39333
|
-
src._readableState.awaitDrain++;
|
|
39334
|
-
increasedAwaitDrain = true;
|
|
39335
|
-
}
|
|
39336
|
-
src.pause();
|
|
39337
|
-
}
|
|
39338
|
-
}
|
|
39339
|
-
|
|
39340
|
-
// if the dest has an error, then stop piping into it.
|
|
39341
|
-
// however, don't suppress the throwing behavior for this.
|
|
39342
|
-
function onerror(er) {
|
|
39343
|
-
debug('onerror', er);
|
|
39344
|
-
unpipe();
|
|
39345
|
-
dest.removeListener('error', onerror);
|
|
39346
|
-
if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
|
|
39347
|
-
}
|
|
39348
|
-
|
|
39349
|
-
// Make sure our error handler is attached before userland ones.
|
|
39350
|
-
prependListener(dest, 'error', onerror);
|
|
39351
|
-
|
|
39352
|
-
// Both close and finish should trigger unpipe, but only once.
|
|
39353
|
-
function onclose() {
|
|
39354
|
-
dest.removeListener('finish', onfinish);
|
|
39355
|
-
unpipe();
|
|
39356
|
-
}
|
|
39357
|
-
dest.once('close', onclose);
|
|
39358
|
-
function onfinish() {
|
|
39359
|
-
debug('onfinish');
|
|
39360
|
-
dest.removeListener('close', onclose);
|
|
39361
|
-
unpipe();
|
|
39362
|
-
}
|
|
39363
|
-
dest.once('finish', onfinish);
|
|
39364
|
-
|
|
39365
|
-
function unpipe() {
|
|
39366
|
-
debug('unpipe');
|
|
39367
|
-
src.unpipe(dest);
|
|
39368
|
-
}
|
|
39369
|
-
|
|
39370
|
-
// tell the dest that it's being piped to
|
|
39371
|
-
dest.emit('pipe', src);
|
|
39372
|
-
|
|
39373
|
-
// start the flow if it hasn't been started already.
|
|
39374
|
-
if (!state.flowing) {
|
|
39375
|
-
debug('pipe resume');
|
|
39376
|
-
src.resume();
|
|
39377
|
-
}
|
|
39378
|
-
|
|
39379
|
-
return dest;
|
|
39380
|
-
};
|
|
39381
|
-
|
|
39382
|
-
function pipeOnDrain(src) {
|
|
39383
|
-
return function () {
|
|
39384
|
-
var state = src._readableState;
|
|
39385
|
-
debug('pipeOnDrain', state.awaitDrain);
|
|
39386
|
-
if (state.awaitDrain) state.awaitDrain--;
|
|
39387
|
-
if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
|
|
39388
|
-
state.flowing = true;
|
|
39389
|
-
flow(src);
|
|
39390
|
-
}
|
|
39391
|
-
};
|
|
39392
|
-
}
|
|
39393
|
-
|
|
39394
|
-
Readable.prototype.unpipe = function (dest) {
|
|
39395
|
-
var state = this._readableState;
|
|
39396
|
-
var unpipeInfo = { hasUnpiped: false };
|
|
39397
|
-
|
|
39398
|
-
// if we're not piping anywhere, then do nothing.
|
|
39399
|
-
if (state.pipesCount === 0) return this;
|
|
39400
|
-
|
|
39401
|
-
// just one destination. most common case.
|
|
39402
|
-
if (state.pipesCount === 1) {
|
|
39403
|
-
// passed in one, but it's not the right one.
|
|
39404
|
-
if (dest && dest !== state.pipes) return this;
|
|
39405
|
-
|
|
39406
|
-
if (!dest) dest = state.pipes;
|
|
39407
|
-
|
|
39408
|
-
// got a match.
|
|
39409
|
-
state.pipes = null;
|
|
39410
|
-
state.pipesCount = 0;
|
|
39411
|
-
state.flowing = false;
|
|
39412
|
-
if (dest) dest.emit('unpipe', this, unpipeInfo);
|
|
39413
|
-
return this;
|
|
39414
|
-
}
|
|
39415
|
-
|
|
39416
|
-
// slow case. multiple pipe destinations.
|
|
39417
|
-
|
|
39418
|
-
if (!dest) {
|
|
39419
|
-
// remove all.
|
|
39420
|
-
var dests = state.pipes;
|
|
39421
|
-
var len = state.pipesCount;
|
|
39422
|
-
state.pipes = null;
|
|
39423
|
-
state.pipesCount = 0;
|
|
39424
|
-
state.flowing = false;
|
|
39425
|
-
|
|
39426
|
-
for (var i = 0; i < len; i++) {
|
|
39427
|
-
dests[i].emit('unpipe', this, unpipeInfo);
|
|
39428
|
-
}return this;
|
|
39429
|
-
}
|
|
39430
|
-
|
|
39431
|
-
// try to find the right one.
|
|
39432
|
-
var index = indexOf(state.pipes, dest);
|
|
39433
|
-
if (index === -1) return this;
|
|
39434
|
-
|
|
39435
|
-
state.pipes.splice(index, 1);
|
|
39436
|
-
state.pipesCount -= 1;
|
|
39437
|
-
if (state.pipesCount === 1) state.pipes = state.pipes[0];
|
|
39438
|
-
|
|
39439
|
-
dest.emit('unpipe', this, unpipeInfo);
|
|
39440
|
-
|
|
39441
|
-
return this;
|
|
39442
|
-
};
|
|
39443
|
-
|
|
39444
|
-
// set up data events if they are asked for
|
|
39445
|
-
// Ensure readable listeners eventually get something
|
|
39446
|
-
Readable.prototype.on = function (ev, fn) {
|
|
39447
|
-
var res = Stream.prototype.on.call(this, ev, fn);
|
|
39448
|
-
|
|
39449
|
-
if (ev === 'data') {
|
|
39450
|
-
// Start flowing on next tick if stream isn't explicitly paused
|
|
39451
|
-
if (this._readableState.flowing !== false) this.resume();
|
|
39452
|
-
} else if (ev === 'readable') {
|
|
39453
|
-
var state = this._readableState;
|
|
39454
|
-
if (!state.endEmitted && !state.readableListening) {
|
|
39455
|
-
state.readableListening = state.needReadable = true;
|
|
39456
|
-
state.emittedReadable = false;
|
|
39457
|
-
if (!state.reading) {
|
|
39458
|
-
pna.nextTick(nReadingNextTick, this);
|
|
39459
|
-
} else if (state.length) {
|
|
39460
|
-
emitReadable(this);
|
|
39461
|
-
}
|
|
39462
|
-
}
|
|
39463
|
-
}
|
|
39464
|
-
|
|
39465
|
-
return res;
|
|
39466
|
-
};
|
|
39467
|
-
Readable.prototype.addListener = Readable.prototype.on;
|
|
39468
|
-
|
|
39469
|
-
function nReadingNextTick(self) {
|
|
39470
|
-
debug('readable nexttick read 0');
|
|
39471
|
-
self.read(0);
|
|
39472
|
-
}
|
|
39473
|
-
|
|
39474
|
-
// pause() and resume() are remnants of the legacy readable stream API
|
|
39475
|
-
// If the user uses them, then switch into old mode.
|
|
39476
|
-
Readable.prototype.resume = function () {
|
|
39477
|
-
var state = this._readableState;
|
|
39478
|
-
if (!state.flowing) {
|
|
39479
|
-
debug('resume');
|
|
39480
|
-
state.flowing = true;
|
|
39481
|
-
resume(this, state);
|
|
39482
|
-
}
|
|
39483
|
-
return this;
|
|
39484
|
-
};
|
|
39485
|
-
|
|
39486
|
-
function resume(stream, state) {
|
|
39487
|
-
if (!state.resumeScheduled) {
|
|
39488
|
-
state.resumeScheduled = true;
|
|
39489
|
-
pna.nextTick(resume_, stream, state);
|
|
39490
|
-
}
|
|
39491
|
-
}
|
|
39492
|
-
|
|
39493
|
-
function resume_(stream, state) {
|
|
39494
|
-
if (!state.reading) {
|
|
39495
|
-
debug('resume read 0');
|
|
39496
|
-
stream.read(0);
|
|
39497
|
-
}
|
|
39498
|
-
|
|
39499
|
-
state.resumeScheduled = false;
|
|
39500
|
-
state.awaitDrain = 0;
|
|
39501
|
-
stream.emit('resume');
|
|
39502
|
-
flow(stream);
|
|
39503
|
-
if (state.flowing && !state.reading) stream.read(0);
|
|
39504
|
-
}
|
|
39505
|
-
|
|
39506
|
-
Readable.prototype.pause = function () {
|
|
39507
|
-
debug('call pause flowing=%j', this._readableState.flowing);
|
|
39508
|
-
if (false !== this._readableState.flowing) {
|
|
39509
|
-
debug('pause');
|
|
39510
|
-
this._readableState.flowing = false;
|
|
39511
|
-
this.emit('pause');
|
|
39512
|
-
}
|
|
39513
|
-
return this;
|
|
39514
|
-
};
|
|
39515
|
-
|
|
39516
|
-
function flow(stream) {
|
|
39517
|
-
var state = stream._readableState;
|
|
39518
|
-
debug('flow', state.flowing);
|
|
39519
|
-
while (state.flowing && stream.read() !== null) {}
|
|
39520
|
-
}
|
|
39521
|
-
|
|
39522
|
-
// wrap an old-style stream as the async data source.
|
|
39523
|
-
// This is *not* part of the readable stream interface.
|
|
39524
|
-
// It is an ugly unfortunate mess of history.
|
|
39525
|
-
Readable.prototype.wrap = function (stream) {
|
|
39526
|
-
var _this = this;
|
|
39527
|
-
|
|
39528
|
-
var state = this._readableState;
|
|
39529
|
-
var paused = false;
|
|
39530
|
-
|
|
39531
|
-
stream.on('end', function () {
|
|
39532
|
-
debug('wrapped end');
|
|
39533
|
-
if (state.decoder && !state.ended) {
|
|
39534
|
-
var chunk = state.decoder.end();
|
|
39535
|
-
if (chunk && chunk.length) _this.push(chunk);
|
|
39536
|
-
}
|
|
39537
|
-
|
|
39538
|
-
_this.push(null);
|
|
39539
|
-
});
|
|
39540
|
-
|
|
39541
|
-
stream.on('data', function (chunk) {
|
|
39542
|
-
debug('wrapped data');
|
|
39543
|
-
if (state.decoder) chunk = state.decoder.write(chunk);
|
|
39544
|
-
|
|
39545
|
-
// don't skip over falsy values in objectMode
|
|
39546
|
-
if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
|
|
39547
|
-
|
|
39548
|
-
var ret = _this.push(chunk);
|
|
39549
|
-
if (!ret) {
|
|
39550
|
-
paused = true;
|
|
39551
|
-
stream.pause();
|
|
39552
|
-
}
|
|
39553
|
-
});
|
|
39554
|
-
|
|
39555
|
-
// proxy all the other methods.
|
|
39556
|
-
// important when wrapping filters and duplexes.
|
|
39557
|
-
for (var i in stream) {
|
|
39558
|
-
if (this[i] === undefined && typeof stream[i] === 'function') {
|
|
39559
|
-
this[i] = function (method) {
|
|
39560
|
-
return function () {
|
|
39561
|
-
return stream[method].apply(stream, arguments);
|
|
39562
|
-
};
|
|
39563
|
-
}(i);
|
|
39564
|
-
}
|
|
39565
|
-
}
|
|
39566
|
-
|
|
39567
|
-
// proxy certain important events.
|
|
39568
|
-
for (var n = 0; n < kProxyEvents.length; n++) {
|
|
39569
|
-
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
|
|
39570
|
-
}
|
|
39571
|
-
|
|
39572
|
-
// when we try to consume some more bytes, simply unpause the
|
|
39573
|
-
// underlying stream.
|
|
39574
|
-
this._read = function (n) {
|
|
39575
|
-
debug('wrapped _read', n);
|
|
39576
|
-
if (paused) {
|
|
39577
|
-
paused = false;
|
|
39578
|
-
stream.resume();
|
|
39579
|
-
}
|
|
39580
|
-
};
|
|
39581
|
-
|
|
39582
|
-
return this;
|
|
39583
|
-
};
|
|
39584
|
-
|
|
39585
|
-
Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
|
|
39586
|
-
// making it explicit this property is not enumerable
|
|
39587
|
-
// because otherwise some prototype manipulation in
|
|
39588
|
-
// userland will fail
|
|
39589
|
-
enumerable: false,
|
|
39590
|
-
get: function () {
|
|
39591
|
-
return this._readableState.highWaterMark;
|
|
39592
|
-
}
|
|
39593
|
-
});
|
|
39594
|
-
|
|
39595
|
-
// exposed for testing purposes only.
|
|
39596
|
-
Readable._fromList = fromList;
|
|
39597
|
-
|
|
39598
|
-
// Pluck off n bytes from an array of buffers.
|
|
39599
|
-
// Length is the combined lengths of all the buffers in the list.
|
|
39600
|
-
// This function is designed to be inlinable, so please take care when making
|
|
39601
|
-
// changes to the function body.
|
|
39602
|
-
function fromList(n, state) {
|
|
39603
|
-
// nothing buffered
|
|
39604
|
-
if (state.length === 0) return null;
|
|
39605
|
-
|
|
39606
|
-
var ret;
|
|
39607
|
-
if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
|
|
39608
|
-
// read it all, truncate the list
|
|
39609
|
-
if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
|
|
39610
|
-
state.buffer.clear();
|
|
39611
|
-
} else {
|
|
39612
|
-
// read part of list
|
|
39613
|
-
ret = fromListPartial(n, state.buffer, state.decoder);
|
|
39614
|
-
}
|
|
39615
|
-
|
|
39616
|
-
return ret;
|
|
39617
|
-
}
|
|
39618
|
-
|
|
39619
|
-
// Extracts only enough buffered data to satisfy the amount requested.
|
|
39620
|
-
// This function is designed to be inlinable, so please take care when making
|
|
39621
|
-
// changes to the function body.
|
|
39622
|
-
function fromListPartial(n, list, hasStrings) {
|
|
39623
|
-
var ret;
|
|
39624
|
-
if (n < list.head.data.length) {
|
|
39625
|
-
// slice is the same for buffers and strings
|
|
39626
|
-
ret = list.head.data.slice(0, n);
|
|
39627
|
-
list.head.data = list.head.data.slice(n);
|
|
39628
|
-
} else if (n === list.head.data.length) {
|
|
39629
|
-
// first chunk is a perfect match
|
|
39630
|
-
ret = list.shift();
|
|
39631
|
-
} else {
|
|
39632
|
-
// result spans more than one buffer
|
|
39633
|
-
ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
|
|
39634
|
-
}
|
|
39635
|
-
return ret;
|
|
39636
|
-
}
|
|
39637
|
-
|
|
39638
|
-
// Copies a specified amount of characters from the list of buffered data
|
|
39639
|
-
// chunks.
|
|
39640
|
-
// This function is designed to be inlinable, so please take care when making
|
|
39641
|
-
// changes to the function body.
|
|
39642
|
-
function copyFromBufferString(n, list) {
|
|
39643
|
-
var p = list.head;
|
|
39644
|
-
var c = 1;
|
|
39645
|
-
var ret = p.data;
|
|
39646
|
-
n -= ret.length;
|
|
39647
|
-
while (p = p.next) {
|
|
39648
|
-
var str = p.data;
|
|
39649
|
-
var nb = n > str.length ? str.length : n;
|
|
39650
|
-
if (nb === str.length) ret += str;else ret += str.slice(0, n);
|
|
39651
|
-
n -= nb;
|
|
39652
|
-
if (n === 0) {
|
|
39653
|
-
if (nb === str.length) {
|
|
39654
|
-
++c;
|
|
39655
|
-
if (p.next) list.head = p.next;else list.head = list.tail = null;
|
|
39656
|
-
} else {
|
|
39657
|
-
list.head = p;
|
|
39658
|
-
p.data = str.slice(nb);
|
|
39659
|
-
}
|
|
39660
|
-
break;
|
|
39661
|
-
}
|
|
39662
|
-
++c;
|
|
39663
|
-
}
|
|
39664
|
-
list.length -= c;
|
|
39665
|
-
return ret;
|
|
39666
|
-
}
|
|
39667
|
-
|
|
39668
|
-
// Copies a specified amount of bytes from the list of buffered data chunks.
|
|
39669
|
-
// This function is designed to be inlinable, so please take care when making
|
|
39670
|
-
// changes to the function body.
|
|
39671
|
-
function copyFromBuffer(n, list) {
|
|
39672
|
-
var ret = Buffer.allocUnsafe(n);
|
|
39673
|
-
var p = list.head;
|
|
39674
|
-
var c = 1;
|
|
39675
|
-
p.data.copy(ret);
|
|
39676
|
-
n -= p.data.length;
|
|
39677
|
-
while (p = p.next) {
|
|
39678
|
-
var buf = p.data;
|
|
39679
|
-
var nb = n > buf.length ? buf.length : n;
|
|
39680
|
-
buf.copy(ret, ret.length - n, 0, nb);
|
|
39681
|
-
n -= nb;
|
|
39682
|
-
if (n === 0) {
|
|
39683
|
-
if (nb === buf.length) {
|
|
39684
|
-
++c;
|
|
39685
|
-
if (p.next) list.head = p.next;else list.head = list.tail = null;
|
|
39686
|
-
} else {
|
|
39687
|
-
list.head = p;
|
|
39688
|
-
p.data = buf.slice(nb);
|
|
39689
|
-
}
|
|
39690
|
-
break;
|
|
39691
|
-
}
|
|
39692
|
-
++c;
|
|
39693
|
-
}
|
|
39694
|
-
list.length -= c;
|
|
39695
|
-
return ret;
|
|
39696
|
-
}
|
|
39697
|
-
|
|
39698
|
-
function endReadable(stream) {
|
|
39699
|
-
var state = stream._readableState;
|
|
39700
|
-
|
|
39701
|
-
// If we get here before consuming all the bytes, then that is a
|
|
39702
|
-
// bug in node. Should never happen.
|
|
39703
|
-
if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
|
|
39704
|
-
|
|
39705
|
-
if (!state.endEmitted) {
|
|
39706
|
-
state.ended = true;
|
|
39707
|
-
pna.nextTick(endReadableNT, state, stream);
|
|
39708
|
-
}
|
|
39709
|
-
}
|
|
39710
|
-
|
|
39711
|
-
function endReadableNT(state, stream) {
|
|
39712
|
-
// Check that we didn't get one last unshift.
|
|
39713
|
-
if (!state.endEmitted && state.length === 0) {
|
|
39714
|
-
state.endEmitted = true;
|
|
39715
|
-
stream.readable = false;
|
|
39716
|
-
stream.emit('end');
|
|
39717
|
-
}
|
|
39718
|
-
}
|
|
39719
|
-
|
|
39720
|
-
function indexOf(xs, x) {
|
|
39721
|
-
for (var i = 0, l = xs.length; i < l; i++) {
|
|
39722
|
-
if (xs[i] === x) return i;
|
|
39723
|
-
}
|
|
39724
|
-
return -1;
|
|
39725
|
-
}
|
|
39726
|
-
return _stream_readable;
|
|
39727
|
-
}
|
|
39728
|
-
|
|
39729
|
-
var _stream_transform = Transform$1;
|
|
39730
|
-
|
|
39731
|
-
var Duplex = require_stream_duplex();
|
|
39732
|
-
|
|
39733
|
-
/*<replacement>*/
|
|
39734
|
-
var util$1 = Object.create(util$4);
|
|
39735
|
-
util$1.inherits = require$$2$2;
|
|
39736
|
-
/*</replacement>*/
|
|
39737
|
-
|
|
39738
|
-
util$1.inherits(Transform$1, Duplex);
|
|
39739
|
-
|
|
39740
|
-
function afterTransform(er, data) {
|
|
39741
|
-
var ts = this._transformState;
|
|
39742
|
-
ts.transforming = false;
|
|
39743
|
-
|
|
39744
|
-
var cb = ts.writecb;
|
|
39745
|
-
|
|
39746
|
-
if (!cb) {
|
|
39747
|
-
return this.emit('error', new Error('write callback called multiple times'));
|
|
39748
|
-
}
|
|
39749
|
-
|
|
39750
|
-
ts.writechunk = null;
|
|
39751
|
-
ts.writecb = null;
|
|
39752
|
-
|
|
39753
|
-
if (data != null) // single equals check for both `null` and `undefined`
|
|
39754
|
-
this.push(data);
|
|
39755
|
-
|
|
39756
|
-
cb(er);
|
|
39757
|
-
|
|
39758
|
-
var rs = this._readableState;
|
|
39759
|
-
rs.reading = false;
|
|
39760
|
-
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
|
39761
|
-
this._read(rs.highWaterMark);
|
|
39762
|
-
}
|
|
39763
|
-
}
|
|
39764
|
-
|
|
39765
|
-
function Transform$1(options) {
|
|
39766
|
-
if (!(this instanceof Transform$1)) return new Transform$1(options);
|
|
39767
|
-
|
|
39768
|
-
Duplex.call(this, options);
|
|
39769
|
-
|
|
39770
|
-
this._transformState = {
|
|
39771
|
-
afterTransform: afterTransform.bind(this),
|
|
39772
|
-
needTransform: false,
|
|
39773
|
-
transforming: false,
|
|
39774
|
-
writecb: null,
|
|
39775
|
-
writechunk: null,
|
|
39776
|
-
writeencoding: null
|
|
39777
|
-
};
|
|
39778
|
-
|
|
39779
|
-
// start out asking for a readable event once data is transformed.
|
|
39780
|
-
this._readableState.needReadable = true;
|
|
39781
|
-
|
|
39782
|
-
// we have implemented the _read method, and done the other things
|
|
39783
|
-
// that Readable wants before the first _read call, so unset the
|
|
39784
|
-
// sync guard flag.
|
|
39785
|
-
this._readableState.sync = false;
|
|
39786
|
-
|
|
39787
|
-
if (options) {
|
|
39788
|
-
if (typeof options.transform === 'function') this._transform = options.transform;
|
|
39789
|
-
|
|
39790
|
-
if (typeof options.flush === 'function') this._flush = options.flush;
|
|
39791
|
-
}
|
|
39792
|
-
|
|
39793
|
-
// When the writable side finishes, then flush out anything remaining.
|
|
39794
|
-
this.on('prefinish', prefinish);
|
|
39795
|
-
}
|
|
39796
|
-
|
|
39797
|
-
function prefinish() {
|
|
39798
|
-
var _this = this;
|
|
39799
|
-
|
|
39800
|
-
if (typeof this._flush === 'function') {
|
|
39801
|
-
this._flush(function (er, data) {
|
|
39802
|
-
done(_this, er, data);
|
|
39803
|
-
});
|
|
39804
|
-
} else {
|
|
39805
|
-
done(this, null, null);
|
|
39806
|
-
}
|
|
39807
|
-
}
|
|
39808
|
-
|
|
39809
|
-
Transform$1.prototype.push = function (chunk, encoding) {
|
|
39810
|
-
this._transformState.needTransform = false;
|
|
39811
|
-
return Duplex.prototype.push.call(this, chunk, encoding);
|
|
39812
|
-
};
|
|
39813
|
-
|
|
39814
|
-
// This is the part where you do stuff!
|
|
39815
|
-
// override this function in implementation classes.
|
|
39816
|
-
// 'chunk' is an input chunk.
|
|
39817
|
-
//
|
|
39818
|
-
// Call `push(newChunk)` to pass along transformed output
|
|
39819
|
-
// to the readable side. You may call 'push' zero or more times.
|
|
39820
|
-
//
|
|
39821
|
-
// Call `cb(err)` when you are done with this chunk. If you pass
|
|
39822
|
-
// an error, then that'll put the hurt on the whole operation. If you
|
|
39823
|
-
// never call cb(), then you'll never get another chunk.
|
|
39824
|
-
Transform$1.prototype._transform = function (chunk, encoding, cb) {
|
|
39825
|
-
throw new Error('_transform() is not implemented');
|
|
39826
|
-
};
|
|
39827
|
-
|
|
39828
|
-
Transform$1.prototype._write = function (chunk, encoding, cb) {
|
|
39829
|
-
var ts = this._transformState;
|
|
39830
|
-
ts.writecb = cb;
|
|
39831
|
-
ts.writechunk = chunk;
|
|
39832
|
-
ts.writeencoding = encoding;
|
|
39833
|
-
if (!ts.transforming) {
|
|
39834
|
-
var rs = this._readableState;
|
|
39835
|
-
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
|
|
39836
|
-
}
|
|
39837
|
-
};
|
|
39838
|
-
|
|
39839
|
-
// Doesn't matter what the args are here.
|
|
39840
|
-
// _transform does all the work.
|
|
39841
|
-
// That we got here means that the readable side wants more data.
|
|
39842
|
-
Transform$1.prototype._read = function (n) {
|
|
39843
|
-
var ts = this._transformState;
|
|
39844
|
-
|
|
39845
|
-
if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
|
|
39846
|
-
ts.transforming = true;
|
|
39847
|
-
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
|
39848
|
-
} else {
|
|
39849
|
-
// mark that we need a transform, so that any data that comes in
|
|
39850
|
-
// will get processed, now that we've asked for it.
|
|
39851
|
-
ts.needTransform = true;
|
|
39852
|
-
}
|
|
39853
|
-
};
|
|
39854
|
-
|
|
39855
|
-
Transform$1.prototype._destroy = function (err, cb) {
|
|
39856
|
-
var _this2 = this;
|
|
39857
|
-
|
|
39858
|
-
Duplex.prototype._destroy.call(this, err, function (err2) {
|
|
39859
|
-
cb(err2);
|
|
39860
|
-
_this2.emit('close');
|
|
39861
|
-
});
|
|
39862
|
-
};
|
|
39863
|
-
|
|
39864
|
-
function done(stream, er, data) {
|
|
39865
|
-
if (er) return stream.emit('error', er);
|
|
39866
|
-
|
|
39867
|
-
if (data != null) // single equals check for both `null` and `undefined`
|
|
39868
|
-
stream.push(data);
|
|
39869
|
-
|
|
39870
|
-
// if there's nothing in the write buffer, then that means
|
|
39871
|
-
// that nothing more will ever be provided
|
|
39872
|
-
if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
|
|
39873
|
-
|
|
39874
|
-
if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
|
|
39875
|
-
|
|
39876
|
-
return stream.push(null);
|
|
39877
|
-
}
|
|
39878
|
-
|
|
39879
|
-
var _stream_passthrough = PassThrough;
|
|
39880
|
-
|
|
39881
|
-
var Transform = _stream_transform;
|
|
39882
|
-
|
|
39883
|
-
/*<replacement>*/
|
|
39884
|
-
var util = Object.create(util$4);
|
|
39885
|
-
util.inherits = require$$2$2;
|
|
39886
|
-
/*</replacement>*/
|
|
39887
|
-
|
|
39888
|
-
util.inherits(PassThrough, Transform);
|
|
39889
|
-
|
|
39890
|
-
function PassThrough(options) {
|
|
39891
|
-
if (!(this instanceof PassThrough)) return new PassThrough(options);
|
|
39892
|
-
|
|
39893
|
-
Transform.call(this, options);
|
|
39894
|
-
}
|
|
39895
|
-
|
|
39896
|
-
PassThrough.prototype._transform = function (chunk, encoding, cb) {
|
|
39897
|
-
cb(null, chunk);
|
|
39898
|
-
};
|
|
39899
|
-
|
|
39900
|
-
(function (module, exports) {
|
|
39901
|
-
exports = module.exports = require_stream_readable();
|
|
39902
|
-
exports.Stream = exports;
|
|
39903
|
-
exports.Readable = exports;
|
|
39904
|
-
exports.Writable = require_stream_writable();
|
|
39905
|
-
exports.Duplex = require_stream_duplex();
|
|
39906
|
-
exports.Transform = _stream_transform;
|
|
39907
|
-
exports.PassThrough = _stream_passthrough;
|
|
39908
|
-
} (readableBrowser, readableBrowser.exports));
|
|
39909
|
-
|
|
39910
37826
|
/**
|
|
39911
37827
|
* This file is derived from prior work.
|
|
39912
37828
|
*
|