@ape.swap/bonds-sdk 1.0.25 → 1.0.27
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/cjs/index.js +3392 -102
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +3392 -102
- package/dist/esm/index.js.map +1 -1
- package/package.json +5 -2
package/dist/cjs/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var React$1 = require('react');
|
|
4
4
|
var require$$0$4 = require('events');
|
|
5
|
-
var Stream = require('stream');
|
|
5
|
+
var Stream$1 = require('stream');
|
|
6
6
|
var http = require('http');
|
|
7
7
|
var Url = require('url');
|
|
8
8
|
var require$$0$3 = require('punycode');
|
|
@@ -734,7 +734,7 @@ var characters = '';
|
|
|
734
734
|
* @param {object[] | string} children
|
|
735
735
|
* @param {number} length
|
|
736
736
|
*/
|
|
737
|
-
function node$
|
|
737
|
+
function node$4 (value, root, parent, type, props, children, length) {
|
|
738
738
|
return {value: value, root: root, parent: parent, type: type, props: props, children: children, line: line, column: column, length: length, return: ''}
|
|
739
739
|
}
|
|
740
740
|
|
|
@@ -744,7 +744,7 @@ function node$3 (value, root, parent, type, props, children, length) {
|
|
|
744
744
|
* @return {object}
|
|
745
745
|
*/
|
|
746
746
|
function copy (root, props) {
|
|
747
|
-
return assign(node$
|
|
747
|
+
return assign(node$4('', null, null, '', null, null, 0), root, {length: -root.length}, props)
|
|
748
748
|
}
|
|
749
749
|
|
|
750
750
|
/**
|
|
@@ -1102,7 +1102,7 @@ function ruleset (value, root, parent, index, offset, rules, points, type, props
|
|
|
1102
1102
|
if (z = trim(j > 0 ? rule[x] + ' ' + y : replace(y, /&\f/g, rule[x])))
|
|
1103
1103
|
props[k++] = z;
|
|
1104
1104
|
|
|
1105
|
-
return node$
|
|
1105
|
+
return node$4(value, root, parent, offset === 0 ? RULESET : type, props, children, length)
|
|
1106
1106
|
}
|
|
1107
1107
|
|
|
1108
1108
|
/**
|
|
@@ -1112,7 +1112,7 @@ function ruleset (value, root, parent, index, offset, rules, points, type, props
|
|
|
1112
1112
|
* @return {object}
|
|
1113
1113
|
*/
|
|
1114
1114
|
function comment (value, root, parent) {
|
|
1115
|
-
return node$
|
|
1115
|
+
return node$4(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0)
|
|
1116
1116
|
}
|
|
1117
1117
|
|
|
1118
1118
|
/**
|
|
@@ -1123,7 +1123,7 @@ function comment (value, root, parent) {
|
|
|
1123
1123
|
* @return {object}
|
|
1124
1124
|
*/
|
|
1125
1125
|
function declaration (value, root, parent, length) {
|
|
1126
|
-
return node$
|
|
1126
|
+
return node$4(value, root, parent, DECLARATION, substr(value, 0, length), substr(value, length + 1, -1), length)
|
|
1127
1127
|
}
|
|
1128
1128
|
|
|
1129
1129
|
/**
|
|
@@ -23418,7 +23418,7 @@ assert$b.equal = function assertEqual(l, r, msg) {
|
|
|
23418
23418
|
throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
|
|
23419
23419
|
};
|
|
23420
23420
|
|
|
23421
|
-
var inherits$
|
|
23421
|
+
var inherits$2 = {exports: {}};
|
|
23422
23422
|
|
|
23423
23423
|
var inherits_browser$1 = {exports: {}};
|
|
23424
23424
|
|
|
@@ -23461,18 +23461,18 @@ try {
|
|
|
23461
23461
|
var util = require('util');
|
|
23462
23462
|
/* istanbul ignore next */
|
|
23463
23463
|
if (typeof util.inherits !== 'function') throw '';
|
|
23464
|
-
inherits$
|
|
23464
|
+
inherits$2.exports = util.inherits;
|
|
23465
23465
|
} catch (e) {
|
|
23466
23466
|
/* istanbul ignore next */
|
|
23467
|
-
inherits$
|
|
23467
|
+
inherits$2.exports = requireInherits_browser();
|
|
23468
23468
|
}
|
|
23469
23469
|
|
|
23470
|
-
var inheritsExports = inherits$
|
|
23470
|
+
var inheritsExports = inherits$2.exports;
|
|
23471
23471
|
|
|
23472
23472
|
var assert$a = minimalisticAssert$1;
|
|
23473
|
-
var inherits = inheritsExports;
|
|
23473
|
+
var inherits$1 = inheritsExports;
|
|
23474
23474
|
|
|
23475
|
-
utils$e.inherits = inherits;
|
|
23475
|
+
utils$e.inherits = inherits$1;
|
|
23476
23476
|
|
|
23477
23477
|
function isSurrogatePair(msg, i) {
|
|
23478
23478
|
if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
|
|
@@ -114702,7 +114702,7 @@ publicApi.parseURL = urlStateMachineExports.parseURL;
|
|
|
114702
114702
|
// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js
|
|
114703
114703
|
|
|
114704
114704
|
// fix for "Readable" isn't a named export issue
|
|
114705
|
-
const Readable = Stream.Readable;
|
|
114705
|
+
const Readable = Stream$1.Readable;
|
|
114706
114706
|
|
|
114707
114707
|
const BUFFER = Symbol('buffer');
|
|
114708
114708
|
const TYPE = Symbol('type');
|
|
@@ -114854,7 +114854,7 @@ try {
|
|
|
114854
114854
|
const INTERNALS = Symbol('Body internals');
|
|
114855
114855
|
|
|
114856
114856
|
// fix an issue where "PassThrough" isn't a named export for node <10
|
|
114857
|
-
const PassThrough = Stream.PassThrough;
|
|
114857
|
+
const PassThrough = Stream$1.PassThrough;
|
|
114858
114858
|
|
|
114859
114859
|
/**
|
|
114860
114860
|
* Body mixin
|
|
@@ -114887,7 +114887,7 @@ function Body(body) {
|
|
|
114887
114887
|
} else if (ArrayBuffer.isView(body)) {
|
|
114888
114888
|
// body is ArrayBufferView
|
|
114889
114889
|
body = Buffer.from(body.buffer, body.byteOffset, body.byteLength);
|
|
114890
|
-
} else if (body instanceof Stream) ; else {
|
|
114890
|
+
} else if (body instanceof Stream$1) ; else {
|
|
114891
114891
|
// none of the above
|
|
114892
114892
|
// coerce to string then buffer
|
|
114893
114893
|
body = Buffer.from(String(body));
|
|
@@ -114900,7 +114900,7 @@ function Body(body) {
|
|
|
114900
114900
|
this.size = size;
|
|
114901
114901
|
this.timeout = timeout;
|
|
114902
114902
|
|
|
114903
|
-
if (body instanceof Stream) {
|
|
114903
|
+
if (body instanceof Stream$1) {
|
|
114904
114904
|
body.on('error', function (err) {
|
|
114905
114905
|
const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err);
|
|
114906
114906
|
_this[INTERNALS].error = error;
|
|
@@ -115056,7 +115056,7 @@ function consumeBody() {
|
|
|
115056
115056
|
}
|
|
115057
115057
|
|
|
115058
115058
|
// istanbul ignore if: should never happen
|
|
115059
|
-
if (!(body instanceof Stream)) {
|
|
115059
|
+
if (!(body instanceof Stream$1)) {
|
|
115060
115060
|
return Body.Promise.resolve(Buffer.alloc(0));
|
|
115061
115061
|
}
|
|
115062
115062
|
|
|
@@ -115229,7 +115229,7 @@ function clone(instance) {
|
|
|
115229
115229
|
|
|
115230
115230
|
// check that body is a stream and not form-data object
|
|
115231
115231
|
// note: we can't clone the form-data object without having it as a dependency
|
|
115232
|
-
if (body instanceof Stream && typeof body.getBoundary !== 'function') {
|
|
115232
|
+
if (body instanceof Stream$1 && typeof body.getBoundary !== 'function') {
|
|
115233
115233
|
// tee instance body
|
|
115234
115234
|
p1 = new PassThrough();
|
|
115235
115235
|
p2 = new PassThrough();
|
|
@@ -115277,7 +115277,7 @@ function extractContentType(body) {
|
|
|
115277
115277
|
} else if (typeof body.getBoundary === 'function') {
|
|
115278
115278
|
// detect form data input from form-data module
|
|
115279
115279
|
return `multipart/form-data;boundary=${body.getBoundary()}`;
|
|
115280
|
-
} else if (body instanceof Stream) {
|
|
115280
|
+
} else if (body instanceof Stream$1) {
|
|
115281
115281
|
// body is stream
|
|
115282
115282
|
// can't really do much about this
|
|
115283
115283
|
return null;
|
|
@@ -115856,7 +115856,7 @@ function parseURL(urlStr) {
|
|
|
115856
115856
|
return parse_url(urlStr);
|
|
115857
115857
|
}
|
|
115858
115858
|
|
|
115859
|
-
const streamDestructionSupported = 'destroy' in Stream.Readable.prototype;
|
|
115859
|
+
const streamDestructionSupported = 'destroy' in Stream$1.Readable.prototype;
|
|
115860
115860
|
|
|
115861
115861
|
/**
|
|
115862
115862
|
* Check if a value is an instance of Request.
|
|
@@ -116019,7 +116019,7 @@ function getNodeRequestOptions(request) {
|
|
|
116019
116019
|
throw new TypeError('Only HTTP(S) protocols are supported');
|
|
116020
116020
|
}
|
|
116021
116021
|
|
|
116022
|
-
if (request.signal && request.body instanceof Stream.Readable && !streamDestructionSupported) {
|
|
116022
|
+
if (request.signal && request.body instanceof Stream$1.Readable && !streamDestructionSupported) {
|
|
116023
116023
|
throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8');
|
|
116024
116024
|
}
|
|
116025
116025
|
|
|
@@ -116092,7 +116092,7 @@ AbortError.prototype.name = 'AbortError';
|
|
|
116092
116092
|
const URL$1$1 = Url.URL || publicApi.URL;
|
|
116093
116093
|
|
|
116094
116094
|
// fix an issue where "PassThrough", "resolve" aren't a named export for node <10
|
|
116095
|
-
const PassThrough$1 = Stream.PassThrough;
|
|
116095
|
+
const PassThrough$1 = Stream$1.PassThrough;
|
|
116096
116096
|
|
|
116097
116097
|
const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original) {
|
|
116098
116098
|
const orig = new URL$1$1(original).hostname;
|
|
@@ -116145,7 +116145,7 @@ function fetch$1(url, opts) {
|
|
|
116145
116145
|
const abort = function abort() {
|
|
116146
116146
|
let error = new AbortError('The user aborted a request.');
|
|
116147
116147
|
reject(error);
|
|
116148
|
-
if (request.body && request.body instanceof Stream.Readable) {
|
|
116148
|
+
if (request.body && request.body instanceof Stream$1.Readable) {
|
|
116149
116149
|
destroyStream(request.body, error);
|
|
116150
116150
|
}
|
|
116151
116151
|
if (!response || !response.body) return;
|
|
@@ -132286,7 +132286,7 @@ function requireReceiver () {
|
|
|
132286
132286
|
if (hasRequiredReceiver) return receiver;
|
|
132287
132287
|
hasRequiredReceiver = 1;
|
|
132288
132288
|
|
|
132289
|
-
const { Writable } = Stream;
|
|
132289
|
+
const { Writable } = Stream$1;
|
|
132290
132290
|
|
|
132291
132291
|
const PerMessageDeflate = requirePermessageDeflate();
|
|
132292
132292
|
const {
|
|
@@ -134817,14 +134817,14 @@ function requireWebsocket () {
|
|
|
134817
134817
|
return websocket;
|
|
134818
134818
|
}
|
|
134819
134819
|
|
|
134820
|
-
var stream;
|
|
134821
|
-
var hasRequiredStream;
|
|
134820
|
+
var stream$1;
|
|
134821
|
+
var hasRequiredStream$1;
|
|
134822
134822
|
|
|
134823
|
-
function requireStream () {
|
|
134824
|
-
if (hasRequiredStream) return stream;
|
|
134825
|
-
hasRequiredStream = 1;
|
|
134823
|
+
function requireStream$1 () {
|
|
134824
|
+
if (hasRequiredStream$1) return stream$1;
|
|
134825
|
+
hasRequiredStream$1 = 1;
|
|
134826
134826
|
|
|
134827
|
-
const { Duplex } = Stream;
|
|
134827
|
+
const { Duplex } = Stream$1;
|
|
134828
134828
|
|
|
134829
134829
|
/**
|
|
134830
134830
|
* Emits the `'close'` event on a stream.
|
|
@@ -134998,8 +134998,8 @@ function requireStream () {
|
|
|
134998
134998
|
return duplex;
|
|
134999
134999
|
}
|
|
135000
135000
|
|
|
135001
|
-
stream = createWebSocketStream;
|
|
135002
|
-
return stream;
|
|
135001
|
+
stream$1 = createWebSocketStream;
|
|
135002
|
+
return stream$1;
|
|
135003
135003
|
}
|
|
135004
135004
|
|
|
135005
135005
|
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^net|tls|https$" }] */
|
|
@@ -135463,7 +135463,7 @@ function requireWs () {
|
|
|
135463
135463
|
|
|
135464
135464
|
const WebSocket = requireWebsocket();
|
|
135465
135465
|
|
|
135466
|
-
WebSocket.createWebSocketStream = requireStream();
|
|
135466
|
+
WebSocket.createWebSocketStream = requireStream$1();
|
|
135467
135467
|
WebSocket.Server = requireWebsocketServer();
|
|
135468
135468
|
WebSocket.Receiver = requireReceiver();
|
|
135469
135469
|
WebSocket.Sender = requireSender();
|
|
@@ -135674,30 +135674,30 @@ function requireCjs$7 () {
|
|
|
135674
135674
|
return cjs$4;
|
|
135675
135675
|
}
|
|
135676
135676
|
|
|
135677
|
-
var errors = {};
|
|
135678
|
-
|
|
135679
|
-
var hasRequiredErrors;
|
|
135680
|
-
|
|
135681
|
-
function requireErrors () {
|
|
135682
|
-
if (hasRequiredErrors) return errors;
|
|
135683
|
-
hasRequiredErrors = 1;
|
|
135684
|
-
Object.defineProperty(errors, "__esModule", { value: true });
|
|
135685
|
-
errors.ERROR_QRCODE_MODAL_USER_CLOSED = errors.ERROR_QRCODE_MODAL_NOT_PROVIDED = errors.ERROR_INVALID_URI = errors.ERROR_INVALID_RESPONSE = errors.ERROR_MISSING_REQUIRED = errors.ERROR_MISSING_ID = errors.ERROR_MISSING_METHOD = errors.ERROR_MISSING_ERROR = errors.ERROR_MISSING_RESULT = errors.ERROR_MISSING_JSON_RPC = errors.ERROR_SESSION_REJECTED = errors.ERROR_SESSION_DISCONNECTED = errors.ERROR_SESSION_CONNECTED = void 0;
|
|
135686
|
-
errors.ERROR_SESSION_CONNECTED = "Session currently connected";
|
|
135687
|
-
errors.ERROR_SESSION_DISCONNECTED = "Session currently disconnected";
|
|
135688
|
-
errors.ERROR_SESSION_REJECTED = "Session Rejected";
|
|
135689
|
-
errors.ERROR_MISSING_JSON_RPC = "Missing JSON RPC response";
|
|
135690
|
-
errors.ERROR_MISSING_RESULT = `JSON-RPC success response must include "result" field`;
|
|
135691
|
-
errors.ERROR_MISSING_ERROR = `JSON-RPC error response must include "error" field`;
|
|
135692
|
-
errors.ERROR_MISSING_METHOD = `JSON RPC request must have valid "method" value`;
|
|
135693
|
-
errors.ERROR_MISSING_ID = `JSON RPC request must have valid "id" value`;
|
|
135694
|
-
errors.ERROR_MISSING_REQUIRED = "Missing one of the required parameters: bridge / uri / session";
|
|
135695
|
-
errors.ERROR_INVALID_RESPONSE = "JSON RPC response format is invalid";
|
|
135696
|
-
errors.ERROR_INVALID_URI = "URI format is invalid";
|
|
135697
|
-
errors.ERROR_QRCODE_MODAL_NOT_PROVIDED = "QRCode Modal not provided";
|
|
135698
|
-
errors.ERROR_QRCODE_MODAL_USER_CLOSED = "User close QRCode Modal";
|
|
135677
|
+
var errors$1 = {};
|
|
135678
|
+
|
|
135679
|
+
var hasRequiredErrors$1;
|
|
135680
|
+
|
|
135681
|
+
function requireErrors$1 () {
|
|
135682
|
+
if (hasRequiredErrors$1) return errors$1;
|
|
135683
|
+
hasRequiredErrors$1 = 1;
|
|
135684
|
+
Object.defineProperty(errors$1, "__esModule", { value: true });
|
|
135685
|
+
errors$1.ERROR_QRCODE_MODAL_USER_CLOSED = errors$1.ERROR_QRCODE_MODAL_NOT_PROVIDED = errors$1.ERROR_INVALID_URI = errors$1.ERROR_INVALID_RESPONSE = errors$1.ERROR_MISSING_REQUIRED = errors$1.ERROR_MISSING_ID = errors$1.ERROR_MISSING_METHOD = errors$1.ERROR_MISSING_ERROR = errors$1.ERROR_MISSING_RESULT = errors$1.ERROR_MISSING_JSON_RPC = errors$1.ERROR_SESSION_REJECTED = errors$1.ERROR_SESSION_DISCONNECTED = errors$1.ERROR_SESSION_CONNECTED = void 0;
|
|
135686
|
+
errors$1.ERROR_SESSION_CONNECTED = "Session currently connected";
|
|
135687
|
+
errors$1.ERROR_SESSION_DISCONNECTED = "Session currently disconnected";
|
|
135688
|
+
errors$1.ERROR_SESSION_REJECTED = "Session Rejected";
|
|
135689
|
+
errors$1.ERROR_MISSING_JSON_RPC = "Missing JSON RPC response";
|
|
135690
|
+
errors$1.ERROR_MISSING_RESULT = `JSON-RPC success response must include "result" field`;
|
|
135691
|
+
errors$1.ERROR_MISSING_ERROR = `JSON-RPC error response must include "error" field`;
|
|
135692
|
+
errors$1.ERROR_MISSING_METHOD = `JSON RPC request must have valid "method" value`;
|
|
135693
|
+
errors$1.ERROR_MISSING_ID = `JSON RPC request must have valid "id" value`;
|
|
135694
|
+
errors$1.ERROR_MISSING_REQUIRED = "Missing one of the required parameters: bridge / uri / session";
|
|
135695
|
+
errors$1.ERROR_INVALID_RESPONSE = "JSON RPC response format is invalid";
|
|
135696
|
+
errors$1.ERROR_INVALID_URI = "URI format is invalid";
|
|
135697
|
+
errors$1.ERROR_QRCODE_MODAL_NOT_PROVIDED = "QRCode Modal not provided";
|
|
135698
|
+
errors$1.ERROR_QRCODE_MODAL_USER_CLOSED = "User close QRCode Modal";
|
|
135699
135699
|
|
|
135700
|
-
return errors;
|
|
135700
|
+
return errors$1;
|
|
135701
135701
|
}
|
|
135702
135702
|
|
|
135703
135703
|
var events = {};
|
|
@@ -135850,7 +135850,7 @@ function requireCjs$6 () {
|
|
|
135850
135850
|
const tslib_1 = require$$0;
|
|
135851
135851
|
const utils_1 = requireCjs$9();
|
|
135852
135852
|
const socket_transport_1 = tslib_1.__importDefault(requireCjs$7());
|
|
135853
|
-
const errors_1 = requireErrors();
|
|
135853
|
+
const errors_1 = requireErrors$1();
|
|
135854
135854
|
const events_1 = tslib_1.__importDefault(requireEvents());
|
|
135855
135855
|
const storage_1 = tslib_1.__importDefault(requireStorage());
|
|
135856
135856
|
const url_1 = requireUrl$1();
|
|
@@ -136827,17 +136827,17 @@ function requireCjs$6 () {
|
|
|
136827
136827
|
|
|
136828
136828
|
var cjs$2 = {};
|
|
136829
136829
|
|
|
136830
|
-
var node$
|
|
136830
|
+
var node$3 = {};
|
|
136831
136831
|
|
|
136832
|
-
var node$
|
|
136832
|
+
var node$2 = {};
|
|
136833
136833
|
|
|
136834
|
-
var hasRequiredNode$
|
|
136834
|
+
var hasRequiredNode$3;
|
|
136835
136835
|
|
|
136836
|
-
function requireNode$
|
|
136837
|
-
if (hasRequiredNode$
|
|
136838
|
-
hasRequiredNode$
|
|
136839
|
-
Object.defineProperty(node$
|
|
136840
|
-
node$
|
|
136836
|
+
function requireNode$3 () {
|
|
136837
|
+
if (hasRequiredNode$3) return node$2;
|
|
136838
|
+
hasRequiredNode$3 = 1;
|
|
136839
|
+
Object.defineProperty(node$2, "__esModule", { value: true });
|
|
136840
|
+
node$2.randomBytes = void 0;
|
|
136841
136841
|
const tslib_1 = require$$0;
|
|
136842
136842
|
const crypto_1 = tslib_1.__importDefault(require$$5$1);
|
|
136843
136843
|
const encoding_1 = require$$2;
|
|
@@ -136845,14 +136845,14 @@ function requireNode$2 () {
|
|
|
136845
136845
|
const buf = crypto_1.default.randomBytes(length);
|
|
136846
136846
|
return encoding_1.bufferToArray(buf);
|
|
136847
136847
|
}
|
|
136848
|
-
node$
|
|
136848
|
+
node$2.randomBytes = randomBytes;
|
|
136849
136849
|
|
|
136850
|
-
return node$
|
|
136850
|
+
return node$2;
|
|
136851
136851
|
}
|
|
136852
136852
|
|
|
136853
136853
|
var aes = {};
|
|
136854
136854
|
|
|
136855
|
-
var node = {};
|
|
136855
|
+
var node$1 = {};
|
|
136856
136856
|
|
|
136857
136857
|
var constants$2 = {};
|
|
136858
136858
|
|
|
@@ -136974,13 +136974,13 @@ function requireConstants$2 () {
|
|
|
136974
136974
|
return constants$2;
|
|
136975
136975
|
}
|
|
136976
136976
|
|
|
136977
|
-
var hasRequiredNode$
|
|
136977
|
+
var hasRequiredNode$2;
|
|
136978
136978
|
|
|
136979
|
-
function requireNode$
|
|
136980
|
-
if (hasRequiredNode$
|
|
136981
|
-
hasRequiredNode$
|
|
136982
|
-
Object.defineProperty(node, "__esModule", { value: true });
|
|
136983
|
-
node.nodeRipemd160 = node.nodeSha512 = node.nodeSha256 = node.nodeHmacSha512Sign = node.nodeHmacSha256Sign = node.nodeAesDecrypt = node.nodeAesEncrypt = void 0;
|
|
136979
|
+
function requireNode$2 () {
|
|
136980
|
+
if (hasRequiredNode$2) return node$1;
|
|
136981
|
+
hasRequiredNode$2 = 1;
|
|
136982
|
+
Object.defineProperty(node$1, "__esModule", { value: true });
|
|
136983
|
+
node$1.nodeRipemd160 = node$1.nodeSha512 = node$1.nodeSha256 = node$1.nodeHmacSha512Sign = node$1.nodeHmacSha256Sign = node$1.nodeAesDecrypt = node$1.nodeAesEncrypt = void 0;
|
|
136984
136984
|
const tslib_1 = require$$0;
|
|
136985
136985
|
const crypto_1 = tslib_1.__importDefault(require$$5$1);
|
|
136986
136986
|
const encoding_1 = require$$2;
|
|
@@ -136989,12 +136989,12 @@ function requireNode$1 () {
|
|
|
136989
136989
|
const cipher = crypto_1.default.createCipheriv(constants_1.AES_NODE_ALGO, Buffer.from(key), Buffer.from(iv));
|
|
136990
136990
|
return encoding_1.bufferToArray(encoding_1.concatBuffers(cipher.update(Buffer.from(data)), cipher.final()));
|
|
136991
136991
|
}
|
|
136992
|
-
node.nodeAesEncrypt = nodeAesEncrypt;
|
|
136992
|
+
node$1.nodeAesEncrypt = nodeAesEncrypt;
|
|
136993
136993
|
function nodeAesDecrypt(iv, key, data) {
|
|
136994
136994
|
const decipher = crypto_1.default.createDecipheriv(constants_1.AES_NODE_ALGO, Buffer.from(key), Buffer.from(iv));
|
|
136995
136995
|
return encoding_1.bufferToArray(encoding_1.concatBuffers(decipher.update(Buffer.from(data)), decipher.final()));
|
|
136996
136996
|
}
|
|
136997
|
-
node.nodeAesDecrypt = nodeAesDecrypt;
|
|
136997
|
+
node$1.nodeAesDecrypt = nodeAesDecrypt;
|
|
136998
136998
|
function nodeHmacSha256Sign(key, data) {
|
|
136999
136999
|
const buf = crypto_1.default
|
|
137000
137000
|
.createHmac(constants_1.HMAC_NODE_ALGO, Buffer.from(key))
|
|
@@ -137002,7 +137002,7 @@ function requireNode$1 () {
|
|
|
137002
137002
|
.digest();
|
|
137003
137003
|
return encoding_1.bufferToArray(buf);
|
|
137004
137004
|
}
|
|
137005
|
-
node.nodeHmacSha256Sign = nodeHmacSha256Sign;
|
|
137005
|
+
node$1.nodeHmacSha256Sign = nodeHmacSha256Sign;
|
|
137006
137006
|
function nodeHmacSha512Sign(key, data) {
|
|
137007
137007
|
const buf = crypto_1.default
|
|
137008
137008
|
.createHmac(constants_1.SHA512_NODE_ALGO, Buffer.from(key))
|
|
@@ -137010,7 +137010,7 @@ function requireNode$1 () {
|
|
|
137010
137010
|
.digest();
|
|
137011
137011
|
return encoding_1.bufferToArray(buf);
|
|
137012
137012
|
}
|
|
137013
|
-
node.nodeHmacSha512Sign = nodeHmacSha512Sign;
|
|
137013
|
+
node$1.nodeHmacSha512Sign = nodeHmacSha512Sign;
|
|
137014
137014
|
function nodeSha256(data) {
|
|
137015
137015
|
const buf = crypto_1.default
|
|
137016
137016
|
.createHash(constants_1.SHA256_NODE_ALGO)
|
|
@@ -137018,7 +137018,7 @@ function requireNode$1 () {
|
|
|
137018
137018
|
.digest();
|
|
137019
137019
|
return encoding_1.bufferToArray(buf);
|
|
137020
137020
|
}
|
|
137021
|
-
node.nodeSha256 = nodeSha256;
|
|
137021
|
+
node$1.nodeSha256 = nodeSha256;
|
|
137022
137022
|
function nodeSha512(data) {
|
|
137023
137023
|
const buf = crypto_1.default
|
|
137024
137024
|
.createHash(constants_1.SHA512_NODE_ALGO)
|
|
@@ -137026,7 +137026,7 @@ function requireNode$1 () {
|
|
|
137026
137026
|
.digest();
|
|
137027
137027
|
return encoding_1.bufferToArray(buf);
|
|
137028
137028
|
}
|
|
137029
|
-
node.nodeSha512 = nodeSha512;
|
|
137029
|
+
node$1.nodeSha512 = nodeSha512;
|
|
137030
137030
|
function nodeRipemd160(data) {
|
|
137031
137031
|
const buf = crypto_1.default
|
|
137032
137032
|
.createHash(constants_1.RIPEMD160_NODE_ALGO)
|
|
@@ -137034,9 +137034,9 @@ function requireNode$1 () {
|
|
|
137034
137034
|
.digest();
|
|
137035
137035
|
return encoding_1.bufferToArray(buf);
|
|
137036
137036
|
}
|
|
137037
|
-
node.nodeRipemd160 = nodeRipemd160;
|
|
137037
|
+
node$1.nodeRipemd160 = nodeRipemd160;
|
|
137038
137038
|
|
|
137039
|
-
return node;
|
|
137039
|
+
return node$1;
|
|
137040
137040
|
}
|
|
137041
137041
|
|
|
137042
137042
|
var hasRequiredAes;
|
|
@@ -137047,7 +137047,7 @@ function requireAes () {
|
|
|
137047
137047
|
Object.defineProperty(aes, "__esModule", { value: true });
|
|
137048
137048
|
aes.aesCbcDecrypt = aes.aesCbcEncrypt = void 0;
|
|
137049
137049
|
const tslib_1 = require$$0;
|
|
137050
|
-
const node_1 = requireNode$
|
|
137050
|
+
const node_1 = requireNode$2();
|
|
137051
137051
|
function aesCbcEncrypt(iv, key, data) {
|
|
137052
137052
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
137053
137053
|
const result = node_1.nodeAesEncrypt(iv, key, data);
|
|
@@ -137197,7 +137197,7 @@ function requireHmac () {
|
|
|
137197
137197
|
hmac.hmacSha512Verify = hmac.hmacSha512Sign = hmac.hmacSha256Verify = hmac.hmacSha256Sign = void 0;
|
|
137198
137198
|
const tslib_1 = require$$0;
|
|
137199
137199
|
const helpers_1 = requireHelpers();
|
|
137200
|
-
const node_1 = requireNode$
|
|
137200
|
+
const node_1 = requireNode$2();
|
|
137201
137201
|
function hmacSha256Sign(key, msg) {
|
|
137202
137202
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
137203
137203
|
const result = node_1.nodeHmacSha256Sign(key, msg);
|
|
@@ -137242,7 +137242,7 @@ function requireSha2 () {
|
|
|
137242
137242
|
Object.defineProperty(sha2, "__esModule", { value: true });
|
|
137243
137243
|
sha2.ripemd160 = sha2.sha512 = sha2.sha256 = void 0;
|
|
137244
137244
|
const tslib_1 = require$$0;
|
|
137245
|
-
const node_1 = requireNode$
|
|
137245
|
+
const node_1 = requireNode$2();
|
|
137246
137246
|
function sha256(msg) {
|
|
137247
137247
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
137248
137248
|
const result = node_1.nodeSha256(msg);
|
|
@@ -137268,23 +137268,23 @@ function requireSha2 () {
|
|
|
137268
137268
|
return sha2;
|
|
137269
137269
|
}
|
|
137270
137270
|
|
|
137271
|
-
var hasRequiredNode;
|
|
137271
|
+
var hasRequiredNode$1;
|
|
137272
137272
|
|
|
137273
|
-
function requireNode () {
|
|
137274
|
-
if (hasRequiredNode) return node$
|
|
137275
|
-
hasRequiredNode = 1;
|
|
137273
|
+
function requireNode$1 () {
|
|
137274
|
+
if (hasRequiredNode$1) return node$3;
|
|
137275
|
+
hasRequiredNode$1 = 1;
|
|
137276
137276
|
(function (exports) {
|
|
137277
137277
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
137278
137278
|
const tslib_1 = require$$0;
|
|
137279
|
-
tslib_1.__exportStar(requireNode$
|
|
137279
|
+
tslib_1.__exportStar(requireNode$3(), exports);
|
|
137280
137280
|
tslib_1.__exportStar(requireAes(), exports);
|
|
137281
137281
|
tslib_1.__exportStar(requireHmac(), exports);
|
|
137282
137282
|
tslib_1.__exportStar(requireSha2(), exports);
|
|
137283
137283
|
tslib_1.__exportStar(requireHelpers(), exports);
|
|
137284
137284
|
tslib_1.__exportStar(requireConstants$2(), exports);
|
|
137285
137285
|
|
|
137286
|
-
} (node$
|
|
137287
|
-
return node$
|
|
137286
|
+
} (node$3));
|
|
137287
|
+
return node$3;
|
|
137288
137288
|
}
|
|
137289
137289
|
|
|
137290
137290
|
var cjs$1 = {};
|
|
@@ -141704,7 +141704,7 @@ function requireCjs$4 () {
|
|
|
141704
141704
|
Object.defineProperty(cjs$2, "__esModule", { value: true });
|
|
141705
141705
|
cjs$2.decrypt = cjs$2.encrypt = cjs$2.verifyHmac = cjs$2.generateKey = void 0;
|
|
141706
141706
|
const tslib_1 = require$$0;
|
|
141707
|
-
const crypto = tslib_1.__importStar(requireNode());
|
|
141707
|
+
const crypto = tslib_1.__importStar(requireNode$1());
|
|
141708
141708
|
const encoding = tslib_1.__importStar(require$$2);
|
|
141709
141709
|
const utils_1 = requireCjs$5();
|
|
141710
141710
|
function generateKey(length) {
|
|
@@ -144835,11 +144835,11 @@ function requireChunkstream () {
|
|
|
144835
144835
|
|
|
144836
144836
|
|
|
144837
144837
|
var util = require$$0$5;
|
|
144838
|
-
var Stream
|
|
144838
|
+
var Stream = Stream$1;
|
|
144839
144839
|
|
|
144840
144840
|
|
|
144841
144841
|
var ChunkStream = chunkstream.exports = function() {
|
|
144842
|
-
Stream
|
|
144842
|
+
Stream.call(this);
|
|
144843
144843
|
|
|
144844
144844
|
this._buffers = [];
|
|
144845
144845
|
this._buffered = 0;
|
|
@@ -144850,7 +144850,7 @@ function requireChunkstream () {
|
|
|
144850
144850
|
this._encoding = 'utf8';
|
|
144851
144851
|
this.writable = true;
|
|
144852
144852
|
};
|
|
144853
|
-
util.inherits(ChunkStream, Stream
|
|
144853
|
+
util.inherits(ChunkStream, Stream);
|
|
144854
144854
|
|
|
144855
144855
|
|
|
144856
144856
|
ChunkStream.prototype.read = function(length, callback) {
|
|
@@ -146786,12 +146786,12 @@ function requirePackerAsync () {
|
|
|
146786
146786
|
hasRequiredPackerAsync = 1;
|
|
146787
146787
|
|
|
146788
146788
|
var util = require$$0$5;
|
|
146789
|
-
var Stream
|
|
146789
|
+
var Stream = Stream$1;
|
|
146790
146790
|
var constants = requireConstants();
|
|
146791
146791
|
var Packer = requirePacker();
|
|
146792
146792
|
|
|
146793
146793
|
var PackerAsync = packerAsync.exports = function(opt) {
|
|
146794
|
-
Stream
|
|
146794
|
+
Stream.call(this);
|
|
146795
146795
|
|
|
146796
146796
|
var options = opt || {};
|
|
146797
146797
|
|
|
@@ -146800,7 +146800,7 @@ function requirePackerAsync () {
|
|
|
146800
146800
|
|
|
146801
146801
|
this.readable = true;
|
|
146802
146802
|
};
|
|
146803
|
-
util.inherits(PackerAsync, Stream
|
|
146803
|
+
util.inherits(PackerAsync, Stream);
|
|
146804
146804
|
|
|
146805
146805
|
|
|
146806
146806
|
PackerAsync.prototype.pack = function(data, width, height, gamma) {
|
|
@@ -147297,14 +147297,14 @@ function requirePng$1 () {
|
|
|
147297
147297
|
hasRequiredPng$1 = 1;
|
|
147298
147298
|
|
|
147299
147299
|
var util = require$$0$5;
|
|
147300
|
-
var Stream
|
|
147300
|
+
var Stream = Stream$1;
|
|
147301
147301
|
var Parser = requireParserAsync();
|
|
147302
147302
|
var Packer = requirePackerAsync();
|
|
147303
147303
|
var PNGSync = requirePngSync();
|
|
147304
147304
|
|
|
147305
147305
|
|
|
147306
147306
|
var PNG = png.PNG = function(options) {
|
|
147307
|
-
Stream
|
|
147307
|
+
Stream.call(this);
|
|
147308
147308
|
|
|
147309
147309
|
options = options || {}; // eslint-disable-line no-param-reassign
|
|
147310
147310
|
|
|
@@ -147340,7 +147340,7 @@ function requirePng$1 () {
|
|
|
147340
147340
|
this._packer.on('error', this.emit.bind(this, 'error'));
|
|
147341
147341
|
|
|
147342
147342
|
};
|
|
147343
|
-
util.inherits(PNG, Stream
|
|
147343
|
+
util.inherits(PNG, Stream);
|
|
147344
147344
|
|
|
147345
147345
|
PNG.sync = PNGSync;
|
|
147346
147346
|
|
|
@@ -156769,6 +156769,3296 @@ var Bonds = function (_a) {
|
|
|
156769
156769
|
})] })] }));
|
|
156770
156770
|
};
|
|
156771
156771
|
|
|
156772
|
+
var stream;
|
|
156773
|
+
var hasRequiredStream;
|
|
156774
|
+
|
|
156775
|
+
function requireStream () {
|
|
156776
|
+
if (hasRequiredStream) return stream;
|
|
156777
|
+
hasRequiredStream = 1;
|
|
156778
|
+
stream = Stream$1;
|
|
156779
|
+
return stream;
|
|
156780
|
+
}
|
|
156781
|
+
|
|
156782
|
+
var buffer_list;
|
|
156783
|
+
var hasRequiredBuffer_list;
|
|
156784
|
+
|
|
156785
|
+
function requireBuffer_list () {
|
|
156786
|
+
if (hasRequiredBuffer_list) return buffer_list;
|
|
156787
|
+
hasRequiredBuffer_list = 1;
|
|
156788
|
+
|
|
156789
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
156790
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
156791
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
156792
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
156793
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
156794
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
156795
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
156796
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
156797
|
+
var _require = require$$2$4,
|
|
156798
|
+
Buffer = _require.Buffer;
|
|
156799
|
+
var _require2 = require$$0$5,
|
|
156800
|
+
inspect = _require2.inspect;
|
|
156801
|
+
var custom = inspect && inspect.custom || 'inspect';
|
|
156802
|
+
function copyBuffer(src, target, offset) {
|
|
156803
|
+
Buffer.prototype.copy.call(src, target, offset);
|
|
156804
|
+
}
|
|
156805
|
+
buffer_list = /*#__PURE__*/function () {
|
|
156806
|
+
function BufferList() {
|
|
156807
|
+
_classCallCheck(this, BufferList);
|
|
156808
|
+
this.head = null;
|
|
156809
|
+
this.tail = null;
|
|
156810
|
+
this.length = 0;
|
|
156811
|
+
}
|
|
156812
|
+
_createClass(BufferList, [{
|
|
156813
|
+
key: "push",
|
|
156814
|
+
value: function push(v) {
|
|
156815
|
+
var entry = {
|
|
156816
|
+
data: v,
|
|
156817
|
+
next: null
|
|
156818
|
+
};
|
|
156819
|
+
if (this.length > 0) this.tail.next = entry;else this.head = entry;
|
|
156820
|
+
this.tail = entry;
|
|
156821
|
+
++this.length;
|
|
156822
|
+
}
|
|
156823
|
+
}, {
|
|
156824
|
+
key: "unshift",
|
|
156825
|
+
value: function unshift(v) {
|
|
156826
|
+
var entry = {
|
|
156827
|
+
data: v,
|
|
156828
|
+
next: this.head
|
|
156829
|
+
};
|
|
156830
|
+
if (this.length === 0) this.tail = entry;
|
|
156831
|
+
this.head = entry;
|
|
156832
|
+
++this.length;
|
|
156833
|
+
}
|
|
156834
|
+
}, {
|
|
156835
|
+
key: "shift",
|
|
156836
|
+
value: function shift() {
|
|
156837
|
+
if (this.length === 0) return;
|
|
156838
|
+
var ret = this.head.data;
|
|
156839
|
+
if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
|
|
156840
|
+
--this.length;
|
|
156841
|
+
return ret;
|
|
156842
|
+
}
|
|
156843
|
+
}, {
|
|
156844
|
+
key: "clear",
|
|
156845
|
+
value: function clear() {
|
|
156846
|
+
this.head = this.tail = null;
|
|
156847
|
+
this.length = 0;
|
|
156848
|
+
}
|
|
156849
|
+
}, {
|
|
156850
|
+
key: "join",
|
|
156851
|
+
value: function join(s) {
|
|
156852
|
+
if (this.length === 0) return '';
|
|
156853
|
+
var p = this.head;
|
|
156854
|
+
var ret = '' + p.data;
|
|
156855
|
+
while (p = p.next) ret += s + p.data;
|
|
156856
|
+
return ret;
|
|
156857
|
+
}
|
|
156858
|
+
}, {
|
|
156859
|
+
key: "concat",
|
|
156860
|
+
value: function concat(n) {
|
|
156861
|
+
if (this.length === 0) return Buffer.alloc(0);
|
|
156862
|
+
var ret = Buffer.allocUnsafe(n >>> 0);
|
|
156863
|
+
var p = this.head;
|
|
156864
|
+
var i = 0;
|
|
156865
|
+
while (p) {
|
|
156866
|
+
copyBuffer(p.data, ret, i);
|
|
156867
|
+
i += p.data.length;
|
|
156868
|
+
p = p.next;
|
|
156869
|
+
}
|
|
156870
|
+
return ret;
|
|
156871
|
+
}
|
|
156872
|
+
|
|
156873
|
+
// Consumes a specified amount of bytes or characters from the buffered data.
|
|
156874
|
+
}, {
|
|
156875
|
+
key: "consume",
|
|
156876
|
+
value: function consume(n, hasStrings) {
|
|
156877
|
+
var ret;
|
|
156878
|
+
if (n < this.head.data.length) {
|
|
156879
|
+
// `slice` is the same for buffers and strings.
|
|
156880
|
+
ret = this.head.data.slice(0, n);
|
|
156881
|
+
this.head.data = this.head.data.slice(n);
|
|
156882
|
+
} else if (n === this.head.data.length) {
|
|
156883
|
+
// First chunk is a perfect match.
|
|
156884
|
+
ret = this.shift();
|
|
156885
|
+
} else {
|
|
156886
|
+
// Result spans more than one buffer.
|
|
156887
|
+
ret = hasStrings ? this._getString(n) : this._getBuffer(n);
|
|
156888
|
+
}
|
|
156889
|
+
return ret;
|
|
156890
|
+
}
|
|
156891
|
+
}, {
|
|
156892
|
+
key: "first",
|
|
156893
|
+
value: function first() {
|
|
156894
|
+
return this.head.data;
|
|
156895
|
+
}
|
|
156896
|
+
|
|
156897
|
+
// Consumes a specified amount of characters from the buffered data.
|
|
156898
|
+
}, {
|
|
156899
|
+
key: "_getString",
|
|
156900
|
+
value: function _getString(n) {
|
|
156901
|
+
var p = this.head;
|
|
156902
|
+
var c = 1;
|
|
156903
|
+
var ret = p.data;
|
|
156904
|
+
n -= ret.length;
|
|
156905
|
+
while (p = p.next) {
|
|
156906
|
+
var str = p.data;
|
|
156907
|
+
var nb = n > str.length ? str.length : n;
|
|
156908
|
+
if (nb === str.length) ret += str;else ret += str.slice(0, n);
|
|
156909
|
+
n -= nb;
|
|
156910
|
+
if (n === 0) {
|
|
156911
|
+
if (nb === str.length) {
|
|
156912
|
+
++c;
|
|
156913
|
+
if (p.next) this.head = p.next;else this.head = this.tail = null;
|
|
156914
|
+
} else {
|
|
156915
|
+
this.head = p;
|
|
156916
|
+
p.data = str.slice(nb);
|
|
156917
|
+
}
|
|
156918
|
+
break;
|
|
156919
|
+
}
|
|
156920
|
+
++c;
|
|
156921
|
+
}
|
|
156922
|
+
this.length -= c;
|
|
156923
|
+
return ret;
|
|
156924
|
+
}
|
|
156925
|
+
|
|
156926
|
+
// Consumes a specified amount of bytes from the buffered data.
|
|
156927
|
+
}, {
|
|
156928
|
+
key: "_getBuffer",
|
|
156929
|
+
value: function _getBuffer(n) {
|
|
156930
|
+
var ret = Buffer.allocUnsafe(n);
|
|
156931
|
+
var p = this.head;
|
|
156932
|
+
var c = 1;
|
|
156933
|
+
p.data.copy(ret);
|
|
156934
|
+
n -= p.data.length;
|
|
156935
|
+
while (p = p.next) {
|
|
156936
|
+
var buf = p.data;
|
|
156937
|
+
var nb = n > buf.length ? buf.length : n;
|
|
156938
|
+
buf.copy(ret, ret.length - n, 0, nb);
|
|
156939
|
+
n -= nb;
|
|
156940
|
+
if (n === 0) {
|
|
156941
|
+
if (nb === buf.length) {
|
|
156942
|
+
++c;
|
|
156943
|
+
if (p.next) this.head = p.next;else this.head = this.tail = null;
|
|
156944
|
+
} else {
|
|
156945
|
+
this.head = p;
|
|
156946
|
+
p.data = buf.slice(nb);
|
|
156947
|
+
}
|
|
156948
|
+
break;
|
|
156949
|
+
}
|
|
156950
|
+
++c;
|
|
156951
|
+
}
|
|
156952
|
+
this.length -= c;
|
|
156953
|
+
return ret;
|
|
156954
|
+
}
|
|
156955
|
+
|
|
156956
|
+
// Make sure the linked list only shows the minimal necessary information.
|
|
156957
|
+
}, {
|
|
156958
|
+
key: custom,
|
|
156959
|
+
value: function value(_, options) {
|
|
156960
|
+
return inspect(this, _objectSpread(_objectSpread({}, options), {}, {
|
|
156961
|
+
// Only inspect one level.
|
|
156962
|
+
depth: 0,
|
|
156963
|
+
// It should not recurse.
|
|
156964
|
+
customInspect: false
|
|
156965
|
+
}));
|
|
156966
|
+
}
|
|
156967
|
+
}]);
|
|
156968
|
+
return BufferList;
|
|
156969
|
+
}();
|
|
156970
|
+
return buffer_list;
|
|
156971
|
+
}
|
|
156972
|
+
|
|
156973
|
+
var destroy_1;
|
|
156974
|
+
var hasRequiredDestroy;
|
|
156975
|
+
|
|
156976
|
+
function requireDestroy () {
|
|
156977
|
+
if (hasRequiredDestroy) return destroy_1;
|
|
156978
|
+
hasRequiredDestroy = 1;
|
|
156979
|
+
|
|
156980
|
+
// undocumented cb() API, needed for core, not for public API
|
|
156981
|
+
function destroy(err, cb) {
|
|
156982
|
+
var _this = this;
|
|
156983
|
+
var readableDestroyed = this._readableState && this._readableState.destroyed;
|
|
156984
|
+
var writableDestroyed = this._writableState && this._writableState.destroyed;
|
|
156985
|
+
if (readableDestroyed || writableDestroyed) {
|
|
156986
|
+
if (cb) {
|
|
156987
|
+
cb(err);
|
|
156988
|
+
} else if (err) {
|
|
156989
|
+
if (!this._writableState) {
|
|
156990
|
+
process.nextTick(emitErrorNT, this, err);
|
|
156991
|
+
} else if (!this._writableState.errorEmitted) {
|
|
156992
|
+
this._writableState.errorEmitted = true;
|
|
156993
|
+
process.nextTick(emitErrorNT, this, err);
|
|
156994
|
+
}
|
|
156995
|
+
}
|
|
156996
|
+
return this;
|
|
156997
|
+
}
|
|
156998
|
+
|
|
156999
|
+
// we set destroyed to true before firing error callbacks in order
|
|
157000
|
+
// to make it re-entrance safe in case destroy() is called within callbacks
|
|
157001
|
+
|
|
157002
|
+
if (this._readableState) {
|
|
157003
|
+
this._readableState.destroyed = true;
|
|
157004
|
+
}
|
|
157005
|
+
|
|
157006
|
+
// if this is a duplex stream mark the writable part as destroyed as well
|
|
157007
|
+
if (this._writableState) {
|
|
157008
|
+
this._writableState.destroyed = true;
|
|
157009
|
+
}
|
|
157010
|
+
this._destroy(err || null, function (err) {
|
|
157011
|
+
if (!cb && err) {
|
|
157012
|
+
if (!_this._writableState) {
|
|
157013
|
+
process.nextTick(emitErrorAndCloseNT, _this, err);
|
|
157014
|
+
} else if (!_this._writableState.errorEmitted) {
|
|
157015
|
+
_this._writableState.errorEmitted = true;
|
|
157016
|
+
process.nextTick(emitErrorAndCloseNT, _this, err);
|
|
157017
|
+
} else {
|
|
157018
|
+
process.nextTick(emitCloseNT, _this);
|
|
157019
|
+
}
|
|
157020
|
+
} else if (cb) {
|
|
157021
|
+
process.nextTick(emitCloseNT, _this);
|
|
157022
|
+
cb(err);
|
|
157023
|
+
} else {
|
|
157024
|
+
process.nextTick(emitCloseNT, _this);
|
|
157025
|
+
}
|
|
157026
|
+
});
|
|
157027
|
+
return this;
|
|
157028
|
+
}
|
|
157029
|
+
function emitErrorAndCloseNT(self, err) {
|
|
157030
|
+
emitErrorNT(self, err);
|
|
157031
|
+
emitCloseNT(self);
|
|
157032
|
+
}
|
|
157033
|
+
function emitCloseNT(self) {
|
|
157034
|
+
if (self._writableState && !self._writableState.emitClose) return;
|
|
157035
|
+
if (self._readableState && !self._readableState.emitClose) return;
|
|
157036
|
+
self.emit('close');
|
|
157037
|
+
}
|
|
157038
|
+
function undestroy() {
|
|
157039
|
+
if (this._readableState) {
|
|
157040
|
+
this._readableState.destroyed = false;
|
|
157041
|
+
this._readableState.reading = false;
|
|
157042
|
+
this._readableState.ended = false;
|
|
157043
|
+
this._readableState.endEmitted = false;
|
|
157044
|
+
}
|
|
157045
|
+
if (this._writableState) {
|
|
157046
|
+
this._writableState.destroyed = false;
|
|
157047
|
+
this._writableState.ended = false;
|
|
157048
|
+
this._writableState.ending = false;
|
|
157049
|
+
this._writableState.finalCalled = false;
|
|
157050
|
+
this._writableState.prefinished = false;
|
|
157051
|
+
this._writableState.finished = false;
|
|
157052
|
+
this._writableState.errorEmitted = false;
|
|
157053
|
+
}
|
|
157054
|
+
}
|
|
157055
|
+
function emitErrorNT(self, err) {
|
|
157056
|
+
self.emit('error', err);
|
|
157057
|
+
}
|
|
157058
|
+
function errorOrDestroy(stream, err) {
|
|
157059
|
+
// We have tests that rely on errors being emitted
|
|
157060
|
+
// in the same tick, so changing this is semver major.
|
|
157061
|
+
// For now when you opt-in to autoDestroy we allow
|
|
157062
|
+
// the error to be emitted nextTick. In a future
|
|
157063
|
+
// semver major update we should change the default to this.
|
|
157064
|
+
|
|
157065
|
+
var rState = stream._readableState;
|
|
157066
|
+
var wState = stream._writableState;
|
|
157067
|
+
if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
|
|
157068
|
+
}
|
|
157069
|
+
destroy_1 = {
|
|
157070
|
+
destroy: destroy,
|
|
157071
|
+
undestroy: undestroy,
|
|
157072
|
+
errorOrDestroy: errorOrDestroy
|
|
157073
|
+
};
|
|
157074
|
+
return destroy_1;
|
|
157075
|
+
}
|
|
157076
|
+
|
|
157077
|
+
var errors = {};
|
|
157078
|
+
|
|
157079
|
+
var hasRequiredErrors;
|
|
157080
|
+
|
|
157081
|
+
function requireErrors () {
|
|
157082
|
+
if (hasRequiredErrors) return errors;
|
|
157083
|
+
hasRequiredErrors = 1;
|
|
157084
|
+
|
|
157085
|
+
const codes = {};
|
|
157086
|
+
|
|
157087
|
+
function createErrorType(code, message, Base) {
|
|
157088
|
+
if (!Base) {
|
|
157089
|
+
Base = Error;
|
|
157090
|
+
}
|
|
157091
|
+
|
|
157092
|
+
function getMessage (arg1, arg2, arg3) {
|
|
157093
|
+
if (typeof message === 'string') {
|
|
157094
|
+
return message
|
|
157095
|
+
} else {
|
|
157096
|
+
return message(arg1, arg2, arg3)
|
|
157097
|
+
}
|
|
157098
|
+
}
|
|
157099
|
+
|
|
157100
|
+
class NodeError extends Base {
|
|
157101
|
+
constructor (arg1, arg2, arg3) {
|
|
157102
|
+
super(getMessage(arg1, arg2, arg3));
|
|
157103
|
+
}
|
|
157104
|
+
}
|
|
157105
|
+
|
|
157106
|
+
NodeError.prototype.name = Base.name;
|
|
157107
|
+
NodeError.prototype.code = code;
|
|
157108
|
+
|
|
157109
|
+
codes[code] = NodeError;
|
|
157110
|
+
}
|
|
157111
|
+
|
|
157112
|
+
// https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
|
|
157113
|
+
function oneOf(expected, thing) {
|
|
157114
|
+
if (Array.isArray(expected)) {
|
|
157115
|
+
const len = expected.length;
|
|
157116
|
+
expected = expected.map((i) => String(i));
|
|
157117
|
+
if (len > 2) {
|
|
157118
|
+
return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or ` +
|
|
157119
|
+
expected[len - 1];
|
|
157120
|
+
} else if (len === 2) {
|
|
157121
|
+
return `one of ${thing} ${expected[0]} or ${expected[1]}`;
|
|
157122
|
+
} else {
|
|
157123
|
+
return `of ${thing} ${expected[0]}`;
|
|
157124
|
+
}
|
|
157125
|
+
} else {
|
|
157126
|
+
return `of ${thing} ${String(expected)}`;
|
|
157127
|
+
}
|
|
157128
|
+
}
|
|
157129
|
+
|
|
157130
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
|
|
157131
|
+
function startsWith(str, search, pos) {
|
|
157132
|
+
return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
|
|
157133
|
+
}
|
|
157134
|
+
|
|
157135
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
|
|
157136
|
+
function endsWith(str, search, this_len) {
|
|
157137
|
+
if (this_len === undefined || this_len > str.length) {
|
|
157138
|
+
this_len = str.length;
|
|
157139
|
+
}
|
|
157140
|
+
return str.substring(this_len - search.length, this_len) === search;
|
|
157141
|
+
}
|
|
157142
|
+
|
|
157143
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
|
|
157144
|
+
function includes(str, search, start) {
|
|
157145
|
+
if (typeof start !== 'number') {
|
|
157146
|
+
start = 0;
|
|
157147
|
+
}
|
|
157148
|
+
|
|
157149
|
+
if (start + search.length > str.length) {
|
|
157150
|
+
return false;
|
|
157151
|
+
} else {
|
|
157152
|
+
return str.indexOf(search, start) !== -1;
|
|
157153
|
+
}
|
|
157154
|
+
}
|
|
157155
|
+
|
|
157156
|
+
createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
|
|
157157
|
+
return 'The value "' + value + '" is invalid for option "' + name + '"'
|
|
157158
|
+
}, TypeError);
|
|
157159
|
+
createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
|
|
157160
|
+
// determiner: 'must be' or 'must not be'
|
|
157161
|
+
let determiner;
|
|
157162
|
+
if (typeof expected === 'string' && startsWith(expected, 'not ')) {
|
|
157163
|
+
determiner = 'must not be';
|
|
157164
|
+
expected = expected.replace(/^not /, '');
|
|
157165
|
+
} else {
|
|
157166
|
+
determiner = 'must be';
|
|
157167
|
+
}
|
|
157168
|
+
|
|
157169
|
+
let msg;
|
|
157170
|
+
if (endsWith(name, ' argument')) {
|
|
157171
|
+
// For cases like 'first argument'
|
|
157172
|
+
msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`;
|
|
157173
|
+
} else {
|
|
157174
|
+
const type = includes(name, '.') ? 'property' : 'argument';
|
|
157175
|
+
msg = `The "${name}" ${type} ${determiner} ${oneOf(expected, 'type')}`;
|
|
157176
|
+
}
|
|
157177
|
+
|
|
157178
|
+
msg += `. Received type ${typeof actual}`;
|
|
157179
|
+
return msg;
|
|
157180
|
+
}, TypeError);
|
|
157181
|
+
createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
|
|
157182
|
+
createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
|
|
157183
|
+
return 'The ' + name + ' method is not implemented'
|
|
157184
|
+
});
|
|
157185
|
+
createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
|
|
157186
|
+
createErrorType('ERR_STREAM_DESTROYED', function (name) {
|
|
157187
|
+
return 'Cannot call ' + name + ' after a stream was destroyed';
|
|
157188
|
+
});
|
|
157189
|
+
createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
|
|
157190
|
+
createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
|
|
157191
|
+
createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
|
|
157192
|
+
createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
|
|
157193
|
+
createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
|
|
157194
|
+
return 'Unknown encoding: ' + arg
|
|
157195
|
+
}, TypeError);
|
|
157196
|
+
createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
|
|
157197
|
+
|
|
157198
|
+
errors.codes = codes;
|
|
157199
|
+
return errors;
|
|
157200
|
+
}
|
|
157201
|
+
|
|
157202
|
+
var state;
|
|
157203
|
+
var hasRequiredState;
|
|
157204
|
+
|
|
157205
|
+
function requireState () {
|
|
157206
|
+
if (hasRequiredState) return state;
|
|
157207
|
+
hasRequiredState = 1;
|
|
157208
|
+
|
|
157209
|
+
var ERR_INVALID_OPT_VALUE = requireErrors().codes.ERR_INVALID_OPT_VALUE;
|
|
157210
|
+
function highWaterMarkFrom(options, isDuplex, duplexKey) {
|
|
157211
|
+
return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
|
|
157212
|
+
}
|
|
157213
|
+
function getHighWaterMark(state, options, duplexKey, isDuplex) {
|
|
157214
|
+
var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
|
|
157215
|
+
if (hwm != null) {
|
|
157216
|
+
if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
|
|
157217
|
+
var name = isDuplex ? duplexKey : 'highWaterMark';
|
|
157218
|
+
throw new ERR_INVALID_OPT_VALUE(name, hwm);
|
|
157219
|
+
}
|
|
157220
|
+
return Math.floor(hwm);
|
|
157221
|
+
}
|
|
157222
|
+
|
|
157223
|
+
// Default value
|
|
157224
|
+
return state.objectMode ? 16 : 16 * 1024;
|
|
157225
|
+
}
|
|
157226
|
+
state = {
|
|
157227
|
+
getHighWaterMark: getHighWaterMark
|
|
157228
|
+
};
|
|
157229
|
+
return state;
|
|
157230
|
+
}
|
|
157231
|
+
|
|
157232
|
+
var node;
|
|
157233
|
+
var hasRequiredNode;
|
|
157234
|
+
|
|
157235
|
+
function requireNode () {
|
|
157236
|
+
if (hasRequiredNode) return node;
|
|
157237
|
+
hasRequiredNode = 1;
|
|
157238
|
+
/**
|
|
157239
|
+
* For Node.js, simply re-export the core `util.deprecate` function.
|
|
157240
|
+
*/
|
|
157241
|
+
|
|
157242
|
+
node = require$$0$5.deprecate;
|
|
157243
|
+
return node;
|
|
157244
|
+
}
|
|
157245
|
+
|
|
157246
|
+
var _stream_writable;
|
|
157247
|
+
var hasRequired_stream_writable;
|
|
157248
|
+
|
|
157249
|
+
function require_stream_writable () {
|
|
157250
|
+
if (hasRequired_stream_writable) return _stream_writable;
|
|
157251
|
+
hasRequired_stream_writable = 1;
|
|
157252
|
+
|
|
157253
|
+
_stream_writable = Writable;
|
|
157254
|
+
|
|
157255
|
+
// It seems a linked list but it is not
|
|
157256
|
+
// there will be only 2 of these for each stream
|
|
157257
|
+
function CorkedRequest(state) {
|
|
157258
|
+
var _this = this;
|
|
157259
|
+
this.next = null;
|
|
157260
|
+
this.entry = null;
|
|
157261
|
+
this.finish = function () {
|
|
157262
|
+
onCorkedFinish(_this, state);
|
|
157263
|
+
};
|
|
157264
|
+
}
|
|
157265
|
+
/* </replacement> */
|
|
157266
|
+
|
|
157267
|
+
/*<replacement>*/
|
|
157268
|
+
var Duplex;
|
|
157269
|
+
/*</replacement>*/
|
|
157270
|
+
|
|
157271
|
+
Writable.WritableState = WritableState;
|
|
157272
|
+
|
|
157273
|
+
/*<replacement>*/
|
|
157274
|
+
var internalUtil = {
|
|
157275
|
+
deprecate: requireNode()
|
|
157276
|
+
};
|
|
157277
|
+
/*</replacement>*/
|
|
157278
|
+
|
|
157279
|
+
/*<replacement>*/
|
|
157280
|
+
var Stream = requireStream();
|
|
157281
|
+
/*</replacement>*/
|
|
157282
|
+
|
|
157283
|
+
var Buffer = require$$2$4.Buffer;
|
|
157284
|
+
var OurUint8Array = (typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
|
|
157285
|
+
function _uint8ArrayToBuffer(chunk) {
|
|
157286
|
+
return Buffer.from(chunk);
|
|
157287
|
+
}
|
|
157288
|
+
function _isUint8Array(obj) {
|
|
157289
|
+
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
157290
|
+
}
|
|
157291
|
+
var destroyImpl = requireDestroy();
|
|
157292
|
+
var _require = requireState(),
|
|
157293
|
+
getHighWaterMark = _require.getHighWaterMark;
|
|
157294
|
+
var _require$codes = requireErrors().codes,
|
|
157295
|
+
ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
|
|
157296
|
+
ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
|
|
157297
|
+
ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
|
|
157298
|
+
ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,
|
|
157299
|
+
ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,
|
|
157300
|
+
ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,
|
|
157301
|
+
ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,
|
|
157302
|
+
ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
|
|
157303
|
+
var errorOrDestroy = destroyImpl.errorOrDestroy;
|
|
157304
|
+
inheritsExports(Writable, Stream);
|
|
157305
|
+
function nop() {}
|
|
157306
|
+
function WritableState(options, stream, isDuplex) {
|
|
157307
|
+
Duplex = Duplex || require_stream_duplex();
|
|
157308
|
+
options = options || {};
|
|
157309
|
+
|
|
157310
|
+
// Duplex streams are both readable and writable, but share
|
|
157311
|
+
// the same options object.
|
|
157312
|
+
// However, some cases require setting options to different
|
|
157313
|
+
// values for the readable and the writable sides of the duplex stream,
|
|
157314
|
+
// e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
|
|
157315
|
+
if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex;
|
|
157316
|
+
|
|
157317
|
+
// object stream flag to indicate whether or not this stream
|
|
157318
|
+
// contains buffers or objects.
|
|
157319
|
+
this.objectMode = !!options.objectMode;
|
|
157320
|
+
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
|
|
157321
|
+
|
|
157322
|
+
// the point at which write() starts returning false
|
|
157323
|
+
// Note: 0 is a valid value, means that we always return false if
|
|
157324
|
+
// the entire buffer is not flushed immediately on write()
|
|
157325
|
+
this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex);
|
|
157326
|
+
|
|
157327
|
+
// if _final has been called
|
|
157328
|
+
this.finalCalled = false;
|
|
157329
|
+
|
|
157330
|
+
// drain event flag.
|
|
157331
|
+
this.needDrain = false;
|
|
157332
|
+
// at the start of calling end()
|
|
157333
|
+
this.ending = false;
|
|
157334
|
+
// when end() has been called, and returned
|
|
157335
|
+
this.ended = false;
|
|
157336
|
+
// when 'finish' is emitted
|
|
157337
|
+
this.finished = false;
|
|
157338
|
+
|
|
157339
|
+
// has it been destroyed
|
|
157340
|
+
this.destroyed = false;
|
|
157341
|
+
|
|
157342
|
+
// should we decode strings into buffers before passing to _write?
|
|
157343
|
+
// this is here so that some node-core streams can optimize string
|
|
157344
|
+
// handling at a lower level.
|
|
157345
|
+
var noDecode = options.decodeStrings === false;
|
|
157346
|
+
this.decodeStrings = !noDecode;
|
|
157347
|
+
|
|
157348
|
+
// Crypto is kind of old and crusty. Historically, its default string
|
|
157349
|
+
// encoding is 'binary' so we have to make this configurable.
|
|
157350
|
+
// Everything else in the universe uses 'utf8', though.
|
|
157351
|
+
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
|
157352
|
+
|
|
157353
|
+
// not an actual buffer we keep track of, but a measurement
|
|
157354
|
+
// of how much we're waiting to get pushed to some underlying
|
|
157355
|
+
// socket or file.
|
|
157356
|
+
this.length = 0;
|
|
157357
|
+
|
|
157358
|
+
// a flag to see when we're in the middle of a write.
|
|
157359
|
+
this.writing = false;
|
|
157360
|
+
|
|
157361
|
+
// when true all writes will be buffered until .uncork() call
|
|
157362
|
+
this.corked = 0;
|
|
157363
|
+
|
|
157364
|
+
// a flag to be able to tell if the onwrite cb is called immediately,
|
|
157365
|
+
// or on a later tick. We set this to true at first, because any
|
|
157366
|
+
// actions that shouldn't happen until "later" should generally also
|
|
157367
|
+
// not happen before the first write call.
|
|
157368
|
+
this.sync = true;
|
|
157369
|
+
|
|
157370
|
+
// a flag to know if we're processing previously buffered items, which
|
|
157371
|
+
// may call the _write() callback in the same tick, so that we don't
|
|
157372
|
+
// end up in an overlapped onwrite situation.
|
|
157373
|
+
this.bufferProcessing = false;
|
|
157374
|
+
|
|
157375
|
+
// the callback that's passed to _write(chunk,cb)
|
|
157376
|
+
this.onwrite = function (er) {
|
|
157377
|
+
onwrite(stream, er);
|
|
157378
|
+
};
|
|
157379
|
+
|
|
157380
|
+
// the callback that the user supplies to write(chunk,encoding,cb)
|
|
157381
|
+
this.writecb = null;
|
|
157382
|
+
|
|
157383
|
+
// the amount that is being written when _write is called.
|
|
157384
|
+
this.writelen = 0;
|
|
157385
|
+
this.bufferedRequest = null;
|
|
157386
|
+
this.lastBufferedRequest = null;
|
|
157387
|
+
|
|
157388
|
+
// number of pending user-supplied write callbacks
|
|
157389
|
+
// this must be 0 before 'finish' can be emitted
|
|
157390
|
+
this.pendingcb = 0;
|
|
157391
|
+
|
|
157392
|
+
// emit prefinish if the only thing we're waiting for is _write cbs
|
|
157393
|
+
// This is relevant for synchronous Transform streams
|
|
157394
|
+
this.prefinished = false;
|
|
157395
|
+
|
|
157396
|
+
// True if the error was already emitted and should not be thrown again
|
|
157397
|
+
this.errorEmitted = false;
|
|
157398
|
+
|
|
157399
|
+
// Should close be emitted on destroy. Defaults to true.
|
|
157400
|
+
this.emitClose = options.emitClose !== false;
|
|
157401
|
+
|
|
157402
|
+
// Should .destroy() be called after 'finish' (and potentially 'end')
|
|
157403
|
+
this.autoDestroy = !!options.autoDestroy;
|
|
157404
|
+
|
|
157405
|
+
// count buffered requests
|
|
157406
|
+
this.bufferedRequestCount = 0;
|
|
157407
|
+
|
|
157408
|
+
// allocate the first CorkedRequest, there is always
|
|
157409
|
+
// one allocated and free to use, and we maintain at most two
|
|
157410
|
+
this.corkedRequestsFree = new CorkedRequest(this);
|
|
157411
|
+
}
|
|
157412
|
+
WritableState.prototype.getBuffer = function getBuffer() {
|
|
157413
|
+
var current = this.bufferedRequest;
|
|
157414
|
+
var out = [];
|
|
157415
|
+
while (current) {
|
|
157416
|
+
out.push(current);
|
|
157417
|
+
current = current.next;
|
|
157418
|
+
}
|
|
157419
|
+
return out;
|
|
157420
|
+
};
|
|
157421
|
+
(function () {
|
|
157422
|
+
try {
|
|
157423
|
+
Object.defineProperty(WritableState.prototype, 'buffer', {
|
|
157424
|
+
get: internalUtil.deprecate(function writableStateBufferGetter() {
|
|
157425
|
+
return this.getBuffer();
|
|
157426
|
+
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
|
|
157427
|
+
});
|
|
157428
|
+
} catch (_) {}
|
|
157429
|
+
})();
|
|
157430
|
+
|
|
157431
|
+
// Test _writableState for inheritance to account for Duplex streams,
|
|
157432
|
+
// whose prototype chain only points to Readable.
|
|
157433
|
+
var realHasInstance;
|
|
157434
|
+
if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
|
|
157435
|
+
realHasInstance = Function.prototype[Symbol.hasInstance];
|
|
157436
|
+
Object.defineProperty(Writable, Symbol.hasInstance, {
|
|
157437
|
+
value: function value(object) {
|
|
157438
|
+
if (realHasInstance.call(this, object)) return true;
|
|
157439
|
+
if (this !== Writable) return false;
|
|
157440
|
+
return object && object._writableState instanceof WritableState;
|
|
157441
|
+
}
|
|
157442
|
+
});
|
|
157443
|
+
} else {
|
|
157444
|
+
realHasInstance = function realHasInstance(object) {
|
|
157445
|
+
return object instanceof this;
|
|
157446
|
+
};
|
|
157447
|
+
}
|
|
157448
|
+
function Writable(options) {
|
|
157449
|
+
Duplex = Duplex || require_stream_duplex();
|
|
157450
|
+
|
|
157451
|
+
// Writable ctor is applied to Duplexes, too.
|
|
157452
|
+
// `realHasInstance` is necessary because using plain `instanceof`
|
|
157453
|
+
// would return false, as no `_writableState` property is attached.
|
|
157454
|
+
|
|
157455
|
+
// Trying to use the custom `instanceof` for Writable here will also break the
|
|
157456
|
+
// Node.js LazyTransform implementation, which has a non-trivial getter for
|
|
157457
|
+
// `_writableState` that would lead to infinite recursion.
|
|
157458
|
+
|
|
157459
|
+
// Checking for a Stream.Duplex instance is faster here instead of inside
|
|
157460
|
+
// the WritableState constructor, at least with V8 6.5
|
|
157461
|
+
var isDuplex = this instanceof Duplex;
|
|
157462
|
+
if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);
|
|
157463
|
+
this._writableState = new WritableState(options, this, isDuplex);
|
|
157464
|
+
|
|
157465
|
+
// legacy.
|
|
157466
|
+
this.writable = true;
|
|
157467
|
+
if (options) {
|
|
157468
|
+
if (typeof options.write === 'function') this._write = options.write;
|
|
157469
|
+
if (typeof options.writev === 'function') this._writev = options.writev;
|
|
157470
|
+
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
|
157471
|
+
if (typeof options.final === 'function') this._final = options.final;
|
|
157472
|
+
}
|
|
157473
|
+
Stream.call(this);
|
|
157474
|
+
}
|
|
157475
|
+
|
|
157476
|
+
// Otherwise people can pipe Writable streams, which is just wrong.
|
|
157477
|
+
Writable.prototype.pipe = function () {
|
|
157478
|
+
errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
|
|
157479
|
+
};
|
|
157480
|
+
function writeAfterEnd(stream, cb) {
|
|
157481
|
+
var er = new ERR_STREAM_WRITE_AFTER_END();
|
|
157482
|
+
// TODO: defer error events consistently everywhere, not just the cb
|
|
157483
|
+
errorOrDestroy(stream, er);
|
|
157484
|
+
process.nextTick(cb, er);
|
|
157485
|
+
}
|
|
157486
|
+
|
|
157487
|
+
// Checks that a user-supplied chunk is valid, especially for the particular
|
|
157488
|
+
// mode the stream is in. Currently this means that `null` is never accepted
|
|
157489
|
+
// and undefined/non-string values are only allowed in object mode.
|
|
157490
|
+
function validChunk(stream, state, chunk, cb) {
|
|
157491
|
+
var er;
|
|
157492
|
+
if (chunk === null) {
|
|
157493
|
+
er = new ERR_STREAM_NULL_VALUES();
|
|
157494
|
+
} else if (typeof chunk !== 'string' && !state.objectMode) {
|
|
157495
|
+
er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);
|
|
157496
|
+
}
|
|
157497
|
+
if (er) {
|
|
157498
|
+
errorOrDestroy(stream, er);
|
|
157499
|
+
process.nextTick(cb, er);
|
|
157500
|
+
return false;
|
|
157501
|
+
}
|
|
157502
|
+
return true;
|
|
157503
|
+
}
|
|
157504
|
+
Writable.prototype.write = function (chunk, encoding, cb) {
|
|
157505
|
+
var state = this._writableState;
|
|
157506
|
+
var ret = false;
|
|
157507
|
+
var isBuf = !state.objectMode && _isUint8Array(chunk);
|
|
157508
|
+
if (isBuf && !Buffer.isBuffer(chunk)) {
|
|
157509
|
+
chunk = _uint8ArrayToBuffer(chunk);
|
|
157510
|
+
}
|
|
157511
|
+
if (typeof encoding === 'function') {
|
|
157512
|
+
cb = encoding;
|
|
157513
|
+
encoding = null;
|
|
157514
|
+
}
|
|
157515
|
+
if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
|
|
157516
|
+
if (typeof cb !== 'function') cb = nop;
|
|
157517
|
+
if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
|
|
157518
|
+
state.pendingcb++;
|
|
157519
|
+
ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
|
|
157520
|
+
}
|
|
157521
|
+
return ret;
|
|
157522
|
+
};
|
|
157523
|
+
Writable.prototype.cork = function () {
|
|
157524
|
+
this._writableState.corked++;
|
|
157525
|
+
};
|
|
157526
|
+
Writable.prototype.uncork = function () {
|
|
157527
|
+
var state = this._writableState;
|
|
157528
|
+
if (state.corked) {
|
|
157529
|
+
state.corked--;
|
|
157530
|
+
if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
|
|
157531
|
+
}
|
|
157532
|
+
};
|
|
157533
|
+
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
|
157534
|
+
// node::ParseEncoding() requires lower case.
|
|
157535
|
+
if (typeof encoding === 'string') encoding = encoding.toLowerCase();
|
|
157536
|
+
if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding);
|
|
157537
|
+
this._writableState.defaultEncoding = encoding;
|
|
157538
|
+
return this;
|
|
157539
|
+
};
|
|
157540
|
+
Object.defineProperty(Writable.prototype, 'writableBuffer', {
|
|
157541
|
+
// making it explicit this property is not enumerable
|
|
157542
|
+
// because otherwise some prototype manipulation in
|
|
157543
|
+
// userland will fail
|
|
157544
|
+
enumerable: false,
|
|
157545
|
+
get: function get() {
|
|
157546
|
+
return this._writableState && this._writableState.getBuffer();
|
|
157547
|
+
}
|
|
157548
|
+
});
|
|
157549
|
+
function decodeChunk(state, chunk, encoding) {
|
|
157550
|
+
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
|
|
157551
|
+
chunk = Buffer.from(chunk, encoding);
|
|
157552
|
+
}
|
|
157553
|
+
return chunk;
|
|
157554
|
+
}
|
|
157555
|
+
Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
|
|
157556
|
+
// making it explicit this property is not enumerable
|
|
157557
|
+
// because otherwise some prototype manipulation in
|
|
157558
|
+
// userland will fail
|
|
157559
|
+
enumerable: false,
|
|
157560
|
+
get: function get() {
|
|
157561
|
+
return this._writableState.highWaterMark;
|
|
157562
|
+
}
|
|
157563
|
+
});
|
|
157564
|
+
|
|
157565
|
+
// if we're already writing something, then just put this
|
|
157566
|
+
// in the queue, and wait our turn. Otherwise, call _write
|
|
157567
|
+
// If we return false, then we need a drain event, so set that flag.
|
|
157568
|
+
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
|
|
157569
|
+
if (!isBuf) {
|
|
157570
|
+
var newChunk = decodeChunk(state, chunk, encoding);
|
|
157571
|
+
if (chunk !== newChunk) {
|
|
157572
|
+
isBuf = true;
|
|
157573
|
+
encoding = 'buffer';
|
|
157574
|
+
chunk = newChunk;
|
|
157575
|
+
}
|
|
157576
|
+
}
|
|
157577
|
+
var len = state.objectMode ? 1 : chunk.length;
|
|
157578
|
+
state.length += len;
|
|
157579
|
+
var ret = state.length < state.highWaterMark;
|
|
157580
|
+
// we must ensure that previous needDrain will not be reset to false.
|
|
157581
|
+
if (!ret) state.needDrain = true;
|
|
157582
|
+
if (state.writing || state.corked) {
|
|
157583
|
+
var last = state.lastBufferedRequest;
|
|
157584
|
+
state.lastBufferedRequest = {
|
|
157585
|
+
chunk: chunk,
|
|
157586
|
+
encoding: encoding,
|
|
157587
|
+
isBuf: isBuf,
|
|
157588
|
+
callback: cb,
|
|
157589
|
+
next: null
|
|
157590
|
+
};
|
|
157591
|
+
if (last) {
|
|
157592
|
+
last.next = state.lastBufferedRequest;
|
|
157593
|
+
} else {
|
|
157594
|
+
state.bufferedRequest = state.lastBufferedRequest;
|
|
157595
|
+
}
|
|
157596
|
+
state.bufferedRequestCount += 1;
|
|
157597
|
+
} else {
|
|
157598
|
+
doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
157599
|
+
}
|
|
157600
|
+
return ret;
|
|
157601
|
+
}
|
|
157602
|
+
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
|
157603
|
+
state.writelen = len;
|
|
157604
|
+
state.writecb = cb;
|
|
157605
|
+
state.writing = true;
|
|
157606
|
+
state.sync = true;
|
|
157607
|
+
if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
|
|
157608
|
+
state.sync = false;
|
|
157609
|
+
}
|
|
157610
|
+
function onwriteError(stream, state, sync, er, cb) {
|
|
157611
|
+
--state.pendingcb;
|
|
157612
|
+
if (sync) {
|
|
157613
|
+
// defer the callback if we are being called synchronously
|
|
157614
|
+
// to avoid piling up things on the stack
|
|
157615
|
+
process.nextTick(cb, er);
|
|
157616
|
+
// this can emit finish, and it will always happen
|
|
157617
|
+
// after error
|
|
157618
|
+
process.nextTick(finishMaybe, stream, state);
|
|
157619
|
+
stream._writableState.errorEmitted = true;
|
|
157620
|
+
errorOrDestroy(stream, er);
|
|
157621
|
+
} else {
|
|
157622
|
+
// the caller expect this to happen before if
|
|
157623
|
+
// it is async
|
|
157624
|
+
cb(er);
|
|
157625
|
+
stream._writableState.errorEmitted = true;
|
|
157626
|
+
errorOrDestroy(stream, er);
|
|
157627
|
+
// this can emit finish, but finish must
|
|
157628
|
+
// always follow error
|
|
157629
|
+
finishMaybe(stream, state);
|
|
157630
|
+
}
|
|
157631
|
+
}
|
|
157632
|
+
function onwriteStateUpdate(state) {
|
|
157633
|
+
state.writing = false;
|
|
157634
|
+
state.writecb = null;
|
|
157635
|
+
state.length -= state.writelen;
|
|
157636
|
+
state.writelen = 0;
|
|
157637
|
+
}
|
|
157638
|
+
function onwrite(stream, er) {
|
|
157639
|
+
var state = stream._writableState;
|
|
157640
|
+
var sync = state.sync;
|
|
157641
|
+
var cb = state.writecb;
|
|
157642
|
+
if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK();
|
|
157643
|
+
onwriteStateUpdate(state);
|
|
157644
|
+
if (er) onwriteError(stream, state, sync, er, cb);else {
|
|
157645
|
+
// Check if we're actually ready to finish, but don't emit yet
|
|
157646
|
+
var finished = needFinish(state) || stream.destroyed;
|
|
157647
|
+
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
|
|
157648
|
+
clearBuffer(stream, state);
|
|
157649
|
+
}
|
|
157650
|
+
if (sync) {
|
|
157651
|
+
process.nextTick(afterWrite, stream, state, finished, cb);
|
|
157652
|
+
} else {
|
|
157653
|
+
afterWrite(stream, state, finished, cb);
|
|
157654
|
+
}
|
|
157655
|
+
}
|
|
157656
|
+
}
|
|
157657
|
+
function afterWrite(stream, state, finished, cb) {
|
|
157658
|
+
if (!finished) onwriteDrain(stream, state);
|
|
157659
|
+
state.pendingcb--;
|
|
157660
|
+
cb();
|
|
157661
|
+
finishMaybe(stream, state);
|
|
157662
|
+
}
|
|
157663
|
+
|
|
157664
|
+
// Must force callback to be called on nextTick, so that we don't
|
|
157665
|
+
// emit 'drain' before the write() consumer gets the 'false' return
|
|
157666
|
+
// value, and has a chance to attach a 'drain' listener.
|
|
157667
|
+
function onwriteDrain(stream, state) {
|
|
157668
|
+
if (state.length === 0 && state.needDrain) {
|
|
157669
|
+
state.needDrain = false;
|
|
157670
|
+
stream.emit('drain');
|
|
157671
|
+
}
|
|
157672
|
+
}
|
|
157673
|
+
|
|
157674
|
+
// if there's something in the buffer waiting, then process it
|
|
157675
|
+
function clearBuffer(stream, state) {
|
|
157676
|
+
state.bufferProcessing = true;
|
|
157677
|
+
var entry = state.bufferedRequest;
|
|
157678
|
+
if (stream._writev && entry && entry.next) {
|
|
157679
|
+
// Fast case, write everything using _writev()
|
|
157680
|
+
var l = state.bufferedRequestCount;
|
|
157681
|
+
var buffer = new Array(l);
|
|
157682
|
+
var holder = state.corkedRequestsFree;
|
|
157683
|
+
holder.entry = entry;
|
|
157684
|
+
var count = 0;
|
|
157685
|
+
var allBuffers = true;
|
|
157686
|
+
while (entry) {
|
|
157687
|
+
buffer[count] = entry;
|
|
157688
|
+
if (!entry.isBuf) allBuffers = false;
|
|
157689
|
+
entry = entry.next;
|
|
157690
|
+
count += 1;
|
|
157691
|
+
}
|
|
157692
|
+
buffer.allBuffers = allBuffers;
|
|
157693
|
+
doWrite(stream, state, true, state.length, buffer, '', holder.finish);
|
|
157694
|
+
|
|
157695
|
+
// doWrite is almost always async, defer these to save a bit of time
|
|
157696
|
+
// as the hot path ends with doWrite
|
|
157697
|
+
state.pendingcb++;
|
|
157698
|
+
state.lastBufferedRequest = null;
|
|
157699
|
+
if (holder.next) {
|
|
157700
|
+
state.corkedRequestsFree = holder.next;
|
|
157701
|
+
holder.next = null;
|
|
157702
|
+
} else {
|
|
157703
|
+
state.corkedRequestsFree = new CorkedRequest(state);
|
|
157704
|
+
}
|
|
157705
|
+
state.bufferedRequestCount = 0;
|
|
157706
|
+
} else {
|
|
157707
|
+
// Slow case, write chunks one-by-one
|
|
157708
|
+
while (entry) {
|
|
157709
|
+
var chunk = entry.chunk;
|
|
157710
|
+
var encoding = entry.encoding;
|
|
157711
|
+
var cb = entry.callback;
|
|
157712
|
+
var len = state.objectMode ? 1 : chunk.length;
|
|
157713
|
+
doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
157714
|
+
entry = entry.next;
|
|
157715
|
+
state.bufferedRequestCount--;
|
|
157716
|
+
// if we didn't call the onwrite immediately, then
|
|
157717
|
+
// it means that we need to wait until it does.
|
|
157718
|
+
// also, that means that the chunk and cb are currently
|
|
157719
|
+
// being processed, so move the buffer counter past them.
|
|
157720
|
+
if (state.writing) {
|
|
157721
|
+
break;
|
|
157722
|
+
}
|
|
157723
|
+
}
|
|
157724
|
+
if (entry === null) state.lastBufferedRequest = null;
|
|
157725
|
+
}
|
|
157726
|
+
state.bufferedRequest = entry;
|
|
157727
|
+
state.bufferProcessing = false;
|
|
157728
|
+
}
|
|
157729
|
+
Writable.prototype._write = function (chunk, encoding, cb) {
|
|
157730
|
+
cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));
|
|
157731
|
+
};
|
|
157732
|
+
Writable.prototype._writev = null;
|
|
157733
|
+
Writable.prototype.end = function (chunk, encoding, cb) {
|
|
157734
|
+
var state = this._writableState;
|
|
157735
|
+
if (typeof chunk === 'function') {
|
|
157736
|
+
cb = chunk;
|
|
157737
|
+
chunk = null;
|
|
157738
|
+
encoding = null;
|
|
157739
|
+
} else if (typeof encoding === 'function') {
|
|
157740
|
+
cb = encoding;
|
|
157741
|
+
encoding = null;
|
|
157742
|
+
}
|
|
157743
|
+
if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
|
|
157744
|
+
|
|
157745
|
+
// .end() fully uncorks
|
|
157746
|
+
if (state.corked) {
|
|
157747
|
+
state.corked = 1;
|
|
157748
|
+
this.uncork();
|
|
157749
|
+
}
|
|
157750
|
+
|
|
157751
|
+
// ignore unnecessary end() calls.
|
|
157752
|
+
if (!state.ending) endWritable(this, state, cb);
|
|
157753
|
+
return this;
|
|
157754
|
+
};
|
|
157755
|
+
Object.defineProperty(Writable.prototype, 'writableLength', {
|
|
157756
|
+
// making it explicit this property is not enumerable
|
|
157757
|
+
// because otherwise some prototype manipulation in
|
|
157758
|
+
// userland will fail
|
|
157759
|
+
enumerable: false,
|
|
157760
|
+
get: function get() {
|
|
157761
|
+
return this._writableState.length;
|
|
157762
|
+
}
|
|
157763
|
+
});
|
|
157764
|
+
function needFinish(state) {
|
|
157765
|
+
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
|
157766
|
+
}
|
|
157767
|
+
function callFinal(stream, state) {
|
|
157768
|
+
stream._final(function (err) {
|
|
157769
|
+
state.pendingcb--;
|
|
157770
|
+
if (err) {
|
|
157771
|
+
errorOrDestroy(stream, err);
|
|
157772
|
+
}
|
|
157773
|
+
state.prefinished = true;
|
|
157774
|
+
stream.emit('prefinish');
|
|
157775
|
+
finishMaybe(stream, state);
|
|
157776
|
+
});
|
|
157777
|
+
}
|
|
157778
|
+
function prefinish(stream, state) {
|
|
157779
|
+
if (!state.prefinished && !state.finalCalled) {
|
|
157780
|
+
if (typeof stream._final === 'function' && !state.destroyed) {
|
|
157781
|
+
state.pendingcb++;
|
|
157782
|
+
state.finalCalled = true;
|
|
157783
|
+
process.nextTick(callFinal, stream, state);
|
|
157784
|
+
} else {
|
|
157785
|
+
state.prefinished = true;
|
|
157786
|
+
stream.emit('prefinish');
|
|
157787
|
+
}
|
|
157788
|
+
}
|
|
157789
|
+
}
|
|
157790
|
+
function finishMaybe(stream, state) {
|
|
157791
|
+
var need = needFinish(state);
|
|
157792
|
+
if (need) {
|
|
157793
|
+
prefinish(stream, state);
|
|
157794
|
+
if (state.pendingcb === 0) {
|
|
157795
|
+
state.finished = true;
|
|
157796
|
+
stream.emit('finish');
|
|
157797
|
+
if (state.autoDestroy) {
|
|
157798
|
+
// In case of duplex streams we need a way to detect
|
|
157799
|
+
// if the readable side is ready for autoDestroy as well
|
|
157800
|
+
var rState = stream._readableState;
|
|
157801
|
+
if (!rState || rState.autoDestroy && rState.endEmitted) {
|
|
157802
|
+
stream.destroy();
|
|
157803
|
+
}
|
|
157804
|
+
}
|
|
157805
|
+
}
|
|
157806
|
+
}
|
|
157807
|
+
return need;
|
|
157808
|
+
}
|
|
157809
|
+
function endWritable(stream, state, cb) {
|
|
157810
|
+
state.ending = true;
|
|
157811
|
+
finishMaybe(stream, state);
|
|
157812
|
+
if (cb) {
|
|
157813
|
+
if (state.finished) process.nextTick(cb);else stream.once('finish', cb);
|
|
157814
|
+
}
|
|
157815
|
+
state.ended = true;
|
|
157816
|
+
stream.writable = false;
|
|
157817
|
+
}
|
|
157818
|
+
function onCorkedFinish(corkReq, state, err) {
|
|
157819
|
+
var entry = corkReq.entry;
|
|
157820
|
+
corkReq.entry = null;
|
|
157821
|
+
while (entry) {
|
|
157822
|
+
var cb = entry.callback;
|
|
157823
|
+
state.pendingcb--;
|
|
157824
|
+
cb(err);
|
|
157825
|
+
entry = entry.next;
|
|
157826
|
+
}
|
|
157827
|
+
|
|
157828
|
+
// reuse the free corkReq.
|
|
157829
|
+
state.corkedRequestsFree.next = corkReq;
|
|
157830
|
+
}
|
|
157831
|
+
Object.defineProperty(Writable.prototype, 'destroyed', {
|
|
157832
|
+
// making it explicit this property is not enumerable
|
|
157833
|
+
// because otherwise some prototype manipulation in
|
|
157834
|
+
// userland will fail
|
|
157835
|
+
enumerable: false,
|
|
157836
|
+
get: function get() {
|
|
157837
|
+
if (this._writableState === undefined) {
|
|
157838
|
+
return false;
|
|
157839
|
+
}
|
|
157840
|
+
return this._writableState.destroyed;
|
|
157841
|
+
},
|
|
157842
|
+
set: function set(value) {
|
|
157843
|
+
// we ignore the value if the stream
|
|
157844
|
+
// has not been initialized yet
|
|
157845
|
+
if (!this._writableState) {
|
|
157846
|
+
return;
|
|
157847
|
+
}
|
|
157848
|
+
|
|
157849
|
+
// backward compatibility, the user is explicitly
|
|
157850
|
+
// managing destroyed
|
|
157851
|
+
this._writableState.destroyed = value;
|
|
157852
|
+
}
|
|
157853
|
+
});
|
|
157854
|
+
Writable.prototype.destroy = destroyImpl.destroy;
|
|
157855
|
+
Writable.prototype._undestroy = destroyImpl.undestroy;
|
|
157856
|
+
Writable.prototype._destroy = function (err, cb) {
|
|
157857
|
+
cb(err);
|
|
157858
|
+
};
|
|
157859
|
+
return _stream_writable;
|
|
157860
|
+
}
|
|
157861
|
+
|
|
157862
|
+
var _stream_duplex;
|
|
157863
|
+
var hasRequired_stream_duplex;
|
|
157864
|
+
|
|
157865
|
+
function require_stream_duplex () {
|
|
157866
|
+
if (hasRequired_stream_duplex) return _stream_duplex;
|
|
157867
|
+
hasRequired_stream_duplex = 1;
|
|
157868
|
+
|
|
157869
|
+
/*<replacement>*/
|
|
157870
|
+
var objectKeys = Object.keys || function (obj) {
|
|
157871
|
+
var keys = [];
|
|
157872
|
+
for (var key in obj) keys.push(key);
|
|
157873
|
+
return keys;
|
|
157874
|
+
};
|
|
157875
|
+
/*</replacement>*/
|
|
157876
|
+
|
|
157877
|
+
_stream_duplex = Duplex;
|
|
157878
|
+
var Readable = require_stream_readable();
|
|
157879
|
+
var Writable = require_stream_writable();
|
|
157880
|
+
inheritsExports(Duplex, Readable);
|
|
157881
|
+
{
|
|
157882
|
+
// Allow the keys array to be GC'ed.
|
|
157883
|
+
var keys = objectKeys(Writable.prototype);
|
|
157884
|
+
for (var v = 0; v < keys.length; v++) {
|
|
157885
|
+
var method = keys[v];
|
|
157886
|
+
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
|
|
157887
|
+
}
|
|
157888
|
+
}
|
|
157889
|
+
function Duplex(options) {
|
|
157890
|
+
if (!(this instanceof Duplex)) return new Duplex(options);
|
|
157891
|
+
Readable.call(this, options);
|
|
157892
|
+
Writable.call(this, options);
|
|
157893
|
+
this.allowHalfOpen = true;
|
|
157894
|
+
if (options) {
|
|
157895
|
+
if (options.readable === false) this.readable = false;
|
|
157896
|
+
if (options.writable === false) this.writable = false;
|
|
157897
|
+
if (options.allowHalfOpen === false) {
|
|
157898
|
+
this.allowHalfOpen = false;
|
|
157899
|
+
this.once('end', onend);
|
|
157900
|
+
}
|
|
157901
|
+
}
|
|
157902
|
+
}
|
|
157903
|
+
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
|
|
157904
|
+
// making it explicit this property is not enumerable
|
|
157905
|
+
// because otherwise some prototype manipulation in
|
|
157906
|
+
// userland will fail
|
|
157907
|
+
enumerable: false,
|
|
157908
|
+
get: function get() {
|
|
157909
|
+
return this._writableState.highWaterMark;
|
|
157910
|
+
}
|
|
157911
|
+
});
|
|
157912
|
+
Object.defineProperty(Duplex.prototype, 'writableBuffer', {
|
|
157913
|
+
// making it explicit this property is not enumerable
|
|
157914
|
+
// because otherwise some prototype manipulation in
|
|
157915
|
+
// userland will fail
|
|
157916
|
+
enumerable: false,
|
|
157917
|
+
get: function get() {
|
|
157918
|
+
return this._writableState && this._writableState.getBuffer();
|
|
157919
|
+
}
|
|
157920
|
+
});
|
|
157921
|
+
Object.defineProperty(Duplex.prototype, 'writableLength', {
|
|
157922
|
+
// making it explicit this property is not enumerable
|
|
157923
|
+
// because otherwise some prototype manipulation in
|
|
157924
|
+
// userland will fail
|
|
157925
|
+
enumerable: false,
|
|
157926
|
+
get: function get() {
|
|
157927
|
+
return this._writableState.length;
|
|
157928
|
+
}
|
|
157929
|
+
});
|
|
157930
|
+
|
|
157931
|
+
// the no-half-open enforcer
|
|
157932
|
+
function onend() {
|
|
157933
|
+
// If the writable side ended, then we're ok.
|
|
157934
|
+
if (this._writableState.ended) return;
|
|
157935
|
+
|
|
157936
|
+
// no more data can be written.
|
|
157937
|
+
// But allow more writes to happen in this tick.
|
|
157938
|
+
process.nextTick(onEndNT, this);
|
|
157939
|
+
}
|
|
157940
|
+
function onEndNT(self) {
|
|
157941
|
+
self.end();
|
|
157942
|
+
}
|
|
157943
|
+
Object.defineProperty(Duplex.prototype, 'destroyed', {
|
|
157944
|
+
// making it explicit this property is not enumerable
|
|
157945
|
+
// because otherwise some prototype manipulation in
|
|
157946
|
+
// userland will fail
|
|
157947
|
+
enumerable: false,
|
|
157948
|
+
get: function get() {
|
|
157949
|
+
if (this._readableState === undefined || this._writableState === undefined) {
|
|
157950
|
+
return false;
|
|
157951
|
+
}
|
|
157952
|
+
return this._readableState.destroyed && this._writableState.destroyed;
|
|
157953
|
+
},
|
|
157954
|
+
set: function set(value) {
|
|
157955
|
+
// we ignore the value if the stream
|
|
157956
|
+
// has not been initialized yet
|
|
157957
|
+
if (this._readableState === undefined || this._writableState === undefined) {
|
|
157958
|
+
return;
|
|
157959
|
+
}
|
|
157960
|
+
|
|
157961
|
+
// backward compatibility, the user is explicitly
|
|
157962
|
+
// managing destroyed
|
|
157963
|
+
this._readableState.destroyed = value;
|
|
157964
|
+
this._writableState.destroyed = value;
|
|
157965
|
+
}
|
|
157966
|
+
});
|
|
157967
|
+
return _stream_duplex;
|
|
157968
|
+
}
|
|
157969
|
+
|
|
157970
|
+
var string_decoder = {};
|
|
157971
|
+
|
|
157972
|
+
var safeBuffer = {exports: {}};
|
|
157973
|
+
|
|
157974
|
+
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
157975
|
+
|
|
157976
|
+
var hasRequiredSafeBuffer;
|
|
157977
|
+
|
|
157978
|
+
function requireSafeBuffer () {
|
|
157979
|
+
if (hasRequiredSafeBuffer) return safeBuffer.exports;
|
|
157980
|
+
hasRequiredSafeBuffer = 1;
|
|
157981
|
+
(function (module, exports) {
|
|
157982
|
+
/* eslint-disable node/no-deprecated-api */
|
|
157983
|
+
var buffer = require$$2$4;
|
|
157984
|
+
var Buffer = buffer.Buffer;
|
|
157985
|
+
|
|
157986
|
+
// alternative to using Object.keys for old browsers
|
|
157987
|
+
function copyProps (src, dst) {
|
|
157988
|
+
for (var key in src) {
|
|
157989
|
+
dst[key] = src[key];
|
|
157990
|
+
}
|
|
157991
|
+
}
|
|
157992
|
+
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
|
157993
|
+
module.exports = buffer;
|
|
157994
|
+
} else {
|
|
157995
|
+
// Copy properties from require('buffer')
|
|
157996
|
+
copyProps(buffer, exports);
|
|
157997
|
+
exports.Buffer = SafeBuffer;
|
|
157998
|
+
}
|
|
157999
|
+
|
|
158000
|
+
function SafeBuffer (arg, encodingOrOffset, length) {
|
|
158001
|
+
return Buffer(arg, encodingOrOffset, length)
|
|
158002
|
+
}
|
|
158003
|
+
|
|
158004
|
+
SafeBuffer.prototype = Object.create(Buffer.prototype);
|
|
158005
|
+
|
|
158006
|
+
// Copy static methods from Buffer
|
|
158007
|
+
copyProps(Buffer, SafeBuffer);
|
|
158008
|
+
|
|
158009
|
+
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
|
158010
|
+
if (typeof arg === 'number') {
|
|
158011
|
+
throw new TypeError('Argument must not be a number')
|
|
158012
|
+
}
|
|
158013
|
+
return Buffer(arg, encodingOrOffset, length)
|
|
158014
|
+
};
|
|
158015
|
+
|
|
158016
|
+
SafeBuffer.alloc = function (size, fill, encoding) {
|
|
158017
|
+
if (typeof size !== 'number') {
|
|
158018
|
+
throw new TypeError('Argument must be a number')
|
|
158019
|
+
}
|
|
158020
|
+
var buf = Buffer(size);
|
|
158021
|
+
if (fill !== undefined) {
|
|
158022
|
+
if (typeof encoding === 'string') {
|
|
158023
|
+
buf.fill(fill, encoding);
|
|
158024
|
+
} else {
|
|
158025
|
+
buf.fill(fill);
|
|
158026
|
+
}
|
|
158027
|
+
} else {
|
|
158028
|
+
buf.fill(0);
|
|
158029
|
+
}
|
|
158030
|
+
return buf
|
|
158031
|
+
};
|
|
158032
|
+
|
|
158033
|
+
SafeBuffer.allocUnsafe = function (size) {
|
|
158034
|
+
if (typeof size !== 'number') {
|
|
158035
|
+
throw new TypeError('Argument must be a number')
|
|
158036
|
+
}
|
|
158037
|
+
return Buffer(size)
|
|
158038
|
+
};
|
|
158039
|
+
|
|
158040
|
+
SafeBuffer.allocUnsafeSlow = function (size) {
|
|
158041
|
+
if (typeof size !== 'number') {
|
|
158042
|
+
throw new TypeError('Argument must be a number')
|
|
158043
|
+
}
|
|
158044
|
+
return buffer.SlowBuffer(size)
|
|
158045
|
+
};
|
|
158046
|
+
} (safeBuffer, safeBuffer.exports));
|
|
158047
|
+
return safeBuffer.exports;
|
|
158048
|
+
}
|
|
158049
|
+
|
|
158050
|
+
var hasRequiredString_decoder;
|
|
158051
|
+
|
|
158052
|
+
function requireString_decoder () {
|
|
158053
|
+
if (hasRequiredString_decoder) return string_decoder;
|
|
158054
|
+
hasRequiredString_decoder = 1;
|
|
158055
|
+
|
|
158056
|
+
/*<replacement>*/
|
|
158057
|
+
|
|
158058
|
+
var Buffer = requireSafeBuffer().Buffer;
|
|
158059
|
+
/*</replacement>*/
|
|
158060
|
+
|
|
158061
|
+
var isEncoding = Buffer.isEncoding || function (encoding) {
|
|
158062
|
+
encoding = '' + encoding;
|
|
158063
|
+
switch (encoding && encoding.toLowerCase()) {
|
|
158064
|
+
case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
|
|
158065
|
+
return true;
|
|
158066
|
+
default:
|
|
158067
|
+
return false;
|
|
158068
|
+
}
|
|
158069
|
+
};
|
|
158070
|
+
|
|
158071
|
+
function _normalizeEncoding(enc) {
|
|
158072
|
+
if (!enc) return 'utf8';
|
|
158073
|
+
var retried;
|
|
158074
|
+
while (true) {
|
|
158075
|
+
switch (enc) {
|
|
158076
|
+
case 'utf8':
|
|
158077
|
+
case 'utf-8':
|
|
158078
|
+
return 'utf8';
|
|
158079
|
+
case 'ucs2':
|
|
158080
|
+
case 'ucs-2':
|
|
158081
|
+
case 'utf16le':
|
|
158082
|
+
case 'utf-16le':
|
|
158083
|
+
return 'utf16le';
|
|
158084
|
+
case 'latin1':
|
|
158085
|
+
case 'binary':
|
|
158086
|
+
return 'latin1';
|
|
158087
|
+
case 'base64':
|
|
158088
|
+
case 'ascii':
|
|
158089
|
+
case 'hex':
|
|
158090
|
+
return enc;
|
|
158091
|
+
default:
|
|
158092
|
+
if (retried) return; // undefined
|
|
158093
|
+
enc = ('' + enc).toLowerCase();
|
|
158094
|
+
retried = true;
|
|
158095
|
+
}
|
|
158096
|
+
}
|
|
158097
|
+
}
|
|
158098
|
+
// Do not cache `Buffer.isEncoding` when checking encoding names as some
|
|
158099
|
+
// modules monkey-patch it to support additional encodings
|
|
158100
|
+
function normalizeEncoding(enc) {
|
|
158101
|
+
var nenc = _normalizeEncoding(enc);
|
|
158102
|
+
if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
|
|
158103
|
+
return nenc || enc;
|
|
158104
|
+
}
|
|
158105
|
+
|
|
158106
|
+
// StringDecoder provides an interface for efficiently splitting a series of
|
|
158107
|
+
// buffers into a series of JS strings without breaking apart multi-byte
|
|
158108
|
+
// characters.
|
|
158109
|
+
string_decoder.StringDecoder = StringDecoder;
|
|
158110
|
+
function StringDecoder(encoding) {
|
|
158111
|
+
this.encoding = normalizeEncoding(encoding);
|
|
158112
|
+
var nb;
|
|
158113
|
+
switch (this.encoding) {
|
|
158114
|
+
case 'utf16le':
|
|
158115
|
+
this.text = utf16Text;
|
|
158116
|
+
this.end = utf16End;
|
|
158117
|
+
nb = 4;
|
|
158118
|
+
break;
|
|
158119
|
+
case 'utf8':
|
|
158120
|
+
this.fillLast = utf8FillLast;
|
|
158121
|
+
nb = 4;
|
|
158122
|
+
break;
|
|
158123
|
+
case 'base64':
|
|
158124
|
+
this.text = base64Text;
|
|
158125
|
+
this.end = base64End;
|
|
158126
|
+
nb = 3;
|
|
158127
|
+
break;
|
|
158128
|
+
default:
|
|
158129
|
+
this.write = simpleWrite;
|
|
158130
|
+
this.end = simpleEnd;
|
|
158131
|
+
return;
|
|
158132
|
+
}
|
|
158133
|
+
this.lastNeed = 0;
|
|
158134
|
+
this.lastTotal = 0;
|
|
158135
|
+
this.lastChar = Buffer.allocUnsafe(nb);
|
|
158136
|
+
}
|
|
158137
|
+
|
|
158138
|
+
StringDecoder.prototype.write = function (buf) {
|
|
158139
|
+
if (buf.length === 0) return '';
|
|
158140
|
+
var r;
|
|
158141
|
+
var i;
|
|
158142
|
+
if (this.lastNeed) {
|
|
158143
|
+
r = this.fillLast(buf);
|
|
158144
|
+
if (r === undefined) return '';
|
|
158145
|
+
i = this.lastNeed;
|
|
158146
|
+
this.lastNeed = 0;
|
|
158147
|
+
} else {
|
|
158148
|
+
i = 0;
|
|
158149
|
+
}
|
|
158150
|
+
if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
|
|
158151
|
+
return r || '';
|
|
158152
|
+
};
|
|
158153
|
+
|
|
158154
|
+
StringDecoder.prototype.end = utf8End;
|
|
158155
|
+
|
|
158156
|
+
// Returns only complete characters in a Buffer
|
|
158157
|
+
StringDecoder.prototype.text = utf8Text;
|
|
158158
|
+
|
|
158159
|
+
// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
|
|
158160
|
+
StringDecoder.prototype.fillLast = function (buf) {
|
|
158161
|
+
if (this.lastNeed <= buf.length) {
|
|
158162
|
+
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
|
|
158163
|
+
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
|
158164
|
+
}
|
|
158165
|
+
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
|
|
158166
|
+
this.lastNeed -= buf.length;
|
|
158167
|
+
};
|
|
158168
|
+
|
|
158169
|
+
// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
|
|
158170
|
+
// continuation byte. If an invalid byte is detected, -2 is returned.
|
|
158171
|
+
function utf8CheckByte(byte) {
|
|
158172
|
+
if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
|
|
158173
|
+
return byte >> 6 === 0x02 ? -1 : -2;
|
|
158174
|
+
}
|
|
158175
|
+
|
|
158176
|
+
// Checks at most 3 bytes at the end of a Buffer in order to detect an
|
|
158177
|
+
// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
|
|
158178
|
+
// needed to complete the UTF-8 character (if applicable) are returned.
|
|
158179
|
+
function utf8CheckIncomplete(self, buf, i) {
|
|
158180
|
+
var j = buf.length - 1;
|
|
158181
|
+
if (j < i) return 0;
|
|
158182
|
+
var nb = utf8CheckByte(buf[j]);
|
|
158183
|
+
if (nb >= 0) {
|
|
158184
|
+
if (nb > 0) self.lastNeed = nb - 1;
|
|
158185
|
+
return nb;
|
|
158186
|
+
}
|
|
158187
|
+
if (--j < i || nb === -2) return 0;
|
|
158188
|
+
nb = utf8CheckByte(buf[j]);
|
|
158189
|
+
if (nb >= 0) {
|
|
158190
|
+
if (nb > 0) self.lastNeed = nb - 2;
|
|
158191
|
+
return nb;
|
|
158192
|
+
}
|
|
158193
|
+
if (--j < i || nb === -2) return 0;
|
|
158194
|
+
nb = utf8CheckByte(buf[j]);
|
|
158195
|
+
if (nb >= 0) {
|
|
158196
|
+
if (nb > 0) {
|
|
158197
|
+
if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
|
|
158198
|
+
}
|
|
158199
|
+
return nb;
|
|
158200
|
+
}
|
|
158201
|
+
return 0;
|
|
158202
|
+
}
|
|
158203
|
+
|
|
158204
|
+
// Validates as many continuation bytes for a multi-byte UTF-8 character as
|
|
158205
|
+
// needed or are available. If we see a non-continuation byte where we expect
|
|
158206
|
+
// one, we "replace" the validated continuation bytes we've seen so far with
|
|
158207
|
+
// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
|
|
158208
|
+
// behavior. The continuation byte check is included three times in the case
|
|
158209
|
+
// where all of the continuation bytes for a character exist in the same buffer.
|
|
158210
|
+
// It is also done this way as a slight performance increase instead of using a
|
|
158211
|
+
// loop.
|
|
158212
|
+
function utf8CheckExtraBytes(self, buf, p) {
|
|
158213
|
+
if ((buf[0] & 0xC0) !== 0x80) {
|
|
158214
|
+
self.lastNeed = 0;
|
|
158215
|
+
return '\ufffd';
|
|
158216
|
+
}
|
|
158217
|
+
if (self.lastNeed > 1 && buf.length > 1) {
|
|
158218
|
+
if ((buf[1] & 0xC0) !== 0x80) {
|
|
158219
|
+
self.lastNeed = 1;
|
|
158220
|
+
return '\ufffd';
|
|
158221
|
+
}
|
|
158222
|
+
if (self.lastNeed > 2 && buf.length > 2) {
|
|
158223
|
+
if ((buf[2] & 0xC0) !== 0x80) {
|
|
158224
|
+
self.lastNeed = 2;
|
|
158225
|
+
return '\ufffd';
|
|
158226
|
+
}
|
|
158227
|
+
}
|
|
158228
|
+
}
|
|
158229
|
+
}
|
|
158230
|
+
|
|
158231
|
+
// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
|
|
158232
|
+
function utf8FillLast(buf) {
|
|
158233
|
+
var p = this.lastTotal - this.lastNeed;
|
|
158234
|
+
var r = utf8CheckExtraBytes(this, buf);
|
|
158235
|
+
if (r !== undefined) return r;
|
|
158236
|
+
if (this.lastNeed <= buf.length) {
|
|
158237
|
+
buf.copy(this.lastChar, p, 0, this.lastNeed);
|
|
158238
|
+
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
|
158239
|
+
}
|
|
158240
|
+
buf.copy(this.lastChar, p, 0, buf.length);
|
|
158241
|
+
this.lastNeed -= buf.length;
|
|
158242
|
+
}
|
|
158243
|
+
|
|
158244
|
+
// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
|
|
158245
|
+
// partial character, the character's bytes are buffered until the required
|
|
158246
|
+
// number of bytes are available.
|
|
158247
|
+
function utf8Text(buf, i) {
|
|
158248
|
+
var total = utf8CheckIncomplete(this, buf, i);
|
|
158249
|
+
if (!this.lastNeed) return buf.toString('utf8', i);
|
|
158250
|
+
this.lastTotal = total;
|
|
158251
|
+
var end = buf.length - (total - this.lastNeed);
|
|
158252
|
+
buf.copy(this.lastChar, 0, end);
|
|
158253
|
+
return buf.toString('utf8', i, end);
|
|
158254
|
+
}
|
|
158255
|
+
|
|
158256
|
+
// For UTF-8, a replacement character is added when ending on a partial
|
|
158257
|
+
// character.
|
|
158258
|
+
function utf8End(buf) {
|
|
158259
|
+
var r = buf && buf.length ? this.write(buf) : '';
|
|
158260
|
+
if (this.lastNeed) return r + '\ufffd';
|
|
158261
|
+
return r;
|
|
158262
|
+
}
|
|
158263
|
+
|
|
158264
|
+
// UTF-16LE typically needs two bytes per character, but even if we have an even
|
|
158265
|
+
// number of bytes available, we need to check if we end on a leading/high
|
|
158266
|
+
// surrogate. In that case, we need to wait for the next two bytes in order to
|
|
158267
|
+
// decode the last character properly.
|
|
158268
|
+
function utf16Text(buf, i) {
|
|
158269
|
+
if ((buf.length - i) % 2 === 0) {
|
|
158270
|
+
var r = buf.toString('utf16le', i);
|
|
158271
|
+
if (r) {
|
|
158272
|
+
var c = r.charCodeAt(r.length - 1);
|
|
158273
|
+
if (c >= 0xD800 && c <= 0xDBFF) {
|
|
158274
|
+
this.lastNeed = 2;
|
|
158275
|
+
this.lastTotal = 4;
|
|
158276
|
+
this.lastChar[0] = buf[buf.length - 2];
|
|
158277
|
+
this.lastChar[1] = buf[buf.length - 1];
|
|
158278
|
+
return r.slice(0, -1);
|
|
158279
|
+
}
|
|
158280
|
+
}
|
|
158281
|
+
return r;
|
|
158282
|
+
}
|
|
158283
|
+
this.lastNeed = 1;
|
|
158284
|
+
this.lastTotal = 2;
|
|
158285
|
+
this.lastChar[0] = buf[buf.length - 1];
|
|
158286
|
+
return buf.toString('utf16le', i, buf.length - 1);
|
|
158287
|
+
}
|
|
158288
|
+
|
|
158289
|
+
// For UTF-16LE we do not explicitly append special replacement characters if we
|
|
158290
|
+
// end on a partial character, we simply let v8 handle that.
|
|
158291
|
+
function utf16End(buf) {
|
|
158292
|
+
var r = buf && buf.length ? this.write(buf) : '';
|
|
158293
|
+
if (this.lastNeed) {
|
|
158294
|
+
var end = this.lastTotal - this.lastNeed;
|
|
158295
|
+
return r + this.lastChar.toString('utf16le', 0, end);
|
|
158296
|
+
}
|
|
158297
|
+
return r;
|
|
158298
|
+
}
|
|
158299
|
+
|
|
158300
|
+
function base64Text(buf, i) {
|
|
158301
|
+
var n = (buf.length - i) % 3;
|
|
158302
|
+
if (n === 0) return buf.toString('base64', i);
|
|
158303
|
+
this.lastNeed = 3 - n;
|
|
158304
|
+
this.lastTotal = 3;
|
|
158305
|
+
if (n === 1) {
|
|
158306
|
+
this.lastChar[0] = buf[buf.length - 1];
|
|
158307
|
+
} else {
|
|
158308
|
+
this.lastChar[0] = buf[buf.length - 2];
|
|
158309
|
+
this.lastChar[1] = buf[buf.length - 1];
|
|
158310
|
+
}
|
|
158311
|
+
return buf.toString('base64', i, buf.length - n);
|
|
158312
|
+
}
|
|
158313
|
+
|
|
158314
|
+
function base64End(buf) {
|
|
158315
|
+
var r = buf && buf.length ? this.write(buf) : '';
|
|
158316
|
+
if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
|
|
158317
|
+
return r;
|
|
158318
|
+
}
|
|
158319
|
+
|
|
158320
|
+
// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
|
|
158321
|
+
function simpleWrite(buf) {
|
|
158322
|
+
return buf.toString(this.encoding);
|
|
158323
|
+
}
|
|
158324
|
+
|
|
158325
|
+
function simpleEnd(buf) {
|
|
158326
|
+
return buf && buf.length ? this.write(buf) : '';
|
|
158327
|
+
}
|
|
158328
|
+
return string_decoder;
|
|
158329
|
+
}
|
|
158330
|
+
|
|
158331
|
+
var endOfStream;
|
|
158332
|
+
var hasRequiredEndOfStream;
|
|
158333
|
+
|
|
158334
|
+
function requireEndOfStream () {
|
|
158335
|
+
if (hasRequiredEndOfStream) return endOfStream;
|
|
158336
|
+
hasRequiredEndOfStream = 1;
|
|
158337
|
+
|
|
158338
|
+
var ERR_STREAM_PREMATURE_CLOSE = requireErrors().codes.ERR_STREAM_PREMATURE_CLOSE;
|
|
158339
|
+
function once(callback) {
|
|
158340
|
+
var called = false;
|
|
158341
|
+
return function () {
|
|
158342
|
+
if (called) return;
|
|
158343
|
+
called = true;
|
|
158344
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
158345
|
+
args[_key] = arguments[_key];
|
|
158346
|
+
}
|
|
158347
|
+
callback.apply(this, args);
|
|
158348
|
+
};
|
|
158349
|
+
}
|
|
158350
|
+
function noop() {}
|
|
158351
|
+
function isRequest(stream) {
|
|
158352
|
+
return stream.setHeader && typeof stream.abort === 'function';
|
|
158353
|
+
}
|
|
158354
|
+
function eos(stream, opts, callback) {
|
|
158355
|
+
if (typeof opts === 'function') return eos(stream, null, opts);
|
|
158356
|
+
if (!opts) opts = {};
|
|
158357
|
+
callback = once(callback || noop);
|
|
158358
|
+
var readable = opts.readable || opts.readable !== false && stream.readable;
|
|
158359
|
+
var writable = opts.writable || opts.writable !== false && stream.writable;
|
|
158360
|
+
var onlegacyfinish = function onlegacyfinish() {
|
|
158361
|
+
if (!stream.writable) onfinish();
|
|
158362
|
+
};
|
|
158363
|
+
var writableEnded = stream._writableState && stream._writableState.finished;
|
|
158364
|
+
var onfinish = function onfinish() {
|
|
158365
|
+
writable = false;
|
|
158366
|
+
writableEnded = true;
|
|
158367
|
+
if (!readable) callback.call(stream);
|
|
158368
|
+
};
|
|
158369
|
+
var readableEnded = stream._readableState && stream._readableState.endEmitted;
|
|
158370
|
+
var onend = function onend() {
|
|
158371
|
+
readable = false;
|
|
158372
|
+
readableEnded = true;
|
|
158373
|
+
if (!writable) callback.call(stream);
|
|
158374
|
+
};
|
|
158375
|
+
var onerror = function onerror(err) {
|
|
158376
|
+
callback.call(stream, err);
|
|
158377
|
+
};
|
|
158378
|
+
var onclose = function onclose() {
|
|
158379
|
+
var err;
|
|
158380
|
+
if (readable && !readableEnded) {
|
|
158381
|
+
if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
|
|
158382
|
+
return callback.call(stream, err);
|
|
158383
|
+
}
|
|
158384
|
+
if (writable && !writableEnded) {
|
|
158385
|
+
if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
|
|
158386
|
+
return callback.call(stream, err);
|
|
158387
|
+
}
|
|
158388
|
+
};
|
|
158389
|
+
var onrequest = function onrequest() {
|
|
158390
|
+
stream.req.on('finish', onfinish);
|
|
158391
|
+
};
|
|
158392
|
+
if (isRequest(stream)) {
|
|
158393
|
+
stream.on('complete', onfinish);
|
|
158394
|
+
stream.on('abort', onclose);
|
|
158395
|
+
if (stream.req) onrequest();else stream.on('request', onrequest);
|
|
158396
|
+
} else if (writable && !stream._writableState) {
|
|
158397
|
+
// legacy streams
|
|
158398
|
+
stream.on('end', onlegacyfinish);
|
|
158399
|
+
stream.on('close', onlegacyfinish);
|
|
158400
|
+
}
|
|
158401
|
+
stream.on('end', onend);
|
|
158402
|
+
stream.on('finish', onfinish);
|
|
158403
|
+
if (opts.error !== false) stream.on('error', onerror);
|
|
158404
|
+
stream.on('close', onclose);
|
|
158405
|
+
return function () {
|
|
158406
|
+
stream.removeListener('complete', onfinish);
|
|
158407
|
+
stream.removeListener('abort', onclose);
|
|
158408
|
+
stream.removeListener('request', onrequest);
|
|
158409
|
+
if (stream.req) stream.req.removeListener('finish', onfinish);
|
|
158410
|
+
stream.removeListener('end', onlegacyfinish);
|
|
158411
|
+
stream.removeListener('close', onlegacyfinish);
|
|
158412
|
+
stream.removeListener('finish', onfinish);
|
|
158413
|
+
stream.removeListener('end', onend);
|
|
158414
|
+
stream.removeListener('error', onerror);
|
|
158415
|
+
stream.removeListener('close', onclose);
|
|
158416
|
+
};
|
|
158417
|
+
}
|
|
158418
|
+
endOfStream = eos;
|
|
158419
|
+
return endOfStream;
|
|
158420
|
+
}
|
|
158421
|
+
|
|
158422
|
+
var async_iterator;
|
|
158423
|
+
var hasRequiredAsync_iterator;
|
|
158424
|
+
|
|
158425
|
+
function requireAsync_iterator () {
|
|
158426
|
+
if (hasRequiredAsync_iterator) return async_iterator;
|
|
158427
|
+
hasRequiredAsync_iterator = 1;
|
|
158428
|
+
|
|
158429
|
+
var _Object$setPrototypeO;
|
|
158430
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
158431
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
158432
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
158433
|
+
var finished = requireEndOfStream();
|
|
158434
|
+
var kLastResolve = Symbol('lastResolve');
|
|
158435
|
+
var kLastReject = Symbol('lastReject');
|
|
158436
|
+
var kError = Symbol('error');
|
|
158437
|
+
var kEnded = Symbol('ended');
|
|
158438
|
+
var kLastPromise = Symbol('lastPromise');
|
|
158439
|
+
var kHandlePromise = Symbol('handlePromise');
|
|
158440
|
+
var kStream = Symbol('stream');
|
|
158441
|
+
function createIterResult(value, done) {
|
|
158442
|
+
return {
|
|
158443
|
+
value: value,
|
|
158444
|
+
done: done
|
|
158445
|
+
};
|
|
158446
|
+
}
|
|
158447
|
+
function readAndResolve(iter) {
|
|
158448
|
+
var resolve = iter[kLastResolve];
|
|
158449
|
+
if (resolve !== null) {
|
|
158450
|
+
var data = iter[kStream].read();
|
|
158451
|
+
// we defer if data is null
|
|
158452
|
+
// we can be expecting either 'end' or
|
|
158453
|
+
// 'error'
|
|
158454
|
+
if (data !== null) {
|
|
158455
|
+
iter[kLastPromise] = null;
|
|
158456
|
+
iter[kLastResolve] = null;
|
|
158457
|
+
iter[kLastReject] = null;
|
|
158458
|
+
resolve(createIterResult(data, false));
|
|
158459
|
+
}
|
|
158460
|
+
}
|
|
158461
|
+
}
|
|
158462
|
+
function onReadable(iter) {
|
|
158463
|
+
// we wait for the next tick, because it might
|
|
158464
|
+
// emit an error with process.nextTick
|
|
158465
|
+
process.nextTick(readAndResolve, iter);
|
|
158466
|
+
}
|
|
158467
|
+
function wrapForNext(lastPromise, iter) {
|
|
158468
|
+
return function (resolve, reject) {
|
|
158469
|
+
lastPromise.then(function () {
|
|
158470
|
+
if (iter[kEnded]) {
|
|
158471
|
+
resolve(createIterResult(undefined, true));
|
|
158472
|
+
return;
|
|
158473
|
+
}
|
|
158474
|
+
iter[kHandlePromise](resolve, reject);
|
|
158475
|
+
}, reject);
|
|
158476
|
+
};
|
|
158477
|
+
}
|
|
158478
|
+
var AsyncIteratorPrototype = Object.getPrototypeOf(function () {});
|
|
158479
|
+
var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {
|
|
158480
|
+
get stream() {
|
|
158481
|
+
return this[kStream];
|
|
158482
|
+
},
|
|
158483
|
+
next: function next() {
|
|
158484
|
+
var _this = this;
|
|
158485
|
+
// if we have detected an error in the meanwhile
|
|
158486
|
+
// reject straight away
|
|
158487
|
+
var error = this[kError];
|
|
158488
|
+
if (error !== null) {
|
|
158489
|
+
return Promise.reject(error);
|
|
158490
|
+
}
|
|
158491
|
+
if (this[kEnded]) {
|
|
158492
|
+
return Promise.resolve(createIterResult(undefined, true));
|
|
158493
|
+
}
|
|
158494
|
+
if (this[kStream].destroyed) {
|
|
158495
|
+
// We need to defer via nextTick because if .destroy(err) is
|
|
158496
|
+
// called, the error will be emitted via nextTick, and
|
|
158497
|
+
// we cannot guarantee that there is no error lingering around
|
|
158498
|
+
// waiting to be emitted.
|
|
158499
|
+
return new Promise(function (resolve, reject) {
|
|
158500
|
+
process.nextTick(function () {
|
|
158501
|
+
if (_this[kError]) {
|
|
158502
|
+
reject(_this[kError]);
|
|
158503
|
+
} else {
|
|
158504
|
+
resolve(createIterResult(undefined, true));
|
|
158505
|
+
}
|
|
158506
|
+
});
|
|
158507
|
+
});
|
|
158508
|
+
}
|
|
158509
|
+
|
|
158510
|
+
// if we have multiple next() calls
|
|
158511
|
+
// we will wait for the previous Promise to finish
|
|
158512
|
+
// this logic is optimized to support for await loops,
|
|
158513
|
+
// where next() is only called once at a time
|
|
158514
|
+
var lastPromise = this[kLastPromise];
|
|
158515
|
+
var promise;
|
|
158516
|
+
if (lastPromise) {
|
|
158517
|
+
promise = new Promise(wrapForNext(lastPromise, this));
|
|
158518
|
+
} else {
|
|
158519
|
+
// fast path needed to support multiple this.push()
|
|
158520
|
+
// without triggering the next() queue
|
|
158521
|
+
var data = this[kStream].read();
|
|
158522
|
+
if (data !== null) {
|
|
158523
|
+
return Promise.resolve(createIterResult(data, false));
|
|
158524
|
+
}
|
|
158525
|
+
promise = new Promise(this[kHandlePromise]);
|
|
158526
|
+
}
|
|
158527
|
+
this[kLastPromise] = promise;
|
|
158528
|
+
return promise;
|
|
158529
|
+
}
|
|
158530
|
+
}, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () {
|
|
158531
|
+
return this;
|
|
158532
|
+
}), _defineProperty(_Object$setPrototypeO, "return", function _return() {
|
|
158533
|
+
var _this2 = this;
|
|
158534
|
+
// destroy(err, cb) is a private API
|
|
158535
|
+
// we can guarantee we have that here, because we control the
|
|
158536
|
+
// Readable class this is attached to
|
|
158537
|
+
return new Promise(function (resolve, reject) {
|
|
158538
|
+
_this2[kStream].destroy(null, function (err) {
|
|
158539
|
+
if (err) {
|
|
158540
|
+
reject(err);
|
|
158541
|
+
return;
|
|
158542
|
+
}
|
|
158543
|
+
resolve(createIterResult(undefined, true));
|
|
158544
|
+
});
|
|
158545
|
+
});
|
|
158546
|
+
}), _Object$setPrototypeO), AsyncIteratorPrototype);
|
|
158547
|
+
var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {
|
|
158548
|
+
var _Object$create;
|
|
158549
|
+
var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
|
|
158550
|
+
value: stream,
|
|
158551
|
+
writable: true
|
|
158552
|
+
}), _defineProperty(_Object$create, kLastResolve, {
|
|
158553
|
+
value: null,
|
|
158554
|
+
writable: true
|
|
158555
|
+
}), _defineProperty(_Object$create, kLastReject, {
|
|
158556
|
+
value: null,
|
|
158557
|
+
writable: true
|
|
158558
|
+
}), _defineProperty(_Object$create, kError, {
|
|
158559
|
+
value: null,
|
|
158560
|
+
writable: true
|
|
158561
|
+
}), _defineProperty(_Object$create, kEnded, {
|
|
158562
|
+
value: stream._readableState.endEmitted,
|
|
158563
|
+
writable: true
|
|
158564
|
+
}), _defineProperty(_Object$create, kHandlePromise, {
|
|
158565
|
+
value: function value(resolve, reject) {
|
|
158566
|
+
var data = iterator[kStream].read();
|
|
158567
|
+
if (data) {
|
|
158568
|
+
iterator[kLastPromise] = null;
|
|
158569
|
+
iterator[kLastResolve] = null;
|
|
158570
|
+
iterator[kLastReject] = null;
|
|
158571
|
+
resolve(createIterResult(data, false));
|
|
158572
|
+
} else {
|
|
158573
|
+
iterator[kLastResolve] = resolve;
|
|
158574
|
+
iterator[kLastReject] = reject;
|
|
158575
|
+
}
|
|
158576
|
+
},
|
|
158577
|
+
writable: true
|
|
158578
|
+
}), _Object$create));
|
|
158579
|
+
iterator[kLastPromise] = null;
|
|
158580
|
+
finished(stream, function (err) {
|
|
158581
|
+
if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
|
|
158582
|
+
var reject = iterator[kLastReject];
|
|
158583
|
+
// reject if we are waiting for data in the Promise
|
|
158584
|
+
// returned by next() and store the error
|
|
158585
|
+
if (reject !== null) {
|
|
158586
|
+
iterator[kLastPromise] = null;
|
|
158587
|
+
iterator[kLastResolve] = null;
|
|
158588
|
+
iterator[kLastReject] = null;
|
|
158589
|
+
reject(err);
|
|
158590
|
+
}
|
|
158591
|
+
iterator[kError] = err;
|
|
158592
|
+
return;
|
|
158593
|
+
}
|
|
158594
|
+
var resolve = iterator[kLastResolve];
|
|
158595
|
+
if (resolve !== null) {
|
|
158596
|
+
iterator[kLastPromise] = null;
|
|
158597
|
+
iterator[kLastResolve] = null;
|
|
158598
|
+
iterator[kLastReject] = null;
|
|
158599
|
+
resolve(createIterResult(undefined, true));
|
|
158600
|
+
}
|
|
158601
|
+
iterator[kEnded] = true;
|
|
158602
|
+
});
|
|
158603
|
+
stream.on('readable', onReadable.bind(null, iterator));
|
|
158604
|
+
return iterator;
|
|
158605
|
+
};
|
|
158606
|
+
async_iterator = createReadableStreamAsyncIterator;
|
|
158607
|
+
return async_iterator;
|
|
158608
|
+
}
|
|
158609
|
+
|
|
158610
|
+
var from_1;
|
|
158611
|
+
var hasRequiredFrom;
|
|
158612
|
+
|
|
158613
|
+
function requireFrom () {
|
|
158614
|
+
if (hasRequiredFrom) return from_1;
|
|
158615
|
+
hasRequiredFrom = 1;
|
|
158616
|
+
|
|
158617
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
158618
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
158619
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
158620
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
158621
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
158622
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
158623
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
158624
|
+
var ERR_INVALID_ARG_TYPE = requireErrors().codes.ERR_INVALID_ARG_TYPE;
|
|
158625
|
+
function from(Readable, iterable, opts) {
|
|
158626
|
+
var iterator;
|
|
158627
|
+
if (iterable && typeof iterable.next === 'function') {
|
|
158628
|
+
iterator = iterable;
|
|
158629
|
+
} else if (iterable && iterable[Symbol.asyncIterator]) iterator = iterable[Symbol.asyncIterator]();else if (iterable && iterable[Symbol.iterator]) iterator = iterable[Symbol.iterator]();else throw new ERR_INVALID_ARG_TYPE('iterable', ['Iterable'], iterable);
|
|
158630
|
+
var readable = new Readable(_objectSpread({
|
|
158631
|
+
objectMode: true
|
|
158632
|
+
}, opts));
|
|
158633
|
+
// Reading boolean to protect against _read
|
|
158634
|
+
// being called before last iteration completion.
|
|
158635
|
+
var reading = false;
|
|
158636
|
+
readable._read = function () {
|
|
158637
|
+
if (!reading) {
|
|
158638
|
+
reading = true;
|
|
158639
|
+
next();
|
|
158640
|
+
}
|
|
158641
|
+
};
|
|
158642
|
+
function next() {
|
|
158643
|
+
return _next2.apply(this, arguments);
|
|
158644
|
+
}
|
|
158645
|
+
function _next2() {
|
|
158646
|
+
_next2 = _asyncToGenerator(function* () {
|
|
158647
|
+
try {
|
|
158648
|
+
var _yield$iterator$next = yield iterator.next(),
|
|
158649
|
+
value = _yield$iterator$next.value,
|
|
158650
|
+
done = _yield$iterator$next.done;
|
|
158651
|
+
if (done) {
|
|
158652
|
+
readable.push(null);
|
|
158653
|
+
} else if (readable.push(yield value)) {
|
|
158654
|
+
next();
|
|
158655
|
+
} else {
|
|
158656
|
+
reading = false;
|
|
158657
|
+
}
|
|
158658
|
+
} catch (err) {
|
|
158659
|
+
readable.destroy(err);
|
|
158660
|
+
}
|
|
158661
|
+
});
|
|
158662
|
+
return _next2.apply(this, arguments);
|
|
158663
|
+
}
|
|
158664
|
+
return readable;
|
|
158665
|
+
}
|
|
158666
|
+
from_1 = from;
|
|
158667
|
+
return from_1;
|
|
158668
|
+
}
|
|
158669
|
+
|
|
158670
|
+
var _stream_readable;
|
|
158671
|
+
var hasRequired_stream_readable;
|
|
158672
|
+
|
|
158673
|
+
function require_stream_readable () {
|
|
158674
|
+
if (hasRequired_stream_readable) return _stream_readable;
|
|
158675
|
+
hasRequired_stream_readable = 1;
|
|
158676
|
+
|
|
158677
|
+
_stream_readable = Readable;
|
|
158678
|
+
|
|
158679
|
+
/*<replacement>*/
|
|
158680
|
+
var Duplex;
|
|
158681
|
+
/*</replacement>*/
|
|
158682
|
+
|
|
158683
|
+
Readable.ReadableState = ReadableState;
|
|
158684
|
+
|
|
158685
|
+
/*<replacement>*/
|
|
158686
|
+
require$$0$4.EventEmitter;
|
|
158687
|
+
var EElistenerCount = function EElistenerCount(emitter, type) {
|
|
158688
|
+
return emitter.listeners(type).length;
|
|
158689
|
+
};
|
|
158690
|
+
/*</replacement>*/
|
|
158691
|
+
|
|
158692
|
+
/*<replacement>*/
|
|
158693
|
+
var Stream = requireStream();
|
|
158694
|
+
/*</replacement>*/
|
|
158695
|
+
|
|
158696
|
+
var Buffer = require$$2$4.Buffer;
|
|
158697
|
+
var OurUint8Array = (typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
|
|
158698
|
+
function _uint8ArrayToBuffer(chunk) {
|
|
158699
|
+
return Buffer.from(chunk);
|
|
158700
|
+
}
|
|
158701
|
+
function _isUint8Array(obj) {
|
|
158702
|
+
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
158703
|
+
}
|
|
158704
|
+
|
|
158705
|
+
/*<replacement>*/
|
|
158706
|
+
var debugUtil = require$$0$5;
|
|
158707
|
+
var debug;
|
|
158708
|
+
if (debugUtil && debugUtil.debuglog) {
|
|
158709
|
+
debug = debugUtil.debuglog('stream');
|
|
158710
|
+
} else {
|
|
158711
|
+
debug = function debug() {};
|
|
158712
|
+
}
|
|
158713
|
+
/*</replacement>*/
|
|
158714
|
+
|
|
158715
|
+
var BufferList = requireBuffer_list();
|
|
158716
|
+
var destroyImpl = requireDestroy();
|
|
158717
|
+
var _require = requireState(),
|
|
158718
|
+
getHighWaterMark = _require.getHighWaterMark;
|
|
158719
|
+
var _require$codes = requireErrors().codes,
|
|
158720
|
+
ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
|
|
158721
|
+
ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF,
|
|
158722
|
+
ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
|
|
158723
|
+
ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;
|
|
158724
|
+
|
|
158725
|
+
// Lazy loaded to improve the startup performance.
|
|
158726
|
+
var StringDecoder;
|
|
158727
|
+
var createReadableStreamAsyncIterator;
|
|
158728
|
+
var from;
|
|
158729
|
+
inheritsExports(Readable, Stream);
|
|
158730
|
+
var errorOrDestroy = destroyImpl.errorOrDestroy;
|
|
158731
|
+
var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
|
|
158732
|
+
function prependListener(emitter, event, fn) {
|
|
158733
|
+
// Sadly this is not cacheable as some libraries bundle their own
|
|
158734
|
+
// event emitter implementation with them.
|
|
158735
|
+
if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
|
|
158736
|
+
|
|
158737
|
+
// This is a hack to make sure that our error handler is attached before any
|
|
158738
|
+
// userland ones. NEVER DO THIS. This is here only because this code needs
|
|
158739
|
+
// to continue to work with older versions of Node.js that do not include
|
|
158740
|
+
// the prependListener() method. The goal is to eventually remove this hack.
|
|
158741
|
+
if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
|
|
158742
|
+
}
|
|
158743
|
+
function ReadableState(options, stream, isDuplex) {
|
|
158744
|
+
Duplex = Duplex || require_stream_duplex();
|
|
158745
|
+
options = options || {};
|
|
158746
|
+
|
|
158747
|
+
// Duplex streams are both readable and writable, but share
|
|
158748
|
+
// the same options object.
|
|
158749
|
+
// However, some cases require setting options to different
|
|
158750
|
+
// values for the readable and the writable sides of the duplex stream.
|
|
158751
|
+
// These options can be provided separately as readableXXX and writableXXX.
|
|
158752
|
+
if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex;
|
|
158753
|
+
|
|
158754
|
+
// object stream flag. Used to make read(n) ignore n and to
|
|
158755
|
+
// make all the buffer merging and length checks go away
|
|
158756
|
+
this.objectMode = !!options.objectMode;
|
|
158757
|
+
if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
|
|
158758
|
+
|
|
158759
|
+
// the point at which it stops calling _read() to fill the buffer
|
|
158760
|
+
// Note: 0 is a valid value, means "don't call _read preemptively ever"
|
|
158761
|
+
this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex);
|
|
158762
|
+
|
|
158763
|
+
// A linked list is used to store data chunks instead of an array because the
|
|
158764
|
+
// linked list can remove elements from the beginning faster than
|
|
158765
|
+
// array.shift()
|
|
158766
|
+
this.buffer = new BufferList();
|
|
158767
|
+
this.length = 0;
|
|
158768
|
+
this.pipes = null;
|
|
158769
|
+
this.pipesCount = 0;
|
|
158770
|
+
this.flowing = null;
|
|
158771
|
+
this.ended = false;
|
|
158772
|
+
this.endEmitted = false;
|
|
158773
|
+
this.reading = false;
|
|
158774
|
+
|
|
158775
|
+
// a flag to be able to tell if the event 'readable'/'data' is emitted
|
|
158776
|
+
// immediately, or on a later tick. We set this to true at first, because
|
|
158777
|
+
// any actions that shouldn't happen until "later" should generally also
|
|
158778
|
+
// not happen before the first read call.
|
|
158779
|
+
this.sync = true;
|
|
158780
|
+
|
|
158781
|
+
// whenever we return null, then we set a flag to say
|
|
158782
|
+
// that we're awaiting a 'readable' event emission.
|
|
158783
|
+
this.needReadable = false;
|
|
158784
|
+
this.emittedReadable = false;
|
|
158785
|
+
this.readableListening = false;
|
|
158786
|
+
this.resumeScheduled = false;
|
|
158787
|
+
this.paused = true;
|
|
158788
|
+
|
|
158789
|
+
// Should close be emitted on destroy. Defaults to true.
|
|
158790
|
+
this.emitClose = options.emitClose !== false;
|
|
158791
|
+
|
|
158792
|
+
// Should .destroy() be called after 'end' (and potentially 'finish')
|
|
158793
|
+
this.autoDestroy = !!options.autoDestroy;
|
|
158794
|
+
|
|
158795
|
+
// has it been destroyed
|
|
158796
|
+
this.destroyed = false;
|
|
158797
|
+
|
|
158798
|
+
// Crypto is kind of old and crusty. Historically, its default string
|
|
158799
|
+
// encoding is 'binary' so we have to make this configurable.
|
|
158800
|
+
// Everything else in the universe uses 'utf8', though.
|
|
158801
|
+
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
|
158802
|
+
|
|
158803
|
+
// the number of writers that are awaiting a drain event in .pipe()s
|
|
158804
|
+
this.awaitDrain = 0;
|
|
158805
|
+
|
|
158806
|
+
// if true, a maybeReadMore has been scheduled
|
|
158807
|
+
this.readingMore = false;
|
|
158808
|
+
this.decoder = null;
|
|
158809
|
+
this.encoding = null;
|
|
158810
|
+
if (options.encoding) {
|
|
158811
|
+
if (!StringDecoder) StringDecoder = requireString_decoder().StringDecoder;
|
|
158812
|
+
this.decoder = new StringDecoder(options.encoding);
|
|
158813
|
+
this.encoding = options.encoding;
|
|
158814
|
+
}
|
|
158815
|
+
}
|
|
158816
|
+
function Readable(options) {
|
|
158817
|
+
Duplex = Duplex || require_stream_duplex();
|
|
158818
|
+
if (!(this instanceof Readable)) return new Readable(options);
|
|
158819
|
+
|
|
158820
|
+
// Checking for a Stream.Duplex instance is faster here instead of inside
|
|
158821
|
+
// the ReadableState constructor, at least with V8 6.5
|
|
158822
|
+
var isDuplex = this instanceof Duplex;
|
|
158823
|
+
this._readableState = new ReadableState(options, this, isDuplex);
|
|
158824
|
+
|
|
158825
|
+
// legacy
|
|
158826
|
+
this.readable = true;
|
|
158827
|
+
if (options) {
|
|
158828
|
+
if (typeof options.read === 'function') this._read = options.read;
|
|
158829
|
+
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
|
158830
|
+
}
|
|
158831
|
+
Stream.call(this);
|
|
158832
|
+
}
|
|
158833
|
+
Object.defineProperty(Readable.prototype, 'destroyed', {
|
|
158834
|
+
// making it explicit this property is not enumerable
|
|
158835
|
+
// because otherwise some prototype manipulation in
|
|
158836
|
+
// userland will fail
|
|
158837
|
+
enumerable: false,
|
|
158838
|
+
get: function get() {
|
|
158839
|
+
if (this._readableState === undefined) {
|
|
158840
|
+
return false;
|
|
158841
|
+
}
|
|
158842
|
+
return this._readableState.destroyed;
|
|
158843
|
+
},
|
|
158844
|
+
set: function set(value) {
|
|
158845
|
+
// we ignore the value if the stream
|
|
158846
|
+
// has not been initialized yet
|
|
158847
|
+
if (!this._readableState) {
|
|
158848
|
+
return;
|
|
158849
|
+
}
|
|
158850
|
+
|
|
158851
|
+
// backward compatibility, the user is explicitly
|
|
158852
|
+
// managing destroyed
|
|
158853
|
+
this._readableState.destroyed = value;
|
|
158854
|
+
}
|
|
158855
|
+
});
|
|
158856
|
+
Readable.prototype.destroy = destroyImpl.destroy;
|
|
158857
|
+
Readable.prototype._undestroy = destroyImpl.undestroy;
|
|
158858
|
+
Readable.prototype._destroy = function (err, cb) {
|
|
158859
|
+
cb(err);
|
|
158860
|
+
};
|
|
158861
|
+
|
|
158862
|
+
// Manually shove something into the read() buffer.
|
|
158863
|
+
// This returns true if the highWaterMark has not been hit yet,
|
|
158864
|
+
// similar to how Writable.write() returns true if you should
|
|
158865
|
+
// write() some more.
|
|
158866
|
+
Readable.prototype.push = function (chunk, encoding) {
|
|
158867
|
+
var state = this._readableState;
|
|
158868
|
+
var skipChunkCheck;
|
|
158869
|
+
if (!state.objectMode) {
|
|
158870
|
+
if (typeof chunk === 'string') {
|
|
158871
|
+
encoding = encoding || state.defaultEncoding;
|
|
158872
|
+
if (encoding !== state.encoding) {
|
|
158873
|
+
chunk = Buffer.from(chunk, encoding);
|
|
158874
|
+
encoding = '';
|
|
158875
|
+
}
|
|
158876
|
+
skipChunkCheck = true;
|
|
158877
|
+
}
|
|
158878
|
+
} else {
|
|
158879
|
+
skipChunkCheck = true;
|
|
158880
|
+
}
|
|
158881
|
+
return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
|
|
158882
|
+
};
|
|
158883
|
+
|
|
158884
|
+
// Unshift should *always* be something directly out of read()
|
|
158885
|
+
Readable.prototype.unshift = function (chunk) {
|
|
158886
|
+
return readableAddChunk(this, chunk, null, true, false);
|
|
158887
|
+
};
|
|
158888
|
+
function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
|
|
158889
|
+
debug('readableAddChunk', chunk);
|
|
158890
|
+
var state = stream._readableState;
|
|
158891
|
+
if (chunk === null) {
|
|
158892
|
+
state.reading = false;
|
|
158893
|
+
onEofChunk(stream, state);
|
|
158894
|
+
} else {
|
|
158895
|
+
var er;
|
|
158896
|
+
if (!skipChunkCheck) er = chunkInvalid(state, chunk);
|
|
158897
|
+
if (er) {
|
|
158898
|
+
errorOrDestroy(stream, er);
|
|
158899
|
+
} else if (state.objectMode || chunk && chunk.length > 0) {
|
|
158900
|
+
if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
|
|
158901
|
+
chunk = _uint8ArrayToBuffer(chunk);
|
|
158902
|
+
}
|
|
158903
|
+
if (addToFront) {
|
|
158904
|
+
if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true);
|
|
158905
|
+
} else if (state.ended) {
|
|
158906
|
+
errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());
|
|
158907
|
+
} else if (state.destroyed) {
|
|
158908
|
+
return false;
|
|
158909
|
+
} else {
|
|
158910
|
+
state.reading = false;
|
|
158911
|
+
if (state.decoder && !encoding) {
|
|
158912
|
+
chunk = state.decoder.write(chunk);
|
|
158913
|
+
if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
|
|
158914
|
+
} else {
|
|
158915
|
+
addChunk(stream, state, chunk, false);
|
|
158916
|
+
}
|
|
158917
|
+
}
|
|
158918
|
+
} else if (!addToFront) {
|
|
158919
|
+
state.reading = false;
|
|
158920
|
+
maybeReadMore(stream, state);
|
|
158921
|
+
}
|
|
158922
|
+
}
|
|
158923
|
+
|
|
158924
|
+
// We can push more data if we are below the highWaterMark.
|
|
158925
|
+
// Also, if we have no data yet, we can stand some more bytes.
|
|
158926
|
+
// This is to work around cases where hwm=0, such as the repl.
|
|
158927
|
+
return !state.ended && (state.length < state.highWaterMark || state.length === 0);
|
|
158928
|
+
}
|
|
158929
|
+
function addChunk(stream, state, chunk, addToFront) {
|
|
158930
|
+
if (state.flowing && state.length === 0 && !state.sync) {
|
|
158931
|
+
state.awaitDrain = 0;
|
|
158932
|
+
stream.emit('data', chunk);
|
|
158933
|
+
} else {
|
|
158934
|
+
// update the buffer info.
|
|
158935
|
+
state.length += state.objectMode ? 1 : chunk.length;
|
|
158936
|
+
if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
|
|
158937
|
+
if (state.needReadable) emitReadable(stream);
|
|
158938
|
+
}
|
|
158939
|
+
maybeReadMore(stream, state);
|
|
158940
|
+
}
|
|
158941
|
+
function chunkInvalid(state, chunk) {
|
|
158942
|
+
var er;
|
|
158943
|
+
if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
|
|
158944
|
+
er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk);
|
|
158945
|
+
}
|
|
158946
|
+
return er;
|
|
158947
|
+
}
|
|
158948
|
+
Readable.prototype.isPaused = function () {
|
|
158949
|
+
return this._readableState.flowing === false;
|
|
158950
|
+
};
|
|
158951
|
+
|
|
158952
|
+
// backwards compatibility.
|
|
158953
|
+
Readable.prototype.setEncoding = function (enc) {
|
|
158954
|
+
if (!StringDecoder) StringDecoder = requireString_decoder().StringDecoder;
|
|
158955
|
+
var decoder = new StringDecoder(enc);
|
|
158956
|
+
this._readableState.decoder = decoder;
|
|
158957
|
+
// If setEncoding(null), decoder.encoding equals utf8
|
|
158958
|
+
this._readableState.encoding = this._readableState.decoder.encoding;
|
|
158959
|
+
|
|
158960
|
+
// Iterate over current buffer to convert already stored Buffers:
|
|
158961
|
+
var p = this._readableState.buffer.head;
|
|
158962
|
+
var content = '';
|
|
158963
|
+
while (p !== null) {
|
|
158964
|
+
content += decoder.write(p.data);
|
|
158965
|
+
p = p.next;
|
|
158966
|
+
}
|
|
158967
|
+
this._readableState.buffer.clear();
|
|
158968
|
+
if (content !== '') this._readableState.buffer.push(content);
|
|
158969
|
+
this._readableState.length = content.length;
|
|
158970
|
+
return this;
|
|
158971
|
+
};
|
|
158972
|
+
|
|
158973
|
+
// Don't raise the hwm > 1GB
|
|
158974
|
+
var MAX_HWM = 0x40000000;
|
|
158975
|
+
function computeNewHighWaterMark(n) {
|
|
158976
|
+
if (n >= MAX_HWM) {
|
|
158977
|
+
// TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
|
|
158978
|
+
n = MAX_HWM;
|
|
158979
|
+
} else {
|
|
158980
|
+
// Get the next highest power of 2 to prevent increasing hwm excessively in
|
|
158981
|
+
// tiny amounts
|
|
158982
|
+
n--;
|
|
158983
|
+
n |= n >>> 1;
|
|
158984
|
+
n |= n >>> 2;
|
|
158985
|
+
n |= n >>> 4;
|
|
158986
|
+
n |= n >>> 8;
|
|
158987
|
+
n |= n >>> 16;
|
|
158988
|
+
n++;
|
|
158989
|
+
}
|
|
158990
|
+
return n;
|
|
158991
|
+
}
|
|
158992
|
+
|
|
158993
|
+
// This function is designed to be inlinable, so please take care when making
|
|
158994
|
+
// changes to the function body.
|
|
158995
|
+
function howMuchToRead(n, state) {
|
|
158996
|
+
if (n <= 0 || state.length === 0 && state.ended) return 0;
|
|
158997
|
+
if (state.objectMode) return 1;
|
|
158998
|
+
if (n !== n) {
|
|
158999
|
+
// Only flow one buffer at a time
|
|
159000
|
+
if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
|
|
159001
|
+
}
|
|
159002
|
+
// If we're asking for more than the current hwm, then raise the hwm.
|
|
159003
|
+
if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
|
|
159004
|
+
if (n <= state.length) return n;
|
|
159005
|
+
// Don't have enough
|
|
159006
|
+
if (!state.ended) {
|
|
159007
|
+
state.needReadable = true;
|
|
159008
|
+
return 0;
|
|
159009
|
+
}
|
|
159010
|
+
return state.length;
|
|
159011
|
+
}
|
|
159012
|
+
|
|
159013
|
+
// you can override either this method, or the async _read(n) below.
|
|
159014
|
+
Readable.prototype.read = function (n) {
|
|
159015
|
+
debug('read', n);
|
|
159016
|
+
n = parseInt(n, 10);
|
|
159017
|
+
var state = this._readableState;
|
|
159018
|
+
var nOrig = n;
|
|
159019
|
+
if (n !== 0) state.emittedReadable = false;
|
|
159020
|
+
|
|
159021
|
+
// if we're doing read(0) to trigger a readable event, but we
|
|
159022
|
+
// already have a bunch of data in the buffer, then just trigger
|
|
159023
|
+
// the 'readable' event and move on.
|
|
159024
|
+
if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
|
|
159025
|
+
debug('read: emitReadable', state.length, state.ended);
|
|
159026
|
+
if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
|
|
159027
|
+
return null;
|
|
159028
|
+
}
|
|
159029
|
+
n = howMuchToRead(n, state);
|
|
159030
|
+
|
|
159031
|
+
// if we've ended, and we're now clear, then finish it up.
|
|
159032
|
+
if (n === 0 && state.ended) {
|
|
159033
|
+
if (state.length === 0) endReadable(this);
|
|
159034
|
+
return null;
|
|
159035
|
+
}
|
|
159036
|
+
|
|
159037
|
+
// All the actual chunk generation logic needs to be
|
|
159038
|
+
// *below* the call to _read. The reason is that in certain
|
|
159039
|
+
// synthetic stream cases, such as passthrough streams, _read
|
|
159040
|
+
// may be a completely synchronous operation which may change
|
|
159041
|
+
// the state of the read buffer, providing enough data when
|
|
159042
|
+
// before there was *not* enough.
|
|
159043
|
+
//
|
|
159044
|
+
// So, the steps are:
|
|
159045
|
+
// 1. Figure out what the state of things will be after we do
|
|
159046
|
+
// a read from the buffer.
|
|
159047
|
+
//
|
|
159048
|
+
// 2. If that resulting state will trigger a _read, then call _read.
|
|
159049
|
+
// Note that this may be asynchronous, or synchronous. Yes, it is
|
|
159050
|
+
// deeply ugly to write APIs this way, but that still doesn't mean
|
|
159051
|
+
// that the Readable class should behave improperly, as streams are
|
|
159052
|
+
// designed to be sync/async agnostic.
|
|
159053
|
+
// Take note if the _read call is sync or async (ie, if the read call
|
|
159054
|
+
// has returned yet), so that we know whether or not it's safe to emit
|
|
159055
|
+
// 'readable' etc.
|
|
159056
|
+
//
|
|
159057
|
+
// 3. Actually pull the requested chunks out of the buffer and return.
|
|
159058
|
+
|
|
159059
|
+
// if we need a readable event, then we need to do some reading.
|
|
159060
|
+
var doRead = state.needReadable;
|
|
159061
|
+
debug('need readable', doRead);
|
|
159062
|
+
|
|
159063
|
+
// if we currently have less than the highWaterMark, then also read some
|
|
159064
|
+
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
|
159065
|
+
doRead = true;
|
|
159066
|
+
debug('length less than watermark', doRead);
|
|
159067
|
+
}
|
|
159068
|
+
|
|
159069
|
+
// however, if we've ended, then there's no point, and if we're already
|
|
159070
|
+
// reading, then it's unnecessary.
|
|
159071
|
+
if (state.ended || state.reading) {
|
|
159072
|
+
doRead = false;
|
|
159073
|
+
debug('reading or ended', doRead);
|
|
159074
|
+
} else if (doRead) {
|
|
159075
|
+
debug('do read');
|
|
159076
|
+
state.reading = true;
|
|
159077
|
+
state.sync = true;
|
|
159078
|
+
// if the length is currently zero, then we *need* a readable event.
|
|
159079
|
+
if (state.length === 0) state.needReadable = true;
|
|
159080
|
+
// call internal read method
|
|
159081
|
+
this._read(state.highWaterMark);
|
|
159082
|
+
state.sync = false;
|
|
159083
|
+
// If _read pushed data synchronously, then `reading` will be false,
|
|
159084
|
+
// and we need to re-evaluate how much data we can return to the user.
|
|
159085
|
+
if (!state.reading) n = howMuchToRead(nOrig, state);
|
|
159086
|
+
}
|
|
159087
|
+
var ret;
|
|
159088
|
+
if (n > 0) ret = fromList(n, state);else ret = null;
|
|
159089
|
+
if (ret === null) {
|
|
159090
|
+
state.needReadable = state.length <= state.highWaterMark;
|
|
159091
|
+
n = 0;
|
|
159092
|
+
} else {
|
|
159093
|
+
state.length -= n;
|
|
159094
|
+
state.awaitDrain = 0;
|
|
159095
|
+
}
|
|
159096
|
+
if (state.length === 0) {
|
|
159097
|
+
// If we have nothing in the buffer, then we want to know
|
|
159098
|
+
// as soon as we *do* get something into the buffer.
|
|
159099
|
+
if (!state.ended) state.needReadable = true;
|
|
159100
|
+
|
|
159101
|
+
// If we tried to read() past the EOF, then emit end on the next tick.
|
|
159102
|
+
if (nOrig !== n && state.ended) endReadable(this);
|
|
159103
|
+
}
|
|
159104
|
+
if (ret !== null) this.emit('data', ret);
|
|
159105
|
+
return ret;
|
|
159106
|
+
};
|
|
159107
|
+
function onEofChunk(stream, state) {
|
|
159108
|
+
debug('onEofChunk');
|
|
159109
|
+
if (state.ended) return;
|
|
159110
|
+
if (state.decoder) {
|
|
159111
|
+
var chunk = state.decoder.end();
|
|
159112
|
+
if (chunk && chunk.length) {
|
|
159113
|
+
state.buffer.push(chunk);
|
|
159114
|
+
state.length += state.objectMode ? 1 : chunk.length;
|
|
159115
|
+
}
|
|
159116
|
+
}
|
|
159117
|
+
state.ended = true;
|
|
159118
|
+
if (state.sync) {
|
|
159119
|
+
// if we are sync, wait until next tick to emit the data.
|
|
159120
|
+
// Otherwise we risk emitting data in the flow()
|
|
159121
|
+
// the readable code triggers during a read() call
|
|
159122
|
+
emitReadable(stream);
|
|
159123
|
+
} else {
|
|
159124
|
+
// emit 'readable' now to make sure it gets picked up.
|
|
159125
|
+
state.needReadable = false;
|
|
159126
|
+
if (!state.emittedReadable) {
|
|
159127
|
+
state.emittedReadable = true;
|
|
159128
|
+
emitReadable_(stream);
|
|
159129
|
+
}
|
|
159130
|
+
}
|
|
159131
|
+
}
|
|
159132
|
+
|
|
159133
|
+
// Don't emit readable right away in sync mode, because this can trigger
|
|
159134
|
+
// another read() call => stack overflow. This way, it might trigger
|
|
159135
|
+
// a nextTick recursion warning, but that's not so bad.
|
|
159136
|
+
function emitReadable(stream) {
|
|
159137
|
+
var state = stream._readableState;
|
|
159138
|
+
debug('emitReadable', state.needReadable, state.emittedReadable);
|
|
159139
|
+
state.needReadable = false;
|
|
159140
|
+
if (!state.emittedReadable) {
|
|
159141
|
+
debug('emitReadable', state.flowing);
|
|
159142
|
+
state.emittedReadable = true;
|
|
159143
|
+
process.nextTick(emitReadable_, stream);
|
|
159144
|
+
}
|
|
159145
|
+
}
|
|
159146
|
+
function emitReadable_(stream) {
|
|
159147
|
+
var state = stream._readableState;
|
|
159148
|
+
debug('emitReadable_', state.destroyed, state.length, state.ended);
|
|
159149
|
+
if (!state.destroyed && (state.length || state.ended)) {
|
|
159150
|
+
stream.emit('readable');
|
|
159151
|
+
state.emittedReadable = false;
|
|
159152
|
+
}
|
|
159153
|
+
|
|
159154
|
+
// The stream needs another readable event if
|
|
159155
|
+
// 1. It is not flowing, as the flow mechanism will take
|
|
159156
|
+
// care of it.
|
|
159157
|
+
// 2. It is not ended.
|
|
159158
|
+
// 3. It is below the highWaterMark, so we can schedule
|
|
159159
|
+
// another readable later.
|
|
159160
|
+
state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;
|
|
159161
|
+
flow(stream);
|
|
159162
|
+
}
|
|
159163
|
+
|
|
159164
|
+
// at this point, the user has presumably seen the 'readable' event,
|
|
159165
|
+
// and called read() to consume some data. that may have triggered
|
|
159166
|
+
// in turn another _read(n) call, in which case reading = true if
|
|
159167
|
+
// it's in progress.
|
|
159168
|
+
// However, if we're not ended, or reading, and the length < hwm,
|
|
159169
|
+
// then go ahead and try to read some more preemptively.
|
|
159170
|
+
function maybeReadMore(stream, state) {
|
|
159171
|
+
if (!state.readingMore) {
|
|
159172
|
+
state.readingMore = true;
|
|
159173
|
+
process.nextTick(maybeReadMore_, stream, state);
|
|
159174
|
+
}
|
|
159175
|
+
}
|
|
159176
|
+
function maybeReadMore_(stream, state) {
|
|
159177
|
+
// Attempt to read more data if we should.
|
|
159178
|
+
//
|
|
159179
|
+
// The conditions for reading more data are (one of):
|
|
159180
|
+
// - Not enough data buffered (state.length < state.highWaterMark). The loop
|
|
159181
|
+
// is responsible for filling the buffer with enough data if such data
|
|
159182
|
+
// is available. If highWaterMark is 0 and we are not in the flowing mode
|
|
159183
|
+
// we should _not_ attempt to buffer any extra data. We'll get more data
|
|
159184
|
+
// when the stream consumer calls read() instead.
|
|
159185
|
+
// - No data in the buffer, and the stream is in flowing mode. In this mode
|
|
159186
|
+
// the loop below is responsible for ensuring read() is called. Failing to
|
|
159187
|
+
// call read here would abort the flow and there's no other mechanism for
|
|
159188
|
+
// continuing the flow if the stream consumer has just subscribed to the
|
|
159189
|
+
// 'data' event.
|
|
159190
|
+
//
|
|
159191
|
+
// In addition to the above conditions to keep reading data, the following
|
|
159192
|
+
// conditions prevent the data from being read:
|
|
159193
|
+
// - The stream has ended (state.ended).
|
|
159194
|
+
// - There is already a pending 'read' operation (state.reading). This is a
|
|
159195
|
+
// case where the the stream has called the implementation defined _read()
|
|
159196
|
+
// method, but they are processing the call asynchronously and have _not_
|
|
159197
|
+
// called push() with new data. In this case we skip performing more
|
|
159198
|
+
// read()s. The execution ends in this method again after the _read() ends
|
|
159199
|
+
// up calling push() with more data.
|
|
159200
|
+
while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
|
|
159201
|
+
var len = state.length;
|
|
159202
|
+
debug('maybeReadMore read 0');
|
|
159203
|
+
stream.read(0);
|
|
159204
|
+
if (len === state.length)
|
|
159205
|
+
// didn't get any data, stop spinning.
|
|
159206
|
+
break;
|
|
159207
|
+
}
|
|
159208
|
+
state.readingMore = false;
|
|
159209
|
+
}
|
|
159210
|
+
|
|
159211
|
+
// abstract method. to be overridden in specific implementation classes.
|
|
159212
|
+
// call cb(er, data) where data is <= n in length.
|
|
159213
|
+
// for virtual (non-string, non-buffer) streams, "length" is somewhat
|
|
159214
|
+
// arbitrary, and perhaps not very meaningful.
|
|
159215
|
+
Readable.prototype._read = function (n) {
|
|
159216
|
+
errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()'));
|
|
159217
|
+
};
|
|
159218
|
+
Readable.prototype.pipe = function (dest, pipeOpts) {
|
|
159219
|
+
var src = this;
|
|
159220
|
+
var state = this._readableState;
|
|
159221
|
+
switch (state.pipesCount) {
|
|
159222
|
+
case 0:
|
|
159223
|
+
state.pipes = dest;
|
|
159224
|
+
break;
|
|
159225
|
+
case 1:
|
|
159226
|
+
state.pipes = [state.pipes, dest];
|
|
159227
|
+
break;
|
|
159228
|
+
default:
|
|
159229
|
+
state.pipes.push(dest);
|
|
159230
|
+
break;
|
|
159231
|
+
}
|
|
159232
|
+
state.pipesCount += 1;
|
|
159233
|
+
debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
|
|
159234
|
+
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
|
|
159235
|
+
var endFn = doEnd ? onend : unpipe;
|
|
159236
|
+
if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn);
|
|
159237
|
+
dest.on('unpipe', onunpipe);
|
|
159238
|
+
function onunpipe(readable, unpipeInfo) {
|
|
159239
|
+
debug('onunpipe');
|
|
159240
|
+
if (readable === src) {
|
|
159241
|
+
if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
|
|
159242
|
+
unpipeInfo.hasUnpiped = true;
|
|
159243
|
+
cleanup();
|
|
159244
|
+
}
|
|
159245
|
+
}
|
|
159246
|
+
}
|
|
159247
|
+
function onend() {
|
|
159248
|
+
debug('onend');
|
|
159249
|
+
dest.end();
|
|
159250
|
+
}
|
|
159251
|
+
|
|
159252
|
+
// when the dest drains, it reduces the awaitDrain counter
|
|
159253
|
+
// on the source. This would be more elegant with a .once()
|
|
159254
|
+
// handler in flow(), but adding and removing repeatedly is
|
|
159255
|
+
// too slow.
|
|
159256
|
+
var ondrain = pipeOnDrain(src);
|
|
159257
|
+
dest.on('drain', ondrain);
|
|
159258
|
+
var cleanedUp = false;
|
|
159259
|
+
function cleanup() {
|
|
159260
|
+
debug('cleanup');
|
|
159261
|
+
// cleanup event handlers once the pipe is broken
|
|
159262
|
+
dest.removeListener('close', onclose);
|
|
159263
|
+
dest.removeListener('finish', onfinish);
|
|
159264
|
+
dest.removeListener('drain', ondrain);
|
|
159265
|
+
dest.removeListener('error', onerror);
|
|
159266
|
+
dest.removeListener('unpipe', onunpipe);
|
|
159267
|
+
src.removeListener('end', onend);
|
|
159268
|
+
src.removeListener('end', unpipe);
|
|
159269
|
+
src.removeListener('data', ondata);
|
|
159270
|
+
cleanedUp = true;
|
|
159271
|
+
|
|
159272
|
+
// if the reader is waiting for a drain event from this
|
|
159273
|
+
// specific writer, then it would cause it to never start
|
|
159274
|
+
// flowing again.
|
|
159275
|
+
// So, if this is awaiting a drain, then we just call it now.
|
|
159276
|
+
// If we don't know, then assume that we are waiting for one.
|
|
159277
|
+
if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
|
|
159278
|
+
}
|
|
159279
|
+
src.on('data', ondata);
|
|
159280
|
+
function ondata(chunk) {
|
|
159281
|
+
debug('ondata');
|
|
159282
|
+
var ret = dest.write(chunk);
|
|
159283
|
+
debug('dest.write', ret);
|
|
159284
|
+
if (ret === false) {
|
|
159285
|
+
// If the user unpiped during `dest.write()`, it is possible
|
|
159286
|
+
// to get stuck in a permanently paused state if that write
|
|
159287
|
+
// also returned false.
|
|
159288
|
+
// => Check whether `dest` is still a piping destination.
|
|
159289
|
+
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
|
|
159290
|
+
debug('false write response, pause', state.awaitDrain);
|
|
159291
|
+
state.awaitDrain++;
|
|
159292
|
+
}
|
|
159293
|
+
src.pause();
|
|
159294
|
+
}
|
|
159295
|
+
}
|
|
159296
|
+
|
|
159297
|
+
// if the dest has an error, then stop piping into it.
|
|
159298
|
+
// however, don't suppress the throwing behavior for this.
|
|
159299
|
+
function onerror(er) {
|
|
159300
|
+
debug('onerror', er);
|
|
159301
|
+
unpipe();
|
|
159302
|
+
dest.removeListener('error', onerror);
|
|
159303
|
+
if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er);
|
|
159304
|
+
}
|
|
159305
|
+
|
|
159306
|
+
// Make sure our error handler is attached before userland ones.
|
|
159307
|
+
prependListener(dest, 'error', onerror);
|
|
159308
|
+
|
|
159309
|
+
// Both close and finish should trigger unpipe, but only once.
|
|
159310
|
+
function onclose() {
|
|
159311
|
+
dest.removeListener('finish', onfinish);
|
|
159312
|
+
unpipe();
|
|
159313
|
+
}
|
|
159314
|
+
dest.once('close', onclose);
|
|
159315
|
+
function onfinish() {
|
|
159316
|
+
debug('onfinish');
|
|
159317
|
+
dest.removeListener('close', onclose);
|
|
159318
|
+
unpipe();
|
|
159319
|
+
}
|
|
159320
|
+
dest.once('finish', onfinish);
|
|
159321
|
+
function unpipe() {
|
|
159322
|
+
debug('unpipe');
|
|
159323
|
+
src.unpipe(dest);
|
|
159324
|
+
}
|
|
159325
|
+
|
|
159326
|
+
// tell the dest that it's being piped to
|
|
159327
|
+
dest.emit('pipe', src);
|
|
159328
|
+
|
|
159329
|
+
// start the flow if it hasn't been started already.
|
|
159330
|
+
if (!state.flowing) {
|
|
159331
|
+
debug('pipe resume');
|
|
159332
|
+
src.resume();
|
|
159333
|
+
}
|
|
159334
|
+
return dest;
|
|
159335
|
+
};
|
|
159336
|
+
function pipeOnDrain(src) {
|
|
159337
|
+
return function pipeOnDrainFunctionResult() {
|
|
159338
|
+
var state = src._readableState;
|
|
159339
|
+
debug('pipeOnDrain', state.awaitDrain);
|
|
159340
|
+
if (state.awaitDrain) state.awaitDrain--;
|
|
159341
|
+
if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
|
|
159342
|
+
state.flowing = true;
|
|
159343
|
+
flow(src);
|
|
159344
|
+
}
|
|
159345
|
+
};
|
|
159346
|
+
}
|
|
159347
|
+
Readable.prototype.unpipe = function (dest) {
|
|
159348
|
+
var state = this._readableState;
|
|
159349
|
+
var unpipeInfo = {
|
|
159350
|
+
hasUnpiped: false
|
|
159351
|
+
};
|
|
159352
|
+
|
|
159353
|
+
// if we're not piping anywhere, then do nothing.
|
|
159354
|
+
if (state.pipesCount === 0) return this;
|
|
159355
|
+
|
|
159356
|
+
// just one destination. most common case.
|
|
159357
|
+
if (state.pipesCount === 1) {
|
|
159358
|
+
// passed in one, but it's not the right one.
|
|
159359
|
+
if (dest && dest !== state.pipes) return this;
|
|
159360
|
+
if (!dest) dest = state.pipes;
|
|
159361
|
+
|
|
159362
|
+
// got a match.
|
|
159363
|
+
state.pipes = null;
|
|
159364
|
+
state.pipesCount = 0;
|
|
159365
|
+
state.flowing = false;
|
|
159366
|
+
if (dest) dest.emit('unpipe', this, unpipeInfo);
|
|
159367
|
+
return this;
|
|
159368
|
+
}
|
|
159369
|
+
|
|
159370
|
+
// slow case. multiple pipe destinations.
|
|
159371
|
+
|
|
159372
|
+
if (!dest) {
|
|
159373
|
+
// remove all.
|
|
159374
|
+
var dests = state.pipes;
|
|
159375
|
+
var len = state.pipesCount;
|
|
159376
|
+
state.pipes = null;
|
|
159377
|
+
state.pipesCount = 0;
|
|
159378
|
+
state.flowing = false;
|
|
159379
|
+
for (var i = 0; i < len; i++) dests[i].emit('unpipe', this, {
|
|
159380
|
+
hasUnpiped: false
|
|
159381
|
+
});
|
|
159382
|
+
return this;
|
|
159383
|
+
}
|
|
159384
|
+
|
|
159385
|
+
// try to find the right one.
|
|
159386
|
+
var index = indexOf(state.pipes, dest);
|
|
159387
|
+
if (index === -1) return this;
|
|
159388
|
+
state.pipes.splice(index, 1);
|
|
159389
|
+
state.pipesCount -= 1;
|
|
159390
|
+
if (state.pipesCount === 1) state.pipes = state.pipes[0];
|
|
159391
|
+
dest.emit('unpipe', this, unpipeInfo);
|
|
159392
|
+
return this;
|
|
159393
|
+
};
|
|
159394
|
+
|
|
159395
|
+
// set up data events if they are asked for
|
|
159396
|
+
// Ensure readable listeners eventually get something
|
|
159397
|
+
Readable.prototype.on = function (ev, fn) {
|
|
159398
|
+
var res = Stream.prototype.on.call(this, ev, fn);
|
|
159399
|
+
var state = this._readableState;
|
|
159400
|
+
if (ev === 'data') {
|
|
159401
|
+
// update readableListening so that resume() may be a no-op
|
|
159402
|
+
// a few lines down. This is needed to support once('readable').
|
|
159403
|
+
state.readableListening = this.listenerCount('readable') > 0;
|
|
159404
|
+
|
|
159405
|
+
// Try start flowing on next tick if stream isn't explicitly paused
|
|
159406
|
+
if (state.flowing !== false) this.resume();
|
|
159407
|
+
} else if (ev === 'readable') {
|
|
159408
|
+
if (!state.endEmitted && !state.readableListening) {
|
|
159409
|
+
state.readableListening = state.needReadable = true;
|
|
159410
|
+
state.flowing = false;
|
|
159411
|
+
state.emittedReadable = false;
|
|
159412
|
+
debug('on readable', state.length, state.reading);
|
|
159413
|
+
if (state.length) {
|
|
159414
|
+
emitReadable(this);
|
|
159415
|
+
} else if (!state.reading) {
|
|
159416
|
+
process.nextTick(nReadingNextTick, this);
|
|
159417
|
+
}
|
|
159418
|
+
}
|
|
159419
|
+
}
|
|
159420
|
+
return res;
|
|
159421
|
+
};
|
|
159422
|
+
Readable.prototype.addListener = Readable.prototype.on;
|
|
159423
|
+
Readable.prototype.removeListener = function (ev, fn) {
|
|
159424
|
+
var res = Stream.prototype.removeListener.call(this, ev, fn);
|
|
159425
|
+
if (ev === 'readable') {
|
|
159426
|
+
// We need to check if there is someone still listening to
|
|
159427
|
+
// readable and reset the state. However this needs to happen
|
|
159428
|
+
// after readable has been emitted but before I/O (nextTick) to
|
|
159429
|
+
// support once('readable', fn) cycles. This means that calling
|
|
159430
|
+
// resume within the same tick will have no
|
|
159431
|
+
// effect.
|
|
159432
|
+
process.nextTick(updateReadableListening, this);
|
|
159433
|
+
}
|
|
159434
|
+
return res;
|
|
159435
|
+
};
|
|
159436
|
+
Readable.prototype.removeAllListeners = function (ev) {
|
|
159437
|
+
var res = Stream.prototype.removeAllListeners.apply(this, arguments);
|
|
159438
|
+
if (ev === 'readable' || ev === undefined) {
|
|
159439
|
+
// We need to check if there is someone still listening to
|
|
159440
|
+
// readable and reset the state. However this needs to happen
|
|
159441
|
+
// after readable has been emitted but before I/O (nextTick) to
|
|
159442
|
+
// support once('readable', fn) cycles. This means that calling
|
|
159443
|
+
// resume within the same tick will have no
|
|
159444
|
+
// effect.
|
|
159445
|
+
process.nextTick(updateReadableListening, this);
|
|
159446
|
+
}
|
|
159447
|
+
return res;
|
|
159448
|
+
};
|
|
159449
|
+
function updateReadableListening(self) {
|
|
159450
|
+
var state = self._readableState;
|
|
159451
|
+
state.readableListening = self.listenerCount('readable') > 0;
|
|
159452
|
+
if (state.resumeScheduled && !state.paused) {
|
|
159453
|
+
// flowing needs to be set to true now, otherwise
|
|
159454
|
+
// the upcoming resume will not flow.
|
|
159455
|
+
state.flowing = true;
|
|
159456
|
+
|
|
159457
|
+
// crude way to check if we should resume
|
|
159458
|
+
} else if (self.listenerCount('data') > 0) {
|
|
159459
|
+
self.resume();
|
|
159460
|
+
}
|
|
159461
|
+
}
|
|
159462
|
+
function nReadingNextTick(self) {
|
|
159463
|
+
debug('readable nexttick read 0');
|
|
159464
|
+
self.read(0);
|
|
159465
|
+
}
|
|
159466
|
+
|
|
159467
|
+
// pause() and resume() are remnants of the legacy readable stream API
|
|
159468
|
+
// If the user uses them, then switch into old mode.
|
|
159469
|
+
Readable.prototype.resume = function () {
|
|
159470
|
+
var state = this._readableState;
|
|
159471
|
+
if (!state.flowing) {
|
|
159472
|
+
debug('resume');
|
|
159473
|
+
// we flow only if there is no one listening
|
|
159474
|
+
// for readable, but we still have to call
|
|
159475
|
+
// resume()
|
|
159476
|
+
state.flowing = !state.readableListening;
|
|
159477
|
+
resume(this, state);
|
|
159478
|
+
}
|
|
159479
|
+
state.paused = false;
|
|
159480
|
+
return this;
|
|
159481
|
+
};
|
|
159482
|
+
function resume(stream, state) {
|
|
159483
|
+
if (!state.resumeScheduled) {
|
|
159484
|
+
state.resumeScheduled = true;
|
|
159485
|
+
process.nextTick(resume_, stream, state);
|
|
159486
|
+
}
|
|
159487
|
+
}
|
|
159488
|
+
function resume_(stream, state) {
|
|
159489
|
+
debug('resume', state.reading);
|
|
159490
|
+
if (!state.reading) {
|
|
159491
|
+
stream.read(0);
|
|
159492
|
+
}
|
|
159493
|
+
state.resumeScheduled = false;
|
|
159494
|
+
stream.emit('resume');
|
|
159495
|
+
flow(stream);
|
|
159496
|
+
if (state.flowing && !state.reading) stream.read(0);
|
|
159497
|
+
}
|
|
159498
|
+
Readable.prototype.pause = function () {
|
|
159499
|
+
debug('call pause flowing=%j', this._readableState.flowing);
|
|
159500
|
+
if (this._readableState.flowing !== false) {
|
|
159501
|
+
debug('pause');
|
|
159502
|
+
this._readableState.flowing = false;
|
|
159503
|
+
this.emit('pause');
|
|
159504
|
+
}
|
|
159505
|
+
this._readableState.paused = true;
|
|
159506
|
+
return this;
|
|
159507
|
+
};
|
|
159508
|
+
function flow(stream) {
|
|
159509
|
+
var state = stream._readableState;
|
|
159510
|
+
debug('flow', state.flowing);
|
|
159511
|
+
while (state.flowing && stream.read() !== null);
|
|
159512
|
+
}
|
|
159513
|
+
|
|
159514
|
+
// wrap an old-style stream as the async data source.
|
|
159515
|
+
// This is *not* part of the readable stream interface.
|
|
159516
|
+
// It is an ugly unfortunate mess of history.
|
|
159517
|
+
Readable.prototype.wrap = function (stream) {
|
|
159518
|
+
var _this = this;
|
|
159519
|
+
var state = this._readableState;
|
|
159520
|
+
var paused = false;
|
|
159521
|
+
stream.on('end', function () {
|
|
159522
|
+
debug('wrapped end');
|
|
159523
|
+
if (state.decoder && !state.ended) {
|
|
159524
|
+
var chunk = state.decoder.end();
|
|
159525
|
+
if (chunk && chunk.length) _this.push(chunk);
|
|
159526
|
+
}
|
|
159527
|
+
_this.push(null);
|
|
159528
|
+
});
|
|
159529
|
+
stream.on('data', function (chunk) {
|
|
159530
|
+
debug('wrapped data');
|
|
159531
|
+
if (state.decoder) chunk = state.decoder.write(chunk);
|
|
159532
|
+
|
|
159533
|
+
// don't skip over falsy values in objectMode
|
|
159534
|
+
if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
|
|
159535
|
+
var ret = _this.push(chunk);
|
|
159536
|
+
if (!ret) {
|
|
159537
|
+
paused = true;
|
|
159538
|
+
stream.pause();
|
|
159539
|
+
}
|
|
159540
|
+
});
|
|
159541
|
+
|
|
159542
|
+
// proxy all the other methods.
|
|
159543
|
+
// important when wrapping filters and duplexes.
|
|
159544
|
+
for (var i in stream) {
|
|
159545
|
+
if (this[i] === undefined && typeof stream[i] === 'function') {
|
|
159546
|
+
this[i] = function methodWrap(method) {
|
|
159547
|
+
return function methodWrapReturnFunction() {
|
|
159548
|
+
return stream[method].apply(stream, arguments);
|
|
159549
|
+
};
|
|
159550
|
+
}(i);
|
|
159551
|
+
}
|
|
159552
|
+
}
|
|
159553
|
+
|
|
159554
|
+
// proxy certain important events.
|
|
159555
|
+
for (var n = 0; n < kProxyEvents.length; n++) {
|
|
159556
|
+
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
|
|
159557
|
+
}
|
|
159558
|
+
|
|
159559
|
+
// when we try to consume some more bytes, simply unpause the
|
|
159560
|
+
// underlying stream.
|
|
159561
|
+
this._read = function (n) {
|
|
159562
|
+
debug('wrapped _read', n);
|
|
159563
|
+
if (paused) {
|
|
159564
|
+
paused = false;
|
|
159565
|
+
stream.resume();
|
|
159566
|
+
}
|
|
159567
|
+
};
|
|
159568
|
+
return this;
|
|
159569
|
+
};
|
|
159570
|
+
if (typeof Symbol === 'function') {
|
|
159571
|
+
Readable.prototype[Symbol.asyncIterator] = function () {
|
|
159572
|
+
if (createReadableStreamAsyncIterator === undefined) {
|
|
159573
|
+
createReadableStreamAsyncIterator = requireAsync_iterator();
|
|
159574
|
+
}
|
|
159575
|
+
return createReadableStreamAsyncIterator(this);
|
|
159576
|
+
};
|
|
159577
|
+
}
|
|
159578
|
+
Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
|
|
159579
|
+
// making it explicit this property is not enumerable
|
|
159580
|
+
// because otherwise some prototype manipulation in
|
|
159581
|
+
// userland will fail
|
|
159582
|
+
enumerable: false,
|
|
159583
|
+
get: function get() {
|
|
159584
|
+
return this._readableState.highWaterMark;
|
|
159585
|
+
}
|
|
159586
|
+
});
|
|
159587
|
+
Object.defineProperty(Readable.prototype, 'readableBuffer', {
|
|
159588
|
+
// making it explicit this property is not enumerable
|
|
159589
|
+
// because otherwise some prototype manipulation in
|
|
159590
|
+
// userland will fail
|
|
159591
|
+
enumerable: false,
|
|
159592
|
+
get: function get() {
|
|
159593
|
+
return this._readableState && this._readableState.buffer;
|
|
159594
|
+
}
|
|
159595
|
+
});
|
|
159596
|
+
Object.defineProperty(Readable.prototype, 'readableFlowing', {
|
|
159597
|
+
// making it explicit this property is not enumerable
|
|
159598
|
+
// because otherwise some prototype manipulation in
|
|
159599
|
+
// userland will fail
|
|
159600
|
+
enumerable: false,
|
|
159601
|
+
get: function get() {
|
|
159602
|
+
return this._readableState.flowing;
|
|
159603
|
+
},
|
|
159604
|
+
set: function set(state) {
|
|
159605
|
+
if (this._readableState) {
|
|
159606
|
+
this._readableState.flowing = state;
|
|
159607
|
+
}
|
|
159608
|
+
}
|
|
159609
|
+
});
|
|
159610
|
+
|
|
159611
|
+
// exposed for testing purposes only.
|
|
159612
|
+
Readable._fromList = fromList;
|
|
159613
|
+
Object.defineProperty(Readable.prototype, 'readableLength', {
|
|
159614
|
+
// making it explicit this property is not enumerable
|
|
159615
|
+
// because otherwise some prototype manipulation in
|
|
159616
|
+
// userland will fail
|
|
159617
|
+
enumerable: false,
|
|
159618
|
+
get: function get() {
|
|
159619
|
+
return this._readableState.length;
|
|
159620
|
+
}
|
|
159621
|
+
});
|
|
159622
|
+
|
|
159623
|
+
// Pluck off n bytes from an array of buffers.
|
|
159624
|
+
// Length is the combined lengths of all the buffers in the list.
|
|
159625
|
+
// This function is designed to be inlinable, so please take care when making
|
|
159626
|
+
// changes to the function body.
|
|
159627
|
+
function fromList(n, state) {
|
|
159628
|
+
// nothing buffered
|
|
159629
|
+
if (state.length === 0) return null;
|
|
159630
|
+
var ret;
|
|
159631
|
+
if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
|
|
159632
|
+
// read it all, truncate the list
|
|
159633
|
+
if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length);
|
|
159634
|
+
state.buffer.clear();
|
|
159635
|
+
} else {
|
|
159636
|
+
// read part of list
|
|
159637
|
+
ret = state.buffer.consume(n, state.decoder);
|
|
159638
|
+
}
|
|
159639
|
+
return ret;
|
|
159640
|
+
}
|
|
159641
|
+
function endReadable(stream) {
|
|
159642
|
+
var state = stream._readableState;
|
|
159643
|
+
debug('endReadable', state.endEmitted);
|
|
159644
|
+
if (!state.endEmitted) {
|
|
159645
|
+
state.ended = true;
|
|
159646
|
+
process.nextTick(endReadableNT, state, stream);
|
|
159647
|
+
}
|
|
159648
|
+
}
|
|
159649
|
+
function endReadableNT(state, stream) {
|
|
159650
|
+
debug('endReadableNT', state.endEmitted, state.length);
|
|
159651
|
+
|
|
159652
|
+
// Check that we didn't get one last unshift.
|
|
159653
|
+
if (!state.endEmitted && state.length === 0) {
|
|
159654
|
+
state.endEmitted = true;
|
|
159655
|
+
stream.readable = false;
|
|
159656
|
+
stream.emit('end');
|
|
159657
|
+
if (state.autoDestroy) {
|
|
159658
|
+
// In case of duplex streams we need a way to detect
|
|
159659
|
+
// if the writable side is ready for autoDestroy as well
|
|
159660
|
+
var wState = stream._writableState;
|
|
159661
|
+
if (!wState || wState.autoDestroy && wState.finished) {
|
|
159662
|
+
stream.destroy();
|
|
159663
|
+
}
|
|
159664
|
+
}
|
|
159665
|
+
}
|
|
159666
|
+
}
|
|
159667
|
+
if (typeof Symbol === 'function') {
|
|
159668
|
+
Readable.from = function (iterable, opts) {
|
|
159669
|
+
if (from === undefined) {
|
|
159670
|
+
from = requireFrom();
|
|
159671
|
+
}
|
|
159672
|
+
return from(Readable, iterable, opts);
|
|
159673
|
+
};
|
|
159674
|
+
}
|
|
159675
|
+
function indexOf(xs, x) {
|
|
159676
|
+
for (var i = 0, l = xs.length; i < l; i++) {
|
|
159677
|
+
if (xs[i] === x) return i;
|
|
159678
|
+
}
|
|
159679
|
+
return -1;
|
|
159680
|
+
}
|
|
159681
|
+
return _stream_readable;
|
|
159682
|
+
}
|
|
159683
|
+
|
|
159684
|
+
var _stream_transform;
|
|
159685
|
+
var hasRequired_stream_transform;
|
|
159686
|
+
|
|
159687
|
+
function require_stream_transform () {
|
|
159688
|
+
if (hasRequired_stream_transform) return _stream_transform;
|
|
159689
|
+
hasRequired_stream_transform = 1;
|
|
159690
|
+
|
|
159691
|
+
_stream_transform = Transform;
|
|
159692
|
+
var _require$codes = requireErrors().codes,
|
|
159693
|
+
ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
|
|
159694
|
+
ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
|
|
159695
|
+
ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
|
|
159696
|
+
ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
|
|
159697
|
+
var Duplex = require_stream_duplex();
|
|
159698
|
+
inheritsExports(Transform, Duplex);
|
|
159699
|
+
function afterTransform(er, data) {
|
|
159700
|
+
var ts = this._transformState;
|
|
159701
|
+
ts.transforming = false;
|
|
159702
|
+
var cb = ts.writecb;
|
|
159703
|
+
if (cb === null) {
|
|
159704
|
+
return this.emit('error', new ERR_MULTIPLE_CALLBACK());
|
|
159705
|
+
}
|
|
159706
|
+
ts.writechunk = null;
|
|
159707
|
+
ts.writecb = null;
|
|
159708
|
+
if (data != null)
|
|
159709
|
+
// single equals check for both `null` and `undefined`
|
|
159710
|
+
this.push(data);
|
|
159711
|
+
cb(er);
|
|
159712
|
+
var rs = this._readableState;
|
|
159713
|
+
rs.reading = false;
|
|
159714
|
+
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
|
159715
|
+
this._read(rs.highWaterMark);
|
|
159716
|
+
}
|
|
159717
|
+
}
|
|
159718
|
+
function Transform(options) {
|
|
159719
|
+
if (!(this instanceof Transform)) return new Transform(options);
|
|
159720
|
+
Duplex.call(this, options);
|
|
159721
|
+
this._transformState = {
|
|
159722
|
+
afterTransform: afterTransform.bind(this),
|
|
159723
|
+
needTransform: false,
|
|
159724
|
+
transforming: false,
|
|
159725
|
+
writecb: null,
|
|
159726
|
+
writechunk: null,
|
|
159727
|
+
writeencoding: null
|
|
159728
|
+
};
|
|
159729
|
+
|
|
159730
|
+
// start out asking for a readable event once data is transformed.
|
|
159731
|
+
this._readableState.needReadable = true;
|
|
159732
|
+
|
|
159733
|
+
// we have implemented the _read method, and done the other things
|
|
159734
|
+
// that Readable wants before the first _read call, so unset the
|
|
159735
|
+
// sync guard flag.
|
|
159736
|
+
this._readableState.sync = false;
|
|
159737
|
+
if (options) {
|
|
159738
|
+
if (typeof options.transform === 'function') this._transform = options.transform;
|
|
159739
|
+
if (typeof options.flush === 'function') this._flush = options.flush;
|
|
159740
|
+
}
|
|
159741
|
+
|
|
159742
|
+
// When the writable side finishes, then flush out anything remaining.
|
|
159743
|
+
this.on('prefinish', prefinish);
|
|
159744
|
+
}
|
|
159745
|
+
function prefinish() {
|
|
159746
|
+
var _this = this;
|
|
159747
|
+
if (typeof this._flush === 'function' && !this._readableState.destroyed) {
|
|
159748
|
+
this._flush(function (er, data) {
|
|
159749
|
+
done(_this, er, data);
|
|
159750
|
+
});
|
|
159751
|
+
} else {
|
|
159752
|
+
done(this, null, null);
|
|
159753
|
+
}
|
|
159754
|
+
}
|
|
159755
|
+
Transform.prototype.push = function (chunk, encoding) {
|
|
159756
|
+
this._transformState.needTransform = false;
|
|
159757
|
+
return Duplex.prototype.push.call(this, chunk, encoding);
|
|
159758
|
+
};
|
|
159759
|
+
|
|
159760
|
+
// This is the part where you do stuff!
|
|
159761
|
+
// override this function in implementation classes.
|
|
159762
|
+
// 'chunk' is an input chunk.
|
|
159763
|
+
//
|
|
159764
|
+
// Call `push(newChunk)` to pass along transformed output
|
|
159765
|
+
// to the readable side. You may call 'push' zero or more times.
|
|
159766
|
+
//
|
|
159767
|
+
// Call `cb(err)` when you are done with this chunk. If you pass
|
|
159768
|
+
// an error, then that'll put the hurt on the whole operation. If you
|
|
159769
|
+
// never call cb(), then you'll never get another chunk.
|
|
159770
|
+
Transform.prototype._transform = function (chunk, encoding, cb) {
|
|
159771
|
+
cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));
|
|
159772
|
+
};
|
|
159773
|
+
Transform.prototype._write = function (chunk, encoding, cb) {
|
|
159774
|
+
var ts = this._transformState;
|
|
159775
|
+
ts.writecb = cb;
|
|
159776
|
+
ts.writechunk = chunk;
|
|
159777
|
+
ts.writeencoding = encoding;
|
|
159778
|
+
if (!ts.transforming) {
|
|
159779
|
+
var rs = this._readableState;
|
|
159780
|
+
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
|
|
159781
|
+
}
|
|
159782
|
+
};
|
|
159783
|
+
|
|
159784
|
+
// Doesn't matter what the args are here.
|
|
159785
|
+
// _transform does all the work.
|
|
159786
|
+
// That we got here means that the readable side wants more data.
|
|
159787
|
+
Transform.prototype._read = function (n) {
|
|
159788
|
+
var ts = this._transformState;
|
|
159789
|
+
if (ts.writechunk !== null && !ts.transforming) {
|
|
159790
|
+
ts.transforming = true;
|
|
159791
|
+
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
|
159792
|
+
} else {
|
|
159793
|
+
// mark that we need a transform, so that any data that comes in
|
|
159794
|
+
// will get processed, now that we've asked for it.
|
|
159795
|
+
ts.needTransform = true;
|
|
159796
|
+
}
|
|
159797
|
+
};
|
|
159798
|
+
Transform.prototype._destroy = function (err, cb) {
|
|
159799
|
+
Duplex.prototype._destroy.call(this, err, function (err2) {
|
|
159800
|
+
cb(err2);
|
|
159801
|
+
});
|
|
159802
|
+
};
|
|
159803
|
+
function done(stream, er, data) {
|
|
159804
|
+
if (er) return stream.emit('error', er);
|
|
159805
|
+
if (data != null)
|
|
159806
|
+
// single equals check for both `null` and `undefined`
|
|
159807
|
+
stream.push(data);
|
|
159808
|
+
|
|
159809
|
+
// TODO(BridgeAR): Write a test for these two error cases
|
|
159810
|
+
// if there's nothing in the write buffer, then that means
|
|
159811
|
+
// that nothing more will ever be provided
|
|
159812
|
+
if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();
|
|
159813
|
+
if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();
|
|
159814
|
+
return stream.push(null);
|
|
159815
|
+
}
|
|
159816
|
+
return _stream_transform;
|
|
159817
|
+
}
|
|
159818
|
+
|
|
159819
|
+
var _stream_passthrough;
|
|
159820
|
+
var hasRequired_stream_passthrough;
|
|
159821
|
+
|
|
159822
|
+
function require_stream_passthrough () {
|
|
159823
|
+
if (hasRequired_stream_passthrough) return _stream_passthrough;
|
|
159824
|
+
hasRequired_stream_passthrough = 1;
|
|
159825
|
+
|
|
159826
|
+
_stream_passthrough = PassThrough;
|
|
159827
|
+
var Transform = require_stream_transform();
|
|
159828
|
+
inheritsExports(PassThrough, Transform);
|
|
159829
|
+
function PassThrough(options) {
|
|
159830
|
+
if (!(this instanceof PassThrough)) return new PassThrough(options);
|
|
159831
|
+
Transform.call(this, options);
|
|
159832
|
+
}
|
|
159833
|
+
PassThrough.prototype._transform = function (chunk, encoding, cb) {
|
|
159834
|
+
cb(null, chunk);
|
|
159835
|
+
};
|
|
159836
|
+
return _stream_passthrough;
|
|
159837
|
+
}
|
|
159838
|
+
|
|
159839
|
+
var pipeline_1;
|
|
159840
|
+
var hasRequiredPipeline;
|
|
159841
|
+
|
|
159842
|
+
function requirePipeline () {
|
|
159843
|
+
if (hasRequiredPipeline) return pipeline_1;
|
|
159844
|
+
hasRequiredPipeline = 1;
|
|
159845
|
+
|
|
159846
|
+
var eos;
|
|
159847
|
+
function once(callback) {
|
|
159848
|
+
var called = false;
|
|
159849
|
+
return function () {
|
|
159850
|
+
if (called) return;
|
|
159851
|
+
called = true;
|
|
159852
|
+
callback.apply(void 0, arguments);
|
|
159853
|
+
};
|
|
159854
|
+
}
|
|
159855
|
+
var _require$codes = requireErrors().codes,
|
|
159856
|
+
ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,
|
|
159857
|
+
ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
|
|
159858
|
+
function noop(err) {
|
|
159859
|
+
// Rethrow the error if it exists to avoid swallowing it
|
|
159860
|
+
if (err) throw err;
|
|
159861
|
+
}
|
|
159862
|
+
function isRequest(stream) {
|
|
159863
|
+
return stream.setHeader && typeof stream.abort === 'function';
|
|
159864
|
+
}
|
|
159865
|
+
function destroyer(stream, reading, writing, callback) {
|
|
159866
|
+
callback = once(callback);
|
|
159867
|
+
var closed = false;
|
|
159868
|
+
stream.on('close', function () {
|
|
159869
|
+
closed = true;
|
|
159870
|
+
});
|
|
159871
|
+
if (eos === undefined) eos = requireEndOfStream();
|
|
159872
|
+
eos(stream, {
|
|
159873
|
+
readable: reading,
|
|
159874
|
+
writable: writing
|
|
159875
|
+
}, function (err) {
|
|
159876
|
+
if (err) return callback(err);
|
|
159877
|
+
closed = true;
|
|
159878
|
+
callback();
|
|
159879
|
+
});
|
|
159880
|
+
var destroyed = false;
|
|
159881
|
+
return function (err) {
|
|
159882
|
+
if (closed) return;
|
|
159883
|
+
if (destroyed) return;
|
|
159884
|
+
destroyed = true;
|
|
159885
|
+
|
|
159886
|
+
// request.destroy just do .end - .abort is what we want
|
|
159887
|
+
if (isRequest(stream)) return stream.abort();
|
|
159888
|
+
if (typeof stream.destroy === 'function') return stream.destroy();
|
|
159889
|
+
callback(err || new ERR_STREAM_DESTROYED('pipe'));
|
|
159890
|
+
};
|
|
159891
|
+
}
|
|
159892
|
+
function call(fn) {
|
|
159893
|
+
fn();
|
|
159894
|
+
}
|
|
159895
|
+
function pipe(from, to) {
|
|
159896
|
+
return from.pipe(to);
|
|
159897
|
+
}
|
|
159898
|
+
function popCallback(streams) {
|
|
159899
|
+
if (!streams.length) return noop;
|
|
159900
|
+
if (typeof streams[streams.length - 1] !== 'function') return noop;
|
|
159901
|
+
return streams.pop();
|
|
159902
|
+
}
|
|
159903
|
+
function pipeline() {
|
|
159904
|
+
for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
159905
|
+
streams[_key] = arguments[_key];
|
|
159906
|
+
}
|
|
159907
|
+
var callback = popCallback(streams);
|
|
159908
|
+
if (Array.isArray(streams[0])) streams = streams[0];
|
|
159909
|
+
if (streams.length < 2) {
|
|
159910
|
+
throw new ERR_MISSING_ARGS('streams');
|
|
159911
|
+
}
|
|
159912
|
+
var error;
|
|
159913
|
+
var destroys = streams.map(function (stream, i) {
|
|
159914
|
+
var reading = i < streams.length - 1;
|
|
159915
|
+
var writing = i > 0;
|
|
159916
|
+
return destroyer(stream, reading, writing, function (err) {
|
|
159917
|
+
if (!error) error = err;
|
|
159918
|
+
if (err) destroys.forEach(call);
|
|
159919
|
+
if (reading) return;
|
|
159920
|
+
destroys.forEach(call);
|
|
159921
|
+
callback(error);
|
|
159922
|
+
});
|
|
159923
|
+
});
|
|
159924
|
+
return streams.reduce(pipe);
|
|
159925
|
+
}
|
|
159926
|
+
pipeline_1 = pipeline;
|
|
159927
|
+
return pipeline_1;
|
|
159928
|
+
}
|
|
159929
|
+
|
|
159930
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
159931
|
+
//
|
|
159932
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
159933
|
+
// copy of this software and associated documentation files (the
|
|
159934
|
+
// "Software"), to deal in the Software without restriction, including
|
|
159935
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
159936
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
159937
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
159938
|
+
// following conditions:
|
|
159939
|
+
//
|
|
159940
|
+
// The above copyright notice and this permission notice shall be included
|
|
159941
|
+
// in all copies or substantial portions of the Software.
|
|
159942
|
+
//
|
|
159943
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
159944
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
159945
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
159946
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
159947
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
159948
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
159949
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
159950
|
+
|
|
159951
|
+
var streamBrowserify = Stream;
|
|
159952
|
+
|
|
159953
|
+
var EE = require$$0$4.EventEmitter;
|
|
159954
|
+
var inherits = inheritsExports;
|
|
159955
|
+
|
|
159956
|
+
inherits(Stream, EE);
|
|
159957
|
+
Stream.Readable = require_stream_readable();
|
|
159958
|
+
Stream.Writable = require_stream_writable();
|
|
159959
|
+
Stream.Duplex = require_stream_duplex();
|
|
159960
|
+
Stream.Transform = require_stream_transform();
|
|
159961
|
+
Stream.PassThrough = require_stream_passthrough();
|
|
159962
|
+
Stream.finished = requireEndOfStream();
|
|
159963
|
+
Stream.pipeline = requirePipeline();
|
|
159964
|
+
|
|
159965
|
+
// Backwards-compat with node 0.4.x
|
|
159966
|
+
Stream.Stream = Stream;
|
|
159967
|
+
|
|
159968
|
+
|
|
159969
|
+
|
|
159970
|
+
// old-style streams. Note that the pipe method (the only relevant
|
|
159971
|
+
// part of this class) is overridden in the Readable class.
|
|
159972
|
+
|
|
159973
|
+
function Stream() {
|
|
159974
|
+
EE.call(this);
|
|
159975
|
+
}
|
|
159976
|
+
|
|
159977
|
+
Stream.prototype.pipe = function(dest, options) {
|
|
159978
|
+
var source = this;
|
|
159979
|
+
|
|
159980
|
+
function ondata(chunk) {
|
|
159981
|
+
if (dest.writable) {
|
|
159982
|
+
if (false === dest.write(chunk) && source.pause) {
|
|
159983
|
+
source.pause();
|
|
159984
|
+
}
|
|
159985
|
+
}
|
|
159986
|
+
}
|
|
159987
|
+
|
|
159988
|
+
source.on('data', ondata);
|
|
159989
|
+
|
|
159990
|
+
function ondrain() {
|
|
159991
|
+
if (source.readable && source.resume) {
|
|
159992
|
+
source.resume();
|
|
159993
|
+
}
|
|
159994
|
+
}
|
|
159995
|
+
|
|
159996
|
+
dest.on('drain', ondrain);
|
|
159997
|
+
|
|
159998
|
+
// If the 'end' option is not supplied, dest.end() will be called when
|
|
159999
|
+
// source gets the 'end' or 'close' events. Only dest.end() once.
|
|
160000
|
+
if (!dest._isStdio && (!options || options.end !== false)) {
|
|
160001
|
+
source.on('end', onend);
|
|
160002
|
+
source.on('close', onclose);
|
|
160003
|
+
}
|
|
160004
|
+
|
|
160005
|
+
var didOnEnd = false;
|
|
160006
|
+
function onend() {
|
|
160007
|
+
if (didOnEnd) return;
|
|
160008
|
+
didOnEnd = true;
|
|
160009
|
+
|
|
160010
|
+
dest.end();
|
|
160011
|
+
}
|
|
160012
|
+
|
|
160013
|
+
|
|
160014
|
+
function onclose() {
|
|
160015
|
+
if (didOnEnd) return;
|
|
160016
|
+
didOnEnd = true;
|
|
160017
|
+
|
|
160018
|
+
if (typeof dest.destroy === 'function') dest.destroy();
|
|
160019
|
+
}
|
|
160020
|
+
|
|
160021
|
+
// don't leave dangling pipes when there are errors.
|
|
160022
|
+
function onerror(er) {
|
|
160023
|
+
cleanup();
|
|
160024
|
+
if (EE.listenerCount(this, 'error') === 0) {
|
|
160025
|
+
throw er; // Unhandled stream error in pipe.
|
|
160026
|
+
}
|
|
160027
|
+
}
|
|
160028
|
+
|
|
160029
|
+
source.on('error', onerror);
|
|
160030
|
+
dest.on('error', onerror);
|
|
160031
|
+
|
|
160032
|
+
// remove all the event listeners that were added.
|
|
160033
|
+
function cleanup() {
|
|
160034
|
+
source.removeListener('data', ondata);
|
|
160035
|
+
dest.removeListener('drain', ondrain);
|
|
160036
|
+
|
|
160037
|
+
source.removeListener('end', onend);
|
|
160038
|
+
source.removeListener('close', onclose);
|
|
160039
|
+
|
|
160040
|
+
source.removeListener('error', onerror);
|
|
160041
|
+
dest.removeListener('error', onerror);
|
|
160042
|
+
|
|
160043
|
+
source.removeListener('end', cleanup);
|
|
160044
|
+
source.removeListener('close', cleanup);
|
|
160045
|
+
|
|
160046
|
+
dest.removeListener('close', cleanup);
|
|
160047
|
+
}
|
|
160048
|
+
|
|
160049
|
+
source.on('end', cleanup);
|
|
160050
|
+
source.on('close', cleanup);
|
|
160051
|
+
|
|
160052
|
+
dest.on('close', cleanup);
|
|
160053
|
+
|
|
160054
|
+
dest.emit('pipe', source);
|
|
160055
|
+
|
|
160056
|
+
// Allow for unix-like usage: A.pipe(B).pipe(C)
|
|
160057
|
+
return dest;
|
|
160058
|
+
};
|
|
160059
|
+
|
|
160060
|
+
window.ReadableStream = streamBrowserify.Readable;
|
|
160061
|
+
window.WritableStream = streamBrowserify.Writable;
|
|
156772
160062
|
var BondsWithProvider = function () {
|
|
156773
160063
|
return (React$1.createElement(Web3ContextProvider, null,
|
|
156774
160064
|
React$1.createElement(Bonds, null)));
|