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