@massalabs/wallet-provider 0.0.1-dev.20230526090450 → 0.0.1-dev.20230613120625

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/bundle.js CHANGED
@@ -140,22 +140,30 @@ class Account {
140
140
  *
141
141
  * @param contractAddress - The address of the smart contract.
142
142
  * @param functionName - The name of the function to be called.
143
- * @param parameter - The parameters of the function to be called (array composed of string, bigint and/or boolean).
144
- * @param fee - The fee to be paid for the transaction execution by the node.
145
- * @returns An ITransactionDetails object. It contains the operationId on the network.
143
+ * @param parameter - The parameters as an Args object to be passed to the function.
144
+ * @param amount - The amount of MASSA coins to be sent to the block creator.
146
145
  *
146
+ * @returns An ITransactionDetails object.
147
+ * - It contains the first event emitted by the contract.
148
+ * - If the contract does not emit any event, it contains "Function called successfully but no event generated"
147
149
  */
148
- async interactWithSC(contractAddress, functionName, parameter, fee) {
150
+ async callSC(contractAddress, functionName, parameter, amount, nonPersistentExecution = {
151
+ isNPE: false,
152
+ }) {
149
153
  return new Promise((resolve, reject) => {
150
- Connector_1.connector.sendMessageToContentScript(this._providerName, __1.AvailableCommands.AccountInteractWithSC, {
151
- contractAddress,
152
- functionName,
153
- parameter,
154
- fee,
154
+ Connector_1.connector.sendMessageToContentScript(this._providerName, __1.AvailableCommands.AccountCallSC, {
155
+ nickname: this._name,
156
+ name: functionName,
157
+ at: contractAddress,
158
+ args: parameter,
159
+ coins: amount,
160
+ nonPersistentExecution: nonPersistentExecution,
155
161
  }, (result, err) => {
156
162
  if (err)
157
163
  return reject(err);
158
- return resolve(result);
164
+ return resolve(nonPersistentExecution?.isNPE
165
+ ? result
166
+ : result);
159
167
  });
160
168
  });
161
169
  }
@@ -334,7 +342,7 @@ class Connector {
334
342
  }
335
343
  exports.connector = new Connector();
336
344
 
337
- },{"..":4,"../thyra/ThyraDiscovery":11,"../thyra/ThyraProvider":12,"uid":46}],4:[function(require,module,exports){
345
+ },{"..":4,"../thyra/ThyraDiscovery":11,"../thyra/ThyraProvider":12,"uid":50}],4:[function(require,module,exports){
338
346
  "use strict";
339
347
  Object.defineProperty(exports, "__esModule", { value: true });
340
348
  exports.ThyraAccount = exports.Provider = exports.EAccountImportResponse = exports.EAccountDeletionResponse = exports.Account = exports.providers = exports.AvailableCommands = void 0;
@@ -353,7 +361,7 @@ var AvailableCommands;
353
361
  AvailableCommands["AccountSellRolls"] = "ACCOUNT_SELL_ROLLS";
354
362
  AvailableCommands["AccountBuyRolls"] = "ACCOUNT_BUY_ROLLS";
355
363
  AvailableCommands["AccountSendTransaction"] = "ACCOUNT_SEND_TRANSACTION";
356
- AvailableCommands["AccountInteractWithSC"] = "ACCOUNT_INTERACT_WITH_SC";
364
+ AvailableCommands["AccountCallSC"] = "ACCOUNT_CALL_SC";
357
365
  })(AvailableCommands = exports.AvailableCommands || (exports.AvailableCommands = {}));
358
366
  function providers() {
359
367
  let providers = [];
@@ -611,22 +619,23 @@ exports.getRequest = getRequest;
611
619
  *
612
620
  */
613
621
  async function postRequest(url, body) {
614
- let resp = null;
615
622
  try {
616
- resp = await axios_1.default.post(url, body, requestHeaders);
623
+ const resp = await axios_1.default.post(url, body, requestHeaders);
624
+ return {
625
+ isError: false,
626
+ result: resp.data,
627
+ error: null,
628
+ };
617
629
  }
618
630
  catch (ex) {
619
631
  return {
620
632
  isError: true,
621
633
  result: null,
622
- error: new Error('Axios error: ' + String(ex)),
634
+ error: ex.response?.data?.message
635
+ ? new Error(String(ex.response.data.message))
636
+ : new Error('Axios error: ' + String(ex)),
623
637
  };
624
638
  }
625
- return {
626
- isError: false,
627
- result: resp.data,
628
- error: null,
629
- };
630
639
  }
631
640
  exports.postRequest = postRequest;
632
641
  /**
@@ -685,16 +694,21 @@ async function putRequest(url, body) {
685
694
  }
686
695
  exports.putRequest = putRequest;
687
696
 
688
- },{"axios":14}],10:[function(require,module,exports){
697
+ },{"axios":15}],10:[function(require,module,exports){
689
698
  "use strict";
690
699
  Object.defineProperty(exports, "__esModule", { value: true });
691
700
  exports.ThyraAccount = void 0;
692
701
  const RequestHandler_1 = require("./RequestHandler");
693
702
  const ThyraProvider_1 = require("./ThyraProvider");
703
+ const argsToBase64_1 = require("../utils/argsToBase64");
694
704
  /**
695
705
  * The Thyra's account balance url
696
706
  */
697
- const THYRA_BALANCE_URL = `https://my.massa/massa/addresses?attributes=balance&addresses`;
707
+ const THYRA_BALANCE_URL = `${ThyraProvider_1.MASSA_STATION_URL}massa/addresses?attributes=balance&addresses`;
708
+ /**
709
+ * The maximum allowed gas for a read operation
710
+ */
711
+ const MAX_READ_BLOCK_GAS = BigInt(4294967295);
698
712
  /**
699
713
  * This module contains the ThyraAccount class. It is responsible for representing an account in the Thyra wallet.
700
714
  *
@@ -771,7 +785,7 @@ class ThyraAccount {
771
785
  async sign(data) {
772
786
  let signOpResponse = null;
773
787
  try {
774
- signOpResponse = await (0, RequestHandler_1.postRequest)(`${ThyraProvider_1.THYRA_ACCOUNTS_URL}/${this._name}/sign`, {
788
+ signOpResponse = await (0, RequestHandler_1.postRequest)(`${ThyraProvider_1.MASSA_STATION_ACCOUNTS_URL}/${this._name}/sign`, {
775
789
  operation: data,
776
790
  batch: false,
777
791
  });
@@ -794,7 +808,7 @@ class ThyraAccount {
794
808
  */
795
809
  async buyRolls(amount, fee) {
796
810
  let buyRollsOpResponse = null;
797
- const url = `${ThyraProvider_1.THYRA_ACCOUNTS_URL}/${this._name}/rolls`;
811
+ const url = `${ThyraProvider_1.MASSA_STATION_ACCOUNTS_URL}/${this._name}/rolls`;
798
812
  const body = {
799
813
  fee: fee.toString(),
800
814
  amount: amount.toString(),
@@ -821,7 +835,7 @@ class ThyraAccount {
821
835
  */
822
836
  async sellRolls(amount, fee) {
823
837
  let sellRollsOpResponse = null;
824
- const url = `${ThyraProvider_1.THYRA_ACCOUNTS_URL}/${this._name}/rolls`;
838
+ const url = `${ThyraProvider_1.MASSA_STATION_ACCOUNTS_URL}/${this._name}/rolls`;
825
839
  const body = {
826
840
  fee: fee.toString(),
827
841
  amount: amount.toString(),
@@ -849,10 +863,129 @@ class ThyraAccount {
849
863
  sendTransaction(amount, recipientAddress, fee) {
850
864
  throw new Error('Method not implemented.');
851
865
  }
866
+ /**
867
+ * This method aims to interact with a smart contract deployed on the MASSA blockchain.
868
+ *
869
+ * @remarks
870
+ * If dryRun.dryRun is true, the method will dry run the smart contract call and return an
871
+ * IContractReadOperationResponse object which contains all the information about the dry run
872
+ * (state changes, gas used, etc.)
873
+ *
874
+ * @param contractAddress - The address of the smart contract.
875
+ * @param functionName - The name of the function to be called.
876
+ * @param parameter - The parameters as an Args object to be passed to the function.
877
+ * @param amount - The amount of MASSA coins to be sent to the block creator.
878
+ * @param dryRun - The dryRun object to be passed to the function.
879
+ *
880
+ * @returns if dryRun.dryRun is true, it returns an IContractReadOperationResponse object. Otherwise,
881
+ * it returns an ITransactionDetails object which contains the first event emitted by the contract.
882
+ * If the contract does not emit any event, it returns "Function called successfully but no event generated"
883
+ *
884
+ */
885
+ async callSC(contractAddress, functionName, parameter, amount, nonPersistentExecution = {
886
+ isNPE: false,
887
+ }) {
888
+ if (nonPersistentExecution?.isNPE) {
889
+ return this.nonPersistentCallSC(contractAddress, functionName, parameter, nonPersistentExecution);
890
+ }
891
+ // convert parameter to base64
892
+ const args = (0, argsToBase64_1.argsToBase64)(parameter);
893
+ let CallSCOpResponse = null;
894
+ const url = `${ThyraProvider_1.MASSA_STATION_URL}cmd/executeFunction`;
895
+ const body = {
896
+ nickname: this._name,
897
+ name: functionName,
898
+ at: contractAddress,
899
+ args: args,
900
+ coins: Number(amount),
901
+ };
902
+ try {
903
+ CallSCOpResponse = await (0, RequestHandler_1.postRequest)(url, body);
904
+ }
905
+ catch (ex) {
906
+ console.log(`Thyra account: error while interacting with smart contract: ${ex}`);
907
+ throw ex;
908
+ }
909
+ if (CallSCOpResponse.isError || CallSCOpResponse.error) {
910
+ throw CallSCOpResponse.error;
911
+ }
912
+ return CallSCOpResponse.result;
913
+ }
914
+ async getNodeUrlFromThyra(providerName) {
915
+ // get the node url from the thyra
916
+ let nodesResponse = null;
917
+ let node = '';
918
+ try {
919
+ nodesResponse = await (0, RequestHandler_1.getRequest)(`${ThyraProvider_1.MASSA_STATION_URL}massa/node`);
920
+ if (nodesResponse.isError || nodesResponse.error) {
921
+ throw nodesResponse.error.message;
922
+ }
923
+ // transform nodesResponse.result to a json and then get the "url" property
924
+ const nodes = nodesResponse.result;
925
+ node = nodes.url;
926
+ }
927
+ catch (ex) {
928
+ throw new Error(`Thyra nodes retrieval error: ${ex}`);
929
+ }
930
+ return node;
931
+ }
932
+ async nonPersistentCallSC(contractAddress, functionName, parameter, dryRun) {
933
+ const node = await this.getNodeUrlFromThyra(this._providerName);
934
+ // Gas amount check
935
+ if (!dryRun.maxGas) {
936
+ dryRun.maxGas = MAX_READ_BLOCK_GAS;
937
+ }
938
+ if (dryRun.maxGas > MAX_READ_BLOCK_GAS) {
939
+ throw new Error(`
940
+ The gas submitted ${dryRun.maxGas.toString()} exceeds the max. allowed block gas of
941
+ ${MAX_READ_BLOCK_GAS.toString()}
942
+ `);
943
+ }
944
+ // convert parameter to an array of numbers
945
+ const argumentArray = Array.from(parameter.serialize());
946
+ // setup the request body
947
+ const data = {
948
+ max_gas: Number(dryRun.maxGas),
949
+ target_address: contractAddress,
950
+ target_function: functionName,
951
+ parameter: argumentArray,
952
+ caller_address: this._address,
953
+ };
954
+ const body = [
955
+ {
956
+ jsonrpc: '2.0',
957
+ method: 'execute_read_only_call',
958
+ params: [[data]],
959
+ id: 0,
960
+ },
961
+ ];
962
+ // returns operation ids
963
+ let jsonRpcCallResult = [];
964
+ try {
965
+ let resp = await (0, RequestHandler_1.postRequest)(node, body);
966
+ if (resp.isError || resp.error) {
967
+ throw resp.error.message;
968
+ }
969
+ jsonRpcCallResult = resp.result;
970
+ }
971
+ catch (ex) {
972
+ throw new Error(`Thyra account: error while interacting with smart contract: ${ex}`);
973
+ }
974
+ if (jsonRpcCallResult.length <= 0) {
975
+ throw new Error(`Read operation bad response. No results array in json rpc response. Inspect smart contract`);
976
+ }
977
+ if (jsonRpcCallResult[0].result.Error) {
978
+ throw new Error(jsonRpcCallResult[0].result.Error);
979
+ }
980
+ return {
981
+ returnValue: jsonRpcCallResult[0].result[0].result.Ok,
982
+ info: jsonRpcCallResult[0],
983
+ };
984
+ }
852
985
  }
853
986
  exports.ThyraAccount = ThyraAccount;
854
987
 
855
- },{"./RequestHandler":9,"./ThyraProvider":12}],11:[function(require,module,exports){
988
+ },{"../utils/argsToBase64":13,"./RequestHandler":9,"./ThyraProvider":12}],11:[function(require,module,exports){
856
989
  "use strict";
857
990
  /**
858
991
  * This file defines a TypeScript class named ThyraDiscovery.
@@ -958,29 +1091,29 @@ class ThyraDiscovery extends events_1.EventEmitter {
958
1091
  }
959
1092
  exports.ThyraDiscovery = ThyraDiscovery;
960
1093
 
961
- },{"../utils/time":13,"./RequestHandler":9,"events":44}],12:[function(require,module,exports){
1094
+ },{"../utils/time":14,"./RequestHandler":9,"events":47}],12:[function(require,module,exports){
962
1095
  "use strict";
963
1096
 
964
1097
  Object.defineProperty(exports, "__esModule", {
965
1098
  value: true
966
1099
  });
967
- exports.ThyraProvider = exports.THYRA_PROVIDER_NAME = exports.THYRA_URL = exports.THYRA_IMPORT_ACCOUNTS_URL = exports.THYRA_ACCOUNTS_URL = void 0;
1100
+ exports.ThyraProvider = exports.THYRA_PROVIDER_NAME = exports.THYRA_IMPORT_ACCOUNTS_URL = exports.MASSA_STATION_ACCOUNTS_URL = exports.MASSA_STATION_URL = void 0;
968
1101
  const AccountDeletion_1 = require("../provider/AccountDeletion");
969
1102
  const AccountImport_1 = require("../provider/AccountImport");
970
1103
  const RequestHandler_1 = require("./RequestHandler");
971
1104
  const ThyraAccount_1 = require("./ThyraAccount");
972
1105
  /**
973
- * The Thyra accounts url
1106
+ * MassaStation url
974
1107
  */
975
- exports.THYRA_ACCOUNTS_URL = 'https://my.massa/thyra/plugin/massalabs/wallet/api/accounts';
1108
+ exports.MASSA_STATION_URL = 'https://my.massa/';
976
1109
  /**
977
- * Thyra's url for importing accounts
1110
+ * The Thyra accounts url
978
1111
  */
979
- exports.THYRA_IMPORT_ACCOUNTS_URL = `${exports.THYRA_ACCOUNTS_URL}/import/`;
1112
+ exports.MASSA_STATION_ACCOUNTS_URL = `${exports.MASSA_STATION_URL}thyra/plugin/massalabs/wallet/api/accounts`;
980
1113
  /**
981
- * MassaStation url
1114
+ * Thyra's url for importing accounts
982
1115
  */
983
- exports.THYRA_URL = 'https://my.massa/';
1116
+ exports.THYRA_IMPORT_ACCOUNTS_URL = `${exports.MASSA_STATION_ACCOUNTS_URL}/import/`;
984
1117
  /**
985
1118
  * Thyra's wallet provider name
986
1119
  */
@@ -1016,7 +1149,7 @@ class ThyraProvider {
1016
1149
  async accounts() {
1017
1150
  let thyraAccountsResponse = null;
1018
1151
  try {
1019
- thyraAccountsResponse = await (0, RequestHandler_1.getRequest)(exports.THYRA_ACCOUNTS_URL);
1152
+ thyraAccountsResponse = await (0, RequestHandler_1.getRequest)(exports.MASSA_STATION_ACCOUNTS_URL);
1020
1153
  } catch (ex) {
1021
1154
  console.error(`Thyra accounts retrieval error`);
1022
1155
  throw ex;
@@ -1046,7 +1179,7 @@ class ThyraProvider {
1046
1179
  };
1047
1180
  let thyraAccountsResponse = null;
1048
1181
  try {
1049
- thyraAccountsResponse = await (0, RequestHandler_1.putRequest)(exports.THYRA_ACCOUNTS_URL, accountImportRequest);
1182
+ thyraAccountsResponse = await (0, RequestHandler_1.putRequest)(exports.MASSA_STATION_ACCOUNTS_URL, accountImportRequest);
1050
1183
  } catch (ex) {
1051
1184
  console.log(`Thyra accounts retrieval error: ${ex}`);
1052
1185
  throw ex;
@@ -1069,7 +1202,7 @@ class ThyraProvider {
1069
1202
  // get all accounts
1070
1203
  let allAccounts = null;
1071
1204
  try {
1072
- allAccounts = await (0, RequestHandler_1.getRequest)(exports.THYRA_ACCOUNTS_URL);
1205
+ allAccounts = await (0, RequestHandler_1.getRequest)(exports.MASSA_STATION_ACCOUNTS_URL);
1073
1206
  } catch (ex) {
1074
1207
  console.log(`Thyra accounts retrieval error: ${ex}`);
1075
1208
  throw ex;
@@ -1082,7 +1215,7 @@ class ThyraProvider {
1082
1215
  // delete the account in question
1083
1216
  let thyraAccountsResponse = null;
1084
1217
  try {
1085
- thyraAccountsResponse = await (0, RequestHandler_1.deleteRequest)(`${exports.THYRA_ACCOUNTS_URL}/${accountToDelete.nickname}`);
1218
+ thyraAccountsResponse = await (0, RequestHandler_1.deleteRequest)(`${exports.MASSA_STATION_ACCOUNTS_URL}/${accountToDelete.nickname}`);
1086
1219
  } catch (ex) {
1087
1220
  console.log(`Thyra accounts deletion error`, ex);
1088
1221
  return {
@@ -1107,7 +1240,7 @@ class ThyraProvider {
1107
1240
  async getNodesUrls() {
1108
1241
  let nodesResponse = null;
1109
1242
  try {
1110
- nodesResponse = await (0, RequestHandler_1.getRequest)(`${exports.THYRA_URL}massa/node`);
1243
+ nodesResponse = await (0, RequestHandler_1.getRequest)(`${exports.MASSA_STATION_URL}massa/node`);
1111
1244
  if (nodesResponse.isError || nodesResponse.error) {
1112
1245
  throw nodesResponse.error.message;
1113
1246
  }
@@ -1126,9 +1259,9 @@ class ThyraProvider {
1126
1259
  */
1127
1260
  async generateNewAccount(name) {
1128
1261
  let thyraAccountsResponse = null;
1129
- console.log(exports.THYRA_ACCOUNTS_URL + '/' + name);
1262
+ console.log(exports.MASSA_STATION_ACCOUNTS_URL + '/' + name);
1130
1263
  try {
1131
- thyraAccountsResponse = await (0, RequestHandler_1.postRequest)(exports.THYRA_ACCOUNTS_URL + '/' + name, {});
1264
+ thyraAccountsResponse = await (0, RequestHandler_1.postRequest)(exports.MASSA_STATION_ACCOUNTS_URL + '/' + name, {});
1132
1265
  if (thyraAccountsResponse.isError || thyraAccountsResponse.error) {
1133
1266
  throw thyraAccountsResponse.error.message;
1134
1267
  }
@@ -1145,6 +1278,24 @@ class ThyraProvider {
1145
1278
  exports.ThyraProvider = ThyraProvider;
1146
1279
 
1147
1280
  },{"../provider/AccountDeletion":5,"../provider/AccountImport":6,"./RequestHandler":9,"./ThyraAccount":10}],13:[function(require,module,exports){
1281
+ (function (Buffer){(function (){
1282
+ "use strict";
1283
+ Object.defineProperty(exports, "__esModule", { value: true });
1284
+ exports.argsToBase64 = void 0;
1285
+ /**
1286
+ * Converts an Args object to a base64 string
1287
+ *
1288
+ * @param arg - The argument to convert to base64
1289
+ * @returns The base64 string
1290
+ */
1291
+ function argsToBase64(arg) {
1292
+ const array = arg.serialize();
1293
+ return Buffer.from(array).toString('base64');
1294
+ }
1295
+ exports.argsToBase64 = argsToBase64;
1296
+
1297
+ }).call(this)}).call(this,require("buffer").Buffer)
1298
+ },{"buffer":46}],14:[function(require,module,exports){
1148
1299
  "use strict";
1149
1300
  /**
1150
1301
  * This file defines a TypeScript module with various time-related Typescript methods.
@@ -1265,9 +1416,9 @@ async function withTimeoutRejection(promise, timeoutMs) {
1265
1416
  }
1266
1417
  exports.withTimeoutRejection = withTimeoutRejection;
1267
1418
 
1268
- },{}],14:[function(require,module,exports){
1419
+ },{}],15:[function(require,module,exports){
1269
1420
  module.exports = require('./lib/axios');
1270
- },{"./lib/axios":16}],15:[function(require,module,exports){
1421
+ },{"./lib/axios":17}],16:[function(require,module,exports){
1271
1422
  'use strict';
1272
1423
 
1273
1424
  var utils = require('./../utils');
@@ -1481,7 +1632,7 @@ module.exports = function xhrAdapter(config) {
1481
1632
  });
1482
1633
  };
1483
1634
 
1484
- },{"../cancel/Cancel":17,"../core/buildFullPath":22,"../core/createError":23,"../defaults/transitional":30,"./../core/settle":27,"./../helpers/buildURL":33,"./../helpers/cookies":35,"./../helpers/isURLSameOrigin":38,"./../helpers/parseHeaders":40,"./../utils":43}],16:[function(require,module,exports){
1635
+ },{"../cancel/Cancel":18,"../core/buildFullPath":23,"../core/createError":24,"../defaults/transitional":31,"./../core/settle":28,"./../helpers/buildURL":34,"./../helpers/cookies":36,"./../helpers/isURLSameOrigin":39,"./../helpers/parseHeaders":41,"./../utils":44}],17:[function(require,module,exports){
1485
1636
  'use strict';
1486
1637
 
1487
1638
  var utils = require('./utils');
@@ -1538,7 +1689,7 @@ module.exports = axios;
1538
1689
  // Allow use of default import syntax in TypeScript
1539
1690
  module.exports.default = axios;
1540
1691
 
1541
- },{"./cancel/Cancel":17,"./cancel/CancelToken":18,"./cancel/isCancel":19,"./core/Axios":20,"./core/mergeConfig":26,"./defaults":29,"./env/data":31,"./helpers/bind":32,"./helpers/isAxiosError":37,"./helpers/spread":41,"./utils":43}],17:[function(require,module,exports){
1692
+ },{"./cancel/Cancel":18,"./cancel/CancelToken":19,"./cancel/isCancel":20,"./core/Axios":21,"./core/mergeConfig":27,"./defaults":30,"./env/data":32,"./helpers/bind":33,"./helpers/isAxiosError":38,"./helpers/spread":42,"./utils":44}],18:[function(require,module,exports){
1542
1693
  'use strict';
1543
1694
 
1544
1695
  /**
@@ -1559,7 +1710,7 @@ Cancel.prototype.__CANCEL__ = true;
1559
1710
 
1560
1711
  module.exports = Cancel;
1561
1712
 
1562
- },{}],18:[function(require,module,exports){
1713
+ },{}],19:[function(require,module,exports){
1563
1714
  'use strict';
1564
1715
 
1565
1716
  var Cancel = require('./Cancel');
@@ -1680,14 +1831,14 @@ CancelToken.source = function source() {
1680
1831
 
1681
1832
  module.exports = CancelToken;
1682
1833
 
1683
- },{"./Cancel":17}],19:[function(require,module,exports){
1834
+ },{"./Cancel":18}],20:[function(require,module,exports){
1684
1835
  'use strict';
1685
1836
 
1686
1837
  module.exports = function isCancel(value) {
1687
1838
  return !!(value && value.__CANCEL__);
1688
1839
  };
1689
1840
 
1690
- },{}],20:[function(require,module,exports){
1841
+ },{}],21:[function(require,module,exports){
1691
1842
  'use strict';
1692
1843
 
1693
1844
  var utils = require('./../utils');
@@ -1837,7 +1988,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1837
1988
 
1838
1989
  module.exports = Axios;
1839
1990
 
1840
- },{"../helpers/buildURL":33,"../helpers/validator":42,"./../utils":43,"./InterceptorManager":21,"./dispatchRequest":24,"./mergeConfig":26}],21:[function(require,module,exports){
1991
+ },{"../helpers/buildURL":34,"../helpers/validator":43,"./../utils":44,"./InterceptorManager":22,"./dispatchRequest":25,"./mergeConfig":27}],22:[function(require,module,exports){
1841
1992
  'use strict';
1842
1993
 
1843
1994
  var utils = require('./../utils');
@@ -1893,7 +2044,7 @@ InterceptorManager.prototype.forEach = function forEach(fn) {
1893
2044
 
1894
2045
  module.exports = InterceptorManager;
1895
2046
 
1896
- },{"./../utils":43}],22:[function(require,module,exports){
2047
+ },{"./../utils":44}],23:[function(require,module,exports){
1897
2048
  'use strict';
1898
2049
 
1899
2050
  var isAbsoluteURL = require('../helpers/isAbsoluteURL');
@@ -1915,7 +2066,7 @@ module.exports = function buildFullPath(baseURL, requestedURL) {
1915
2066
  return requestedURL;
1916
2067
  };
1917
2068
 
1918
- },{"../helpers/combineURLs":34,"../helpers/isAbsoluteURL":36}],23:[function(require,module,exports){
2069
+ },{"../helpers/combineURLs":35,"../helpers/isAbsoluteURL":37}],24:[function(require,module,exports){
1919
2070
  'use strict';
1920
2071
 
1921
2072
  var enhanceError = require('./enhanceError');
@@ -1935,7 +2086,7 @@ module.exports = function createError(message, config, code, request, response)
1935
2086
  return enhanceError(error, config, code, request, response);
1936
2087
  };
1937
2088
 
1938
- },{"./enhanceError":25}],24:[function(require,module,exports){
2089
+ },{"./enhanceError":26}],25:[function(require,module,exports){
1939
2090
  'use strict';
1940
2091
 
1941
2092
  var utils = require('./../utils');
@@ -2024,7 +2175,7 @@ module.exports = function dispatchRequest(config) {
2024
2175
  });
2025
2176
  };
2026
2177
 
2027
- },{"../cancel/Cancel":17,"../cancel/isCancel":19,"../defaults":29,"./../utils":43,"./transformData":28}],25:[function(require,module,exports){
2178
+ },{"../cancel/Cancel":18,"../cancel/isCancel":20,"../defaults":30,"./../utils":44,"./transformData":29}],26:[function(require,module,exports){
2028
2179
  'use strict';
2029
2180
 
2030
2181
  /**
@@ -2069,7 +2220,7 @@ module.exports = function enhanceError(error, config, code, request, response) {
2069
2220
  return error;
2070
2221
  };
2071
2222
 
2072
- },{}],26:[function(require,module,exports){
2223
+ },{}],27:[function(require,module,exports){
2073
2224
  'use strict';
2074
2225
 
2075
2226
  var utils = require('../utils');
@@ -2170,7 +2321,7 @@ module.exports = function mergeConfig(config1, config2) {
2170
2321
  return config;
2171
2322
  };
2172
2323
 
2173
- },{"../utils":43}],27:[function(require,module,exports){
2324
+ },{"../utils":44}],28:[function(require,module,exports){
2174
2325
  'use strict';
2175
2326
 
2176
2327
  var createError = require('./createError');
@@ -2197,7 +2348,7 @@ module.exports = function settle(resolve, reject, response) {
2197
2348
  }
2198
2349
  };
2199
2350
 
2200
- },{"./createError":23}],28:[function(require,module,exports){
2351
+ },{"./createError":24}],29:[function(require,module,exports){
2201
2352
  'use strict';
2202
2353
 
2203
2354
  var utils = require('./../utils');
@@ -2221,7 +2372,7 @@ module.exports = function transformData(data, headers, fns) {
2221
2372
  return data;
2222
2373
  };
2223
2374
 
2224
- },{"../defaults":29,"./../utils":43}],29:[function(require,module,exports){
2375
+ },{"../defaults":30,"./../utils":44}],30:[function(require,module,exports){
2225
2376
  (function (process){(function (){
2226
2377
  'use strict';
2227
2378
 
@@ -2356,7 +2507,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2356
2507
  module.exports = defaults;
2357
2508
 
2358
2509
  }).call(this)}).call(this,require('_process'))
2359
- },{"../adapters/http":15,"../adapters/xhr":15,"../core/enhanceError":25,"../helpers/normalizeHeaderName":39,"../utils":43,"./transitional":30,"_process":45}],30:[function(require,module,exports){
2510
+ },{"../adapters/http":16,"../adapters/xhr":16,"../core/enhanceError":26,"../helpers/normalizeHeaderName":40,"../utils":44,"./transitional":31,"_process":49}],31:[function(require,module,exports){
2360
2511
  'use strict';
2361
2512
 
2362
2513
  module.exports = {
@@ -2365,11 +2516,11 @@ module.exports = {
2365
2516
  clarifyTimeoutError: false
2366
2517
  };
2367
2518
 
2368
- },{}],31:[function(require,module,exports){
2519
+ },{}],32:[function(require,module,exports){
2369
2520
  module.exports = {
2370
2521
  "version": "0.26.1"
2371
2522
  };
2372
- },{}],32:[function(require,module,exports){
2523
+ },{}],33:[function(require,module,exports){
2373
2524
  'use strict';
2374
2525
 
2375
2526
  module.exports = function bind(fn, thisArg) {
@@ -2382,7 +2533,7 @@ module.exports = function bind(fn, thisArg) {
2382
2533
  };
2383
2534
  };
2384
2535
 
2385
- },{}],33:[function(require,module,exports){
2536
+ },{}],34:[function(require,module,exports){
2386
2537
  'use strict';
2387
2538
 
2388
2539
  var utils = require('./../utils');
@@ -2454,7 +2605,7 @@ module.exports = function buildURL(url, params, paramsSerializer) {
2454
2605
  return url;
2455
2606
  };
2456
2607
 
2457
- },{"./../utils":43}],34:[function(require,module,exports){
2608
+ },{"./../utils":44}],35:[function(require,module,exports){
2458
2609
  'use strict';
2459
2610
 
2460
2611
  /**
@@ -2470,7 +2621,7 @@ module.exports = function combineURLs(baseURL, relativeURL) {
2470
2621
  : baseURL;
2471
2622
  };
2472
2623
 
2473
- },{}],35:[function(require,module,exports){
2624
+ },{}],36:[function(require,module,exports){
2474
2625
  'use strict';
2475
2626
 
2476
2627
  var utils = require('./../utils');
@@ -2525,7 +2676,7 @@ module.exports = (
2525
2676
  })()
2526
2677
  );
2527
2678
 
2528
- },{"./../utils":43}],36:[function(require,module,exports){
2679
+ },{"./../utils":44}],37:[function(require,module,exports){
2529
2680
  'use strict';
2530
2681
 
2531
2682
  /**
@@ -2541,7 +2692,7 @@ module.exports = function isAbsoluteURL(url) {
2541
2692
  return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2542
2693
  };
2543
2694
 
2544
- },{}],37:[function(require,module,exports){
2695
+ },{}],38:[function(require,module,exports){
2545
2696
  'use strict';
2546
2697
 
2547
2698
  var utils = require('./../utils');
@@ -2556,7 +2707,7 @@ module.exports = function isAxiosError(payload) {
2556
2707
  return utils.isObject(payload) && (payload.isAxiosError === true);
2557
2708
  };
2558
2709
 
2559
- },{"./../utils":43}],38:[function(require,module,exports){
2710
+ },{"./../utils":44}],39:[function(require,module,exports){
2560
2711
  'use strict';
2561
2712
 
2562
2713
  var utils = require('./../utils');
@@ -2626,7 +2777,7 @@ module.exports = (
2626
2777
  })()
2627
2778
  );
2628
2779
 
2629
- },{"./../utils":43}],39:[function(require,module,exports){
2780
+ },{"./../utils":44}],40:[function(require,module,exports){
2630
2781
  'use strict';
2631
2782
 
2632
2783
  var utils = require('../utils');
@@ -2640,7 +2791,7 @@ module.exports = function normalizeHeaderName(headers, normalizedName) {
2640
2791
  });
2641
2792
  };
2642
2793
 
2643
- },{"../utils":43}],40:[function(require,module,exports){
2794
+ },{"../utils":44}],41:[function(require,module,exports){
2644
2795
  'use strict';
2645
2796
 
2646
2797
  var utils = require('./../utils');
@@ -2695,7 +2846,7 @@ module.exports = function parseHeaders(headers) {
2695
2846
  return parsed;
2696
2847
  };
2697
2848
 
2698
- },{"./../utils":43}],41:[function(require,module,exports){
2849
+ },{"./../utils":44}],42:[function(require,module,exports){
2699
2850
  'use strict';
2700
2851
 
2701
2852
  /**
@@ -2724,7 +2875,7 @@ module.exports = function spread(callback) {
2724
2875
  };
2725
2876
  };
2726
2877
 
2727
- },{}],42:[function(require,module,exports){
2878
+ },{}],43:[function(require,module,exports){
2728
2879
  'use strict';
2729
2880
 
2730
2881
  var VERSION = require('../env/data').version;
@@ -2808,7 +2959,7 @@ module.exports = {
2808
2959
  validators: validators
2809
2960
  };
2810
2961
 
2811
- },{"../env/data":31}],43:[function(require,module,exports){
2962
+ },{"../env/data":32}],44:[function(require,module,exports){
2812
2963
  'use strict';
2813
2964
 
2814
2965
  var bind = require('./helpers/bind');
@@ -3159,184 +3310,2117 @@ module.exports = {
3159
3310
  stripBOM: stripBOM
3160
3311
  };
3161
3312
 
3162
- },{"./helpers/bind":32}],44:[function(require,module,exports){
3163
- // Copyright Joyent, Inc. and other Node contributors.
3164
- //
3165
- // Permission is hereby granted, free of charge, to any person obtaining a
3166
- // copy of this software and associated documentation files (the
3167
- // "Software"), to deal in the Software without restriction, including
3168
- // without limitation the rights to use, copy, modify, merge, publish,
3169
- // distribute, sublicense, and/or sell copies of the Software, and to permit
3170
- // persons to whom the Software is furnished to do so, subject to the
3171
- // following conditions:
3172
- //
3173
- // The above copyright notice and this permission notice shall be included
3174
- // in all copies or substantial portions of the Software.
3175
- //
3176
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
3177
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3178
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
3179
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
3180
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
3181
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
3182
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
3313
+ },{"./helpers/bind":33}],45:[function(require,module,exports){
3314
+ 'use strict'
3183
3315
 
3184
- 'use strict';
3316
+ exports.byteLength = byteLength
3317
+ exports.toByteArray = toByteArray
3318
+ exports.fromByteArray = fromByteArray
3185
3319
 
3186
- var R = typeof Reflect === 'object' ? Reflect : null
3187
- var ReflectApply = R && typeof R.apply === 'function'
3188
- ? R.apply
3189
- : function ReflectApply(target, receiver, args) {
3190
- return Function.prototype.apply.call(target, receiver, args);
3320
+ var lookup = []
3321
+ var revLookup = []
3322
+ var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
3323
+
3324
+ var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
3325
+ for (var i = 0, len = code.length; i < len; ++i) {
3326
+ lookup[i] = code[i]
3327
+ revLookup[code.charCodeAt(i)] = i
3328
+ }
3329
+
3330
+ // Support decoding URL-safe base64 strings, as Node.js does.
3331
+ // See: https://en.wikipedia.org/wiki/Base64#URL_applications
3332
+ revLookup['-'.charCodeAt(0)] = 62
3333
+ revLookup['_'.charCodeAt(0)] = 63
3334
+
3335
+ function getLens (b64) {
3336
+ var len = b64.length
3337
+
3338
+ if (len % 4 > 0) {
3339
+ throw new Error('Invalid string. Length must be a multiple of 4')
3191
3340
  }
3192
3341
 
3193
- var ReflectOwnKeys
3194
- if (R && typeof R.ownKeys === 'function') {
3195
- ReflectOwnKeys = R.ownKeys
3196
- } else if (Object.getOwnPropertySymbols) {
3197
- ReflectOwnKeys = function ReflectOwnKeys(target) {
3198
- return Object.getOwnPropertyNames(target)
3199
- .concat(Object.getOwnPropertySymbols(target));
3200
- };
3201
- } else {
3202
- ReflectOwnKeys = function ReflectOwnKeys(target) {
3203
- return Object.getOwnPropertyNames(target);
3204
- };
3342
+ // Trim off extra bytes after placeholder bytes are found
3343
+ // See: https://github.com/beatgammit/base64-js/issues/42
3344
+ var validLen = b64.indexOf('=')
3345
+ if (validLen === -1) validLen = len
3346
+
3347
+ var placeHoldersLen = validLen === len
3348
+ ? 0
3349
+ : 4 - (validLen % 4)
3350
+
3351
+ return [validLen, placeHoldersLen]
3205
3352
  }
3206
3353
 
3207
- function ProcessEmitWarning(warning) {
3208
- if (console && console.warn) console.warn(warning);
3354
+ // base64 is 4/3 + up to two characters of the original data
3355
+ function byteLength (b64) {
3356
+ var lens = getLens(b64)
3357
+ var validLen = lens[0]
3358
+ var placeHoldersLen = lens[1]
3359
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
3209
3360
  }
3210
3361
 
3211
- var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
3212
- return value !== value;
3362
+ function _byteLength (b64, validLen, placeHoldersLen) {
3363
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
3213
3364
  }
3214
3365
 
3215
- function EventEmitter() {
3216
- EventEmitter.init.call(this);
3366
+ function toByteArray (b64) {
3367
+ var tmp
3368
+ var lens = getLens(b64)
3369
+ var validLen = lens[0]
3370
+ var placeHoldersLen = lens[1]
3371
+
3372
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
3373
+
3374
+ var curByte = 0
3375
+
3376
+ // if there are placeholders, only get up to the last complete 4 chars
3377
+ var len = placeHoldersLen > 0
3378
+ ? validLen - 4
3379
+ : validLen
3380
+
3381
+ var i
3382
+ for (i = 0; i < len; i += 4) {
3383
+ tmp =
3384
+ (revLookup[b64.charCodeAt(i)] << 18) |
3385
+ (revLookup[b64.charCodeAt(i + 1)] << 12) |
3386
+ (revLookup[b64.charCodeAt(i + 2)] << 6) |
3387
+ revLookup[b64.charCodeAt(i + 3)]
3388
+ arr[curByte++] = (tmp >> 16) & 0xFF
3389
+ arr[curByte++] = (tmp >> 8) & 0xFF
3390
+ arr[curByte++] = tmp & 0xFF
3391
+ }
3392
+
3393
+ if (placeHoldersLen === 2) {
3394
+ tmp =
3395
+ (revLookup[b64.charCodeAt(i)] << 2) |
3396
+ (revLookup[b64.charCodeAt(i + 1)] >> 4)
3397
+ arr[curByte++] = tmp & 0xFF
3398
+ }
3399
+
3400
+ if (placeHoldersLen === 1) {
3401
+ tmp =
3402
+ (revLookup[b64.charCodeAt(i)] << 10) |
3403
+ (revLookup[b64.charCodeAt(i + 1)] << 4) |
3404
+ (revLookup[b64.charCodeAt(i + 2)] >> 2)
3405
+ arr[curByte++] = (tmp >> 8) & 0xFF
3406
+ arr[curByte++] = tmp & 0xFF
3407
+ }
3408
+
3409
+ return arr
3217
3410
  }
3218
- module.exports = EventEmitter;
3219
- module.exports.once = once;
3220
3411
 
3221
- // Backwards-compat with node 0.10.x
3222
- EventEmitter.EventEmitter = EventEmitter;
3412
+ function tripletToBase64 (num) {
3413
+ return lookup[num >> 18 & 0x3F] +
3414
+ lookup[num >> 12 & 0x3F] +
3415
+ lookup[num >> 6 & 0x3F] +
3416
+ lookup[num & 0x3F]
3417
+ }
3223
3418
 
3224
- EventEmitter.prototype._events = undefined;
3225
- EventEmitter.prototype._eventsCount = 0;
3226
- EventEmitter.prototype._maxListeners = undefined;
3419
+ function encodeChunk (uint8, start, end) {
3420
+ var tmp
3421
+ var output = []
3422
+ for (var i = start; i < end; i += 3) {
3423
+ tmp =
3424
+ ((uint8[i] << 16) & 0xFF0000) +
3425
+ ((uint8[i + 1] << 8) & 0xFF00) +
3426
+ (uint8[i + 2] & 0xFF)
3427
+ output.push(tripletToBase64(tmp))
3428
+ }
3429
+ return output.join('')
3430
+ }
3227
3431
 
3228
- // By default EventEmitters will print a warning if more than 10 listeners are
3229
- // added to it. This is a useful default which helps finding memory leaks.
3230
- var defaultMaxListeners = 10;
3432
+ function fromByteArray (uint8) {
3433
+ var tmp
3434
+ var len = uint8.length
3435
+ var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
3436
+ var parts = []
3437
+ var maxChunkLength = 16383 // must be multiple of 3
3231
3438
 
3232
- function checkListener(listener) {
3233
- if (typeof listener !== 'function') {
3234
- throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
3439
+ // go through the array every three bytes, we'll deal with trailing stuff later
3440
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
3441
+ parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
3442
+ }
3443
+
3444
+ // pad the end with zeros, but make sure to not forget the extra bytes
3445
+ if (extraBytes === 1) {
3446
+ tmp = uint8[len - 1]
3447
+ parts.push(
3448
+ lookup[tmp >> 2] +
3449
+ lookup[(tmp << 4) & 0x3F] +
3450
+ '=='
3451
+ )
3452
+ } else if (extraBytes === 2) {
3453
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1]
3454
+ parts.push(
3455
+ lookup[tmp >> 10] +
3456
+ lookup[(tmp >> 4) & 0x3F] +
3457
+ lookup[(tmp << 2) & 0x3F] +
3458
+ '='
3459
+ )
3235
3460
  }
3461
+
3462
+ return parts.join('')
3236
3463
  }
3237
3464
 
3238
- Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
3465
+ },{}],46:[function(require,module,exports){
3466
+ (function (Buffer){(function (){
3467
+ /*!
3468
+ * The buffer module from node.js, for the browser.
3469
+ *
3470
+ * @author Feross Aboukhadijeh <https://feross.org>
3471
+ * @license MIT
3472
+ */
3473
+ /* eslint-disable no-proto */
3474
+
3475
+ 'use strict'
3476
+
3477
+ var base64 = require('base64-js')
3478
+ var ieee754 = require('ieee754')
3479
+
3480
+ exports.Buffer = Buffer
3481
+ exports.SlowBuffer = SlowBuffer
3482
+ exports.INSPECT_MAX_BYTES = 50
3483
+
3484
+ var K_MAX_LENGTH = 0x7fffffff
3485
+ exports.kMaxLength = K_MAX_LENGTH
3486
+
3487
+ /**
3488
+ * If `Buffer.TYPED_ARRAY_SUPPORT`:
3489
+ * === true Use Uint8Array implementation (fastest)
3490
+ * === false Print warning and recommend using `buffer` v4.x which has an Object
3491
+ * implementation (most compatible, even IE6)
3492
+ *
3493
+ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
3494
+ * Opera 11.6+, iOS 4.2+.
3495
+ *
3496
+ * We report that the browser does not support typed arrays if the are not subclassable
3497
+ * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
3498
+ * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
3499
+ * for __proto__ and has a buggy typed array implementation.
3500
+ */
3501
+ Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
3502
+
3503
+ if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
3504
+ typeof console.error === 'function') {
3505
+ console.error(
3506
+ 'This browser lacks typed array (Uint8Array) support which is required by ' +
3507
+ '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
3508
+ )
3509
+ }
3510
+
3511
+ function typedArraySupport () {
3512
+ // Can typed array instances can be augmented?
3513
+ try {
3514
+ var arr = new Uint8Array(1)
3515
+ arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
3516
+ return arr.foo() === 42
3517
+ } catch (e) {
3518
+ return false
3519
+ }
3520
+ }
3521
+
3522
+ Object.defineProperty(Buffer.prototype, 'parent', {
3239
3523
  enumerable: true,
3240
- get: function() {
3241
- return defaultMaxListeners;
3242
- },
3243
- set: function(arg) {
3244
- if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
3245
- throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
3246
- }
3247
- defaultMaxListeners = arg;
3524
+ get: function () {
3525
+ if (!Buffer.isBuffer(this)) return undefined
3526
+ return this.buffer
3248
3527
  }
3249
- });
3528
+ })
3250
3529
 
3251
- EventEmitter.init = function() {
3530
+ Object.defineProperty(Buffer.prototype, 'offset', {
3531
+ enumerable: true,
3532
+ get: function () {
3533
+ if (!Buffer.isBuffer(this)) return undefined
3534
+ return this.byteOffset
3535
+ }
3536
+ })
3252
3537
 
3253
- if (this._events === undefined ||
3254
- this._events === Object.getPrototypeOf(this)._events) {
3255
- this._events = Object.create(null);
3256
- this._eventsCount = 0;
3538
+ function createBuffer (length) {
3539
+ if (length > K_MAX_LENGTH) {
3540
+ throw new RangeError('The value "' + length + '" is invalid for option "size"')
3257
3541
  }
3542
+ // Return an augmented `Uint8Array` instance
3543
+ var buf = new Uint8Array(length)
3544
+ buf.__proto__ = Buffer.prototype
3545
+ return buf
3546
+ }
3258
3547
 
3259
- this._maxListeners = this._maxListeners || undefined;
3260
- };
3548
+ /**
3549
+ * The Buffer constructor returns instances of `Uint8Array` that have their
3550
+ * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
3551
+ * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
3552
+ * and the `Uint8Array` methods. Square bracket notation works as expected -- it
3553
+ * returns a single octet.
3554
+ *
3555
+ * The `Uint8Array` prototype remains unmodified.
3556
+ */
3261
3557
 
3262
- // Obviously not all Emitters should be limited to 10. This function allows
3263
- // that to be increased. Set to zero for unlimited.
3264
- EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
3265
- if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
3266
- throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
3558
+ function Buffer (arg, encodingOrOffset, length) {
3559
+ // Common case.
3560
+ if (typeof arg === 'number') {
3561
+ if (typeof encodingOrOffset === 'string') {
3562
+ throw new TypeError(
3563
+ 'The "string" argument must be of type string. Received type number'
3564
+ )
3565
+ }
3566
+ return allocUnsafe(arg)
3267
3567
  }
3268
- this._maxListeners = n;
3269
- return this;
3270
- };
3568
+ return from(arg, encodingOrOffset, length)
3569
+ }
3271
3570
 
3272
- function _getMaxListeners(that) {
3273
- if (that._maxListeners === undefined)
3274
- return EventEmitter.defaultMaxListeners;
3275
- return that._maxListeners;
3571
+ // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
3572
+ if (typeof Symbol !== 'undefined' && Symbol.species != null &&
3573
+ Buffer[Symbol.species] === Buffer) {
3574
+ Object.defineProperty(Buffer, Symbol.species, {
3575
+ value: null,
3576
+ configurable: true,
3577
+ enumerable: false,
3578
+ writable: false
3579
+ })
3276
3580
  }
3277
3581
 
3278
- EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
3279
- return _getMaxListeners(this);
3280
- };
3582
+ Buffer.poolSize = 8192 // not used by this implementation
3281
3583
 
3282
- EventEmitter.prototype.emit = function emit(type) {
3283
- var args = [];
3284
- for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
3285
- var doError = (type === 'error');
3584
+ function from (value, encodingOrOffset, length) {
3585
+ if (typeof value === 'string') {
3586
+ return fromString(value, encodingOrOffset)
3587
+ }
3286
3588
 
3287
- var events = this._events;
3288
- if (events !== undefined)
3289
- doError = (doError && events.error === undefined);
3290
- else if (!doError)
3291
- return false;
3589
+ if (ArrayBuffer.isView(value)) {
3590
+ return fromArrayLike(value)
3591
+ }
3292
3592
 
3293
- // If there is no 'error' event listener then throw.
3294
- if (doError) {
3295
- var er;
3296
- if (args.length > 0)
3297
- er = args[0];
3298
- if (er instanceof Error) {
3299
- // Note: The comments on the `throw` lines are intentional, they show
3300
- // up in Node's output if this results in an unhandled exception.
3301
- throw er; // Unhandled 'error' event
3302
- }
3303
- // At least give some kind of context to the user
3304
- var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
3305
- err.context = er;
3306
- throw err; // Unhandled 'error' event
3593
+ if (value == null) {
3594
+ throw TypeError(
3595
+ 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
3596
+ 'or Array-like Object. Received type ' + (typeof value)
3597
+ )
3307
3598
  }
3308
3599
 
3309
- var handler = events[type];
3600
+ if (isInstance(value, ArrayBuffer) ||
3601
+ (value && isInstance(value.buffer, ArrayBuffer))) {
3602
+ return fromArrayBuffer(value, encodingOrOffset, length)
3603
+ }
3310
3604
 
3311
- if (handler === undefined)
3312
- return false;
3605
+ if (typeof value === 'number') {
3606
+ throw new TypeError(
3607
+ 'The "value" argument must not be of type number. Received type number'
3608
+ )
3609
+ }
3313
3610
 
3314
- if (typeof handler === 'function') {
3315
- ReflectApply(handler, this, args);
3316
- } else {
3317
- var len = handler.length;
3318
- var listeners = arrayClone(handler, len);
3319
- for (var i = 0; i < len; ++i)
3320
- ReflectApply(listeners[i], this, args);
3611
+ var valueOf = value.valueOf && value.valueOf()
3612
+ if (valueOf != null && valueOf !== value) {
3613
+ return Buffer.from(valueOf, encodingOrOffset, length)
3321
3614
  }
3322
3615
 
3323
- return true;
3324
- };
3616
+ var b = fromObject(value)
3617
+ if (b) return b
3325
3618
 
3326
- function _addListener(target, type, listener, prepend) {
3327
- var m;
3328
- var events;
3329
- var existing;
3619
+ if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
3620
+ typeof value[Symbol.toPrimitive] === 'function') {
3621
+ return Buffer.from(
3622
+ value[Symbol.toPrimitive]('string'), encodingOrOffset, length
3623
+ )
3624
+ }
3330
3625
 
3331
- checkListener(listener);
3626
+ throw new TypeError(
3627
+ 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
3628
+ 'or Array-like Object. Received type ' + (typeof value)
3629
+ )
3630
+ }
3332
3631
 
3333
- events = target._events;
3334
- if (events === undefined) {
3335
- events = target._events = Object.create(null);
3336
- target._eventsCount = 0;
3337
- } else {
3338
- // To avoid recursion in the case that type === "newListener"! Before
3339
- // adding it to the listeners, first emit "newListener".
3632
+ /**
3633
+ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
3634
+ * if value is a number.
3635
+ * Buffer.from(str[, encoding])
3636
+ * Buffer.from(array)
3637
+ * Buffer.from(buffer)
3638
+ * Buffer.from(arrayBuffer[, byteOffset[, length]])
3639
+ **/
3640
+ Buffer.from = function (value, encodingOrOffset, length) {
3641
+ return from(value, encodingOrOffset, length)
3642
+ }
3643
+
3644
+ // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
3645
+ // https://github.com/feross/buffer/pull/148
3646
+ Buffer.prototype.__proto__ = Uint8Array.prototype
3647
+ Buffer.__proto__ = Uint8Array
3648
+
3649
+ function assertSize (size) {
3650
+ if (typeof size !== 'number') {
3651
+ throw new TypeError('"size" argument must be of type number')
3652
+ } else if (size < 0) {
3653
+ throw new RangeError('The value "' + size + '" is invalid for option "size"')
3654
+ }
3655
+ }
3656
+
3657
+ function alloc (size, fill, encoding) {
3658
+ assertSize(size)
3659
+ if (size <= 0) {
3660
+ return createBuffer(size)
3661
+ }
3662
+ if (fill !== undefined) {
3663
+ // Only pay attention to encoding if it's a string. This
3664
+ // prevents accidentally sending in a number that would
3665
+ // be interpretted as a start offset.
3666
+ return typeof encoding === 'string'
3667
+ ? createBuffer(size).fill(fill, encoding)
3668
+ : createBuffer(size).fill(fill)
3669
+ }
3670
+ return createBuffer(size)
3671
+ }
3672
+
3673
+ /**
3674
+ * Creates a new filled Buffer instance.
3675
+ * alloc(size[, fill[, encoding]])
3676
+ **/
3677
+ Buffer.alloc = function (size, fill, encoding) {
3678
+ return alloc(size, fill, encoding)
3679
+ }
3680
+
3681
+ function allocUnsafe (size) {
3682
+ assertSize(size)
3683
+ return createBuffer(size < 0 ? 0 : checked(size) | 0)
3684
+ }
3685
+
3686
+ /**
3687
+ * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
3688
+ * */
3689
+ Buffer.allocUnsafe = function (size) {
3690
+ return allocUnsafe(size)
3691
+ }
3692
+ /**
3693
+ * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
3694
+ */
3695
+ Buffer.allocUnsafeSlow = function (size) {
3696
+ return allocUnsafe(size)
3697
+ }
3698
+
3699
+ function fromString (string, encoding) {
3700
+ if (typeof encoding !== 'string' || encoding === '') {
3701
+ encoding = 'utf8'
3702
+ }
3703
+
3704
+ if (!Buffer.isEncoding(encoding)) {
3705
+ throw new TypeError('Unknown encoding: ' + encoding)
3706
+ }
3707
+
3708
+ var length = byteLength(string, encoding) | 0
3709
+ var buf = createBuffer(length)
3710
+
3711
+ var actual = buf.write(string, encoding)
3712
+
3713
+ if (actual !== length) {
3714
+ // Writing a hex string, for example, that contains invalid characters will
3715
+ // cause everything after the first invalid character to be ignored. (e.g.
3716
+ // 'abxxcd' will be treated as 'ab')
3717
+ buf = buf.slice(0, actual)
3718
+ }
3719
+
3720
+ return buf
3721
+ }
3722
+
3723
+ function fromArrayLike (array) {
3724
+ var length = array.length < 0 ? 0 : checked(array.length) | 0
3725
+ var buf = createBuffer(length)
3726
+ for (var i = 0; i < length; i += 1) {
3727
+ buf[i] = array[i] & 255
3728
+ }
3729
+ return buf
3730
+ }
3731
+
3732
+ function fromArrayBuffer (array, byteOffset, length) {
3733
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
3734
+ throw new RangeError('"offset" is outside of buffer bounds')
3735
+ }
3736
+
3737
+ if (array.byteLength < byteOffset + (length || 0)) {
3738
+ throw new RangeError('"length" is outside of buffer bounds')
3739
+ }
3740
+
3741
+ var buf
3742
+ if (byteOffset === undefined && length === undefined) {
3743
+ buf = new Uint8Array(array)
3744
+ } else if (length === undefined) {
3745
+ buf = new Uint8Array(array, byteOffset)
3746
+ } else {
3747
+ buf = new Uint8Array(array, byteOffset, length)
3748
+ }
3749
+
3750
+ // Return an augmented `Uint8Array` instance
3751
+ buf.__proto__ = Buffer.prototype
3752
+ return buf
3753
+ }
3754
+
3755
+ function fromObject (obj) {
3756
+ if (Buffer.isBuffer(obj)) {
3757
+ var len = checked(obj.length) | 0
3758
+ var buf = createBuffer(len)
3759
+
3760
+ if (buf.length === 0) {
3761
+ return buf
3762
+ }
3763
+
3764
+ obj.copy(buf, 0, 0, len)
3765
+ return buf
3766
+ }
3767
+
3768
+ if (obj.length !== undefined) {
3769
+ if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
3770
+ return createBuffer(0)
3771
+ }
3772
+ return fromArrayLike(obj)
3773
+ }
3774
+
3775
+ if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
3776
+ return fromArrayLike(obj.data)
3777
+ }
3778
+ }
3779
+
3780
+ function checked (length) {
3781
+ // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
3782
+ // length is NaN (which is otherwise coerced to zero.)
3783
+ if (length >= K_MAX_LENGTH) {
3784
+ throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
3785
+ 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
3786
+ }
3787
+ return length | 0
3788
+ }
3789
+
3790
+ function SlowBuffer (length) {
3791
+ if (+length != length) { // eslint-disable-line eqeqeq
3792
+ length = 0
3793
+ }
3794
+ return Buffer.alloc(+length)
3795
+ }
3796
+
3797
+ Buffer.isBuffer = function isBuffer (b) {
3798
+ return b != null && b._isBuffer === true &&
3799
+ b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
3800
+ }
3801
+
3802
+ Buffer.compare = function compare (a, b) {
3803
+ if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
3804
+ if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
3805
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
3806
+ throw new TypeError(
3807
+ 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
3808
+ )
3809
+ }
3810
+
3811
+ if (a === b) return 0
3812
+
3813
+ var x = a.length
3814
+ var y = b.length
3815
+
3816
+ for (var i = 0, len = Math.min(x, y); i < len; ++i) {
3817
+ if (a[i] !== b[i]) {
3818
+ x = a[i]
3819
+ y = b[i]
3820
+ break
3821
+ }
3822
+ }
3823
+
3824
+ if (x < y) return -1
3825
+ if (y < x) return 1
3826
+ return 0
3827
+ }
3828
+
3829
+ Buffer.isEncoding = function isEncoding (encoding) {
3830
+ switch (String(encoding).toLowerCase()) {
3831
+ case 'hex':
3832
+ case 'utf8':
3833
+ case 'utf-8':
3834
+ case 'ascii':
3835
+ case 'latin1':
3836
+ case 'binary':
3837
+ case 'base64':
3838
+ case 'ucs2':
3839
+ case 'ucs-2':
3840
+ case 'utf16le':
3841
+ case 'utf-16le':
3842
+ return true
3843
+ default:
3844
+ return false
3845
+ }
3846
+ }
3847
+
3848
+ Buffer.concat = function concat (list, length) {
3849
+ if (!Array.isArray(list)) {
3850
+ throw new TypeError('"list" argument must be an Array of Buffers')
3851
+ }
3852
+
3853
+ if (list.length === 0) {
3854
+ return Buffer.alloc(0)
3855
+ }
3856
+
3857
+ var i
3858
+ if (length === undefined) {
3859
+ length = 0
3860
+ for (i = 0; i < list.length; ++i) {
3861
+ length += list[i].length
3862
+ }
3863
+ }
3864
+
3865
+ var buffer = Buffer.allocUnsafe(length)
3866
+ var pos = 0
3867
+ for (i = 0; i < list.length; ++i) {
3868
+ var buf = list[i]
3869
+ if (isInstance(buf, Uint8Array)) {
3870
+ buf = Buffer.from(buf)
3871
+ }
3872
+ if (!Buffer.isBuffer(buf)) {
3873
+ throw new TypeError('"list" argument must be an Array of Buffers')
3874
+ }
3875
+ buf.copy(buffer, pos)
3876
+ pos += buf.length
3877
+ }
3878
+ return buffer
3879
+ }
3880
+
3881
+ function byteLength (string, encoding) {
3882
+ if (Buffer.isBuffer(string)) {
3883
+ return string.length
3884
+ }
3885
+ if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
3886
+ return string.byteLength
3887
+ }
3888
+ if (typeof string !== 'string') {
3889
+ throw new TypeError(
3890
+ 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
3891
+ 'Received type ' + typeof string
3892
+ )
3893
+ }
3894
+
3895
+ var len = string.length
3896
+ var mustMatch = (arguments.length > 2 && arguments[2] === true)
3897
+ if (!mustMatch && len === 0) return 0
3898
+
3899
+ // Use a for loop to avoid recursion
3900
+ var loweredCase = false
3901
+ for (;;) {
3902
+ switch (encoding) {
3903
+ case 'ascii':
3904
+ case 'latin1':
3905
+ case 'binary':
3906
+ return len
3907
+ case 'utf8':
3908
+ case 'utf-8':
3909
+ return utf8ToBytes(string).length
3910
+ case 'ucs2':
3911
+ case 'ucs-2':
3912
+ case 'utf16le':
3913
+ case 'utf-16le':
3914
+ return len * 2
3915
+ case 'hex':
3916
+ return len >>> 1
3917
+ case 'base64':
3918
+ return base64ToBytes(string).length
3919
+ default:
3920
+ if (loweredCase) {
3921
+ return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
3922
+ }
3923
+ encoding = ('' + encoding).toLowerCase()
3924
+ loweredCase = true
3925
+ }
3926
+ }
3927
+ }
3928
+ Buffer.byteLength = byteLength
3929
+
3930
+ function slowToString (encoding, start, end) {
3931
+ var loweredCase = false
3932
+
3933
+ // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
3934
+ // property of a typed array.
3935
+
3936
+ // This behaves neither like String nor Uint8Array in that we set start/end
3937
+ // to their upper/lower bounds if the value passed is out of range.
3938
+ // undefined is handled specially as per ECMA-262 6th Edition,
3939
+ // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
3940
+ if (start === undefined || start < 0) {
3941
+ start = 0
3942
+ }
3943
+ // Return early if start > this.length. Done here to prevent potential uint32
3944
+ // coercion fail below.
3945
+ if (start > this.length) {
3946
+ return ''
3947
+ }
3948
+
3949
+ if (end === undefined || end > this.length) {
3950
+ end = this.length
3951
+ }
3952
+
3953
+ if (end <= 0) {
3954
+ return ''
3955
+ }
3956
+
3957
+ // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
3958
+ end >>>= 0
3959
+ start >>>= 0
3960
+
3961
+ if (end <= start) {
3962
+ return ''
3963
+ }
3964
+
3965
+ if (!encoding) encoding = 'utf8'
3966
+
3967
+ while (true) {
3968
+ switch (encoding) {
3969
+ case 'hex':
3970
+ return hexSlice(this, start, end)
3971
+
3972
+ case 'utf8':
3973
+ case 'utf-8':
3974
+ return utf8Slice(this, start, end)
3975
+
3976
+ case 'ascii':
3977
+ return asciiSlice(this, start, end)
3978
+
3979
+ case 'latin1':
3980
+ case 'binary':
3981
+ return latin1Slice(this, start, end)
3982
+
3983
+ case 'base64':
3984
+ return base64Slice(this, start, end)
3985
+
3986
+ case 'ucs2':
3987
+ case 'ucs-2':
3988
+ case 'utf16le':
3989
+ case 'utf-16le':
3990
+ return utf16leSlice(this, start, end)
3991
+
3992
+ default:
3993
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
3994
+ encoding = (encoding + '').toLowerCase()
3995
+ loweredCase = true
3996
+ }
3997
+ }
3998
+ }
3999
+
4000
+ // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
4001
+ // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
4002
+ // reliably in a browserify context because there could be multiple different
4003
+ // copies of the 'buffer' package in use. This method works even for Buffer
4004
+ // instances that were created from another copy of the `buffer` package.
4005
+ // See: https://github.com/feross/buffer/issues/154
4006
+ Buffer.prototype._isBuffer = true
4007
+
4008
+ function swap (b, n, m) {
4009
+ var i = b[n]
4010
+ b[n] = b[m]
4011
+ b[m] = i
4012
+ }
4013
+
4014
+ Buffer.prototype.swap16 = function swap16 () {
4015
+ var len = this.length
4016
+ if (len % 2 !== 0) {
4017
+ throw new RangeError('Buffer size must be a multiple of 16-bits')
4018
+ }
4019
+ for (var i = 0; i < len; i += 2) {
4020
+ swap(this, i, i + 1)
4021
+ }
4022
+ return this
4023
+ }
4024
+
4025
+ Buffer.prototype.swap32 = function swap32 () {
4026
+ var len = this.length
4027
+ if (len % 4 !== 0) {
4028
+ throw new RangeError('Buffer size must be a multiple of 32-bits')
4029
+ }
4030
+ for (var i = 0; i < len; i += 4) {
4031
+ swap(this, i, i + 3)
4032
+ swap(this, i + 1, i + 2)
4033
+ }
4034
+ return this
4035
+ }
4036
+
4037
+ Buffer.prototype.swap64 = function swap64 () {
4038
+ var len = this.length
4039
+ if (len % 8 !== 0) {
4040
+ throw new RangeError('Buffer size must be a multiple of 64-bits')
4041
+ }
4042
+ for (var i = 0; i < len; i += 8) {
4043
+ swap(this, i, i + 7)
4044
+ swap(this, i + 1, i + 6)
4045
+ swap(this, i + 2, i + 5)
4046
+ swap(this, i + 3, i + 4)
4047
+ }
4048
+ return this
4049
+ }
4050
+
4051
+ Buffer.prototype.toString = function toString () {
4052
+ var length = this.length
4053
+ if (length === 0) return ''
4054
+ if (arguments.length === 0) return utf8Slice(this, 0, length)
4055
+ return slowToString.apply(this, arguments)
4056
+ }
4057
+
4058
+ Buffer.prototype.toLocaleString = Buffer.prototype.toString
4059
+
4060
+ Buffer.prototype.equals = function equals (b) {
4061
+ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
4062
+ if (this === b) return true
4063
+ return Buffer.compare(this, b) === 0
4064
+ }
4065
+
4066
+ Buffer.prototype.inspect = function inspect () {
4067
+ var str = ''
4068
+ var max = exports.INSPECT_MAX_BYTES
4069
+ str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
4070
+ if (this.length > max) str += ' ... '
4071
+ return '<Buffer ' + str + '>'
4072
+ }
4073
+
4074
+ Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
4075
+ if (isInstance(target, Uint8Array)) {
4076
+ target = Buffer.from(target, target.offset, target.byteLength)
4077
+ }
4078
+ if (!Buffer.isBuffer(target)) {
4079
+ throw new TypeError(
4080
+ 'The "target" argument must be one of type Buffer or Uint8Array. ' +
4081
+ 'Received type ' + (typeof target)
4082
+ )
4083
+ }
4084
+
4085
+ if (start === undefined) {
4086
+ start = 0
4087
+ }
4088
+ if (end === undefined) {
4089
+ end = target ? target.length : 0
4090
+ }
4091
+ if (thisStart === undefined) {
4092
+ thisStart = 0
4093
+ }
4094
+ if (thisEnd === undefined) {
4095
+ thisEnd = this.length
4096
+ }
4097
+
4098
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
4099
+ throw new RangeError('out of range index')
4100
+ }
4101
+
4102
+ if (thisStart >= thisEnd && start >= end) {
4103
+ return 0
4104
+ }
4105
+ if (thisStart >= thisEnd) {
4106
+ return -1
4107
+ }
4108
+ if (start >= end) {
4109
+ return 1
4110
+ }
4111
+
4112
+ start >>>= 0
4113
+ end >>>= 0
4114
+ thisStart >>>= 0
4115
+ thisEnd >>>= 0
4116
+
4117
+ if (this === target) return 0
4118
+
4119
+ var x = thisEnd - thisStart
4120
+ var y = end - start
4121
+ var len = Math.min(x, y)
4122
+
4123
+ var thisCopy = this.slice(thisStart, thisEnd)
4124
+ var targetCopy = target.slice(start, end)
4125
+
4126
+ for (var i = 0; i < len; ++i) {
4127
+ if (thisCopy[i] !== targetCopy[i]) {
4128
+ x = thisCopy[i]
4129
+ y = targetCopy[i]
4130
+ break
4131
+ }
4132
+ }
4133
+
4134
+ if (x < y) return -1
4135
+ if (y < x) return 1
4136
+ return 0
4137
+ }
4138
+
4139
+ // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
4140
+ // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
4141
+ //
4142
+ // Arguments:
4143
+ // - buffer - a Buffer to search
4144
+ // - val - a string, Buffer, or number
4145
+ // - byteOffset - an index into `buffer`; will be clamped to an int32
4146
+ // - encoding - an optional encoding, relevant is val is a string
4147
+ // - dir - true for indexOf, false for lastIndexOf
4148
+ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
4149
+ // Empty buffer means no match
4150
+ if (buffer.length === 0) return -1
4151
+
4152
+ // Normalize byteOffset
4153
+ if (typeof byteOffset === 'string') {
4154
+ encoding = byteOffset
4155
+ byteOffset = 0
4156
+ } else if (byteOffset > 0x7fffffff) {
4157
+ byteOffset = 0x7fffffff
4158
+ } else if (byteOffset < -0x80000000) {
4159
+ byteOffset = -0x80000000
4160
+ }
4161
+ byteOffset = +byteOffset // Coerce to Number.
4162
+ if (numberIsNaN(byteOffset)) {
4163
+ // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
4164
+ byteOffset = dir ? 0 : (buffer.length - 1)
4165
+ }
4166
+
4167
+ // Normalize byteOffset: negative offsets start from the end of the buffer
4168
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset
4169
+ if (byteOffset >= buffer.length) {
4170
+ if (dir) return -1
4171
+ else byteOffset = buffer.length - 1
4172
+ } else if (byteOffset < 0) {
4173
+ if (dir) byteOffset = 0
4174
+ else return -1
4175
+ }
4176
+
4177
+ // Normalize val
4178
+ if (typeof val === 'string') {
4179
+ val = Buffer.from(val, encoding)
4180
+ }
4181
+
4182
+ // Finally, search either indexOf (if dir is true) or lastIndexOf
4183
+ if (Buffer.isBuffer(val)) {
4184
+ // Special case: looking for empty string/buffer always fails
4185
+ if (val.length === 0) {
4186
+ return -1
4187
+ }
4188
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
4189
+ } else if (typeof val === 'number') {
4190
+ val = val & 0xFF // Search for a byte value [0-255]
4191
+ if (typeof Uint8Array.prototype.indexOf === 'function') {
4192
+ if (dir) {
4193
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
4194
+ } else {
4195
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
4196
+ }
4197
+ }
4198
+ return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
4199
+ }
4200
+
4201
+ throw new TypeError('val must be string, number or Buffer')
4202
+ }
4203
+
4204
+ function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
4205
+ var indexSize = 1
4206
+ var arrLength = arr.length
4207
+ var valLength = val.length
4208
+
4209
+ if (encoding !== undefined) {
4210
+ encoding = String(encoding).toLowerCase()
4211
+ if (encoding === 'ucs2' || encoding === 'ucs-2' ||
4212
+ encoding === 'utf16le' || encoding === 'utf-16le') {
4213
+ if (arr.length < 2 || val.length < 2) {
4214
+ return -1
4215
+ }
4216
+ indexSize = 2
4217
+ arrLength /= 2
4218
+ valLength /= 2
4219
+ byteOffset /= 2
4220
+ }
4221
+ }
4222
+
4223
+ function read (buf, i) {
4224
+ if (indexSize === 1) {
4225
+ return buf[i]
4226
+ } else {
4227
+ return buf.readUInt16BE(i * indexSize)
4228
+ }
4229
+ }
4230
+
4231
+ var i
4232
+ if (dir) {
4233
+ var foundIndex = -1
4234
+ for (i = byteOffset; i < arrLength; i++) {
4235
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
4236
+ if (foundIndex === -1) foundIndex = i
4237
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
4238
+ } else {
4239
+ if (foundIndex !== -1) i -= i - foundIndex
4240
+ foundIndex = -1
4241
+ }
4242
+ }
4243
+ } else {
4244
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
4245
+ for (i = byteOffset; i >= 0; i--) {
4246
+ var found = true
4247
+ for (var j = 0; j < valLength; j++) {
4248
+ if (read(arr, i + j) !== read(val, j)) {
4249
+ found = false
4250
+ break
4251
+ }
4252
+ }
4253
+ if (found) return i
4254
+ }
4255
+ }
4256
+
4257
+ return -1
4258
+ }
4259
+
4260
+ Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
4261
+ return this.indexOf(val, byteOffset, encoding) !== -1
4262
+ }
4263
+
4264
+ Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
4265
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
4266
+ }
4267
+
4268
+ Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
4269
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
4270
+ }
4271
+
4272
+ function hexWrite (buf, string, offset, length) {
4273
+ offset = Number(offset) || 0
4274
+ var remaining = buf.length - offset
4275
+ if (!length) {
4276
+ length = remaining
4277
+ } else {
4278
+ length = Number(length)
4279
+ if (length > remaining) {
4280
+ length = remaining
4281
+ }
4282
+ }
4283
+
4284
+ var strLen = string.length
4285
+
4286
+ if (length > strLen / 2) {
4287
+ length = strLen / 2
4288
+ }
4289
+ for (var i = 0; i < length; ++i) {
4290
+ var parsed = parseInt(string.substr(i * 2, 2), 16)
4291
+ if (numberIsNaN(parsed)) return i
4292
+ buf[offset + i] = parsed
4293
+ }
4294
+ return i
4295
+ }
4296
+
4297
+ function utf8Write (buf, string, offset, length) {
4298
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
4299
+ }
4300
+
4301
+ function asciiWrite (buf, string, offset, length) {
4302
+ return blitBuffer(asciiToBytes(string), buf, offset, length)
4303
+ }
4304
+
4305
+ function latin1Write (buf, string, offset, length) {
4306
+ return asciiWrite(buf, string, offset, length)
4307
+ }
4308
+
4309
+ function base64Write (buf, string, offset, length) {
4310
+ return blitBuffer(base64ToBytes(string), buf, offset, length)
4311
+ }
4312
+
4313
+ function ucs2Write (buf, string, offset, length) {
4314
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
4315
+ }
4316
+
4317
+ Buffer.prototype.write = function write (string, offset, length, encoding) {
4318
+ // Buffer#write(string)
4319
+ if (offset === undefined) {
4320
+ encoding = 'utf8'
4321
+ length = this.length
4322
+ offset = 0
4323
+ // Buffer#write(string, encoding)
4324
+ } else if (length === undefined && typeof offset === 'string') {
4325
+ encoding = offset
4326
+ length = this.length
4327
+ offset = 0
4328
+ // Buffer#write(string, offset[, length][, encoding])
4329
+ } else if (isFinite(offset)) {
4330
+ offset = offset >>> 0
4331
+ if (isFinite(length)) {
4332
+ length = length >>> 0
4333
+ if (encoding === undefined) encoding = 'utf8'
4334
+ } else {
4335
+ encoding = length
4336
+ length = undefined
4337
+ }
4338
+ } else {
4339
+ throw new Error(
4340
+ 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
4341
+ )
4342
+ }
4343
+
4344
+ var remaining = this.length - offset
4345
+ if (length === undefined || length > remaining) length = remaining
4346
+
4347
+ if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
4348
+ throw new RangeError('Attempt to write outside buffer bounds')
4349
+ }
4350
+
4351
+ if (!encoding) encoding = 'utf8'
4352
+
4353
+ var loweredCase = false
4354
+ for (;;) {
4355
+ switch (encoding) {
4356
+ case 'hex':
4357
+ return hexWrite(this, string, offset, length)
4358
+
4359
+ case 'utf8':
4360
+ case 'utf-8':
4361
+ return utf8Write(this, string, offset, length)
4362
+
4363
+ case 'ascii':
4364
+ return asciiWrite(this, string, offset, length)
4365
+
4366
+ case 'latin1':
4367
+ case 'binary':
4368
+ return latin1Write(this, string, offset, length)
4369
+
4370
+ case 'base64':
4371
+ // Warning: maxLength not taken into account in base64Write
4372
+ return base64Write(this, string, offset, length)
4373
+
4374
+ case 'ucs2':
4375
+ case 'ucs-2':
4376
+ case 'utf16le':
4377
+ case 'utf-16le':
4378
+ return ucs2Write(this, string, offset, length)
4379
+
4380
+ default:
4381
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
4382
+ encoding = ('' + encoding).toLowerCase()
4383
+ loweredCase = true
4384
+ }
4385
+ }
4386
+ }
4387
+
4388
+ Buffer.prototype.toJSON = function toJSON () {
4389
+ return {
4390
+ type: 'Buffer',
4391
+ data: Array.prototype.slice.call(this._arr || this, 0)
4392
+ }
4393
+ }
4394
+
4395
+ function base64Slice (buf, start, end) {
4396
+ if (start === 0 && end === buf.length) {
4397
+ return base64.fromByteArray(buf)
4398
+ } else {
4399
+ return base64.fromByteArray(buf.slice(start, end))
4400
+ }
4401
+ }
4402
+
4403
+ function utf8Slice (buf, start, end) {
4404
+ end = Math.min(buf.length, end)
4405
+ var res = []
4406
+
4407
+ var i = start
4408
+ while (i < end) {
4409
+ var firstByte = buf[i]
4410
+ var codePoint = null
4411
+ var bytesPerSequence = (firstByte > 0xEF) ? 4
4412
+ : (firstByte > 0xDF) ? 3
4413
+ : (firstByte > 0xBF) ? 2
4414
+ : 1
4415
+
4416
+ if (i + bytesPerSequence <= end) {
4417
+ var secondByte, thirdByte, fourthByte, tempCodePoint
4418
+
4419
+ switch (bytesPerSequence) {
4420
+ case 1:
4421
+ if (firstByte < 0x80) {
4422
+ codePoint = firstByte
4423
+ }
4424
+ break
4425
+ case 2:
4426
+ secondByte = buf[i + 1]
4427
+ if ((secondByte & 0xC0) === 0x80) {
4428
+ tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
4429
+ if (tempCodePoint > 0x7F) {
4430
+ codePoint = tempCodePoint
4431
+ }
4432
+ }
4433
+ break
4434
+ case 3:
4435
+ secondByte = buf[i + 1]
4436
+ thirdByte = buf[i + 2]
4437
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
4438
+ tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
4439
+ if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
4440
+ codePoint = tempCodePoint
4441
+ }
4442
+ }
4443
+ break
4444
+ case 4:
4445
+ secondByte = buf[i + 1]
4446
+ thirdByte = buf[i + 2]
4447
+ fourthByte = buf[i + 3]
4448
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
4449
+ tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
4450
+ if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
4451
+ codePoint = tempCodePoint
4452
+ }
4453
+ }
4454
+ }
4455
+ }
4456
+
4457
+ if (codePoint === null) {
4458
+ // we did not generate a valid codePoint so insert a
4459
+ // replacement char (U+FFFD) and advance only 1 byte
4460
+ codePoint = 0xFFFD
4461
+ bytesPerSequence = 1
4462
+ } else if (codePoint > 0xFFFF) {
4463
+ // encode to utf16 (surrogate pair dance)
4464
+ codePoint -= 0x10000
4465
+ res.push(codePoint >>> 10 & 0x3FF | 0xD800)
4466
+ codePoint = 0xDC00 | codePoint & 0x3FF
4467
+ }
4468
+
4469
+ res.push(codePoint)
4470
+ i += bytesPerSequence
4471
+ }
4472
+
4473
+ return decodeCodePointsArray(res)
4474
+ }
4475
+
4476
+ // Based on http://stackoverflow.com/a/22747272/680742, the browser with
4477
+ // the lowest limit is Chrome, with 0x10000 args.
4478
+ // We go 1 magnitude less, for safety
4479
+ var MAX_ARGUMENTS_LENGTH = 0x1000
4480
+
4481
+ function decodeCodePointsArray (codePoints) {
4482
+ var len = codePoints.length
4483
+ if (len <= MAX_ARGUMENTS_LENGTH) {
4484
+ return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
4485
+ }
4486
+
4487
+ // Decode in chunks to avoid "call stack size exceeded".
4488
+ var res = ''
4489
+ var i = 0
4490
+ while (i < len) {
4491
+ res += String.fromCharCode.apply(
4492
+ String,
4493
+ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
4494
+ )
4495
+ }
4496
+ return res
4497
+ }
4498
+
4499
+ function asciiSlice (buf, start, end) {
4500
+ var ret = ''
4501
+ end = Math.min(buf.length, end)
4502
+
4503
+ for (var i = start; i < end; ++i) {
4504
+ ret += String.fromCharCode(buf[i] & 0x7F)
4505
+ }
4506
+ return ret
4507
+ }
4508
+
4509
+ function latin1Slice (buf, start, end) {
4510
+ var ret = ''
4511
+ end = Math.min(buf.length, end)
4512
+
4513
+ for (var i = start; i < end; ++i) {
4514
+ ret += String.fromCharCode(buf[i])
4515
+ }
4516
+ return ret
4517
+ }
4518
+
4519
+ function hexSlice (buf, start, end) {
4520
+ var len = buf.length
4521
+
4522
+ if (!start || start < 0) start = 0
4523
+ if (!end || end < 0 || end > len) end = len
4524
+
4525
+ var out = ''
4526
+ for (var i = start; i < end; ++i) {
4527
+ out += toHex(buf[i])
4528
+ }
4529
+ return out
4530
+ }
4531
+
4532
+ function utf16leSlice (buf, start, end) {
4533
+ var bytes = buf.slice(start, end)
4534
+ var res = ''
4535
+ for (var i = 0; i < bytes.length; i += 2) {
4536
+ res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
4537
+ }
4538
+ return res
4539
+ }
4540
+
4541
+ Buffer.prototype.slice = function slice (start, end) {
4542
+ var len = this.length
4543
+ start = ~~start
4544
+ end = end === undefined ? len : ~~end
4545
+
4546
+ if (start < 0) {
4547
+ start += len
4548
+ if (start < 0) start = 0
4549
+ } else if (start > len) {
4550
+ start = len
4551
+ }
4552
+
4553
+ if (end < 0) {
4554
+ end += len
4555
+ if (end < 0) end = 0
4556
+ } else if (end > len) {
4557
+ end = len
4558
+ }
4559
+
4560
+ if (end < start) end = start
4561
+
4562
+ var newBuf = this.subarray(start, end)
4563
+ // Return an augmented `Uint8Array` instance
4564
+ newBuf.__proto__ = Buffer.prototype
4565
+ return newBuf
4566
+ }
4567
+
4568
+ /*
4569
+ * Need to make sure that buffer isn't trying to write out of bounds.
4570
+ */
4571
+ function checkOffset (offset, ext, length) {
4572
+ if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
4573
+ if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
4574
+ }
4575
+
4576
+ Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
4577
+ offset = offset >>> 0
4578
+ byteLength = byteLength >>> 0
4579
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
4580
+
4581
+ var val = this[offset]
4582
+ var mul = 1
4583
+ var i = 0
4584
+ while (++i < byteLength && (mul *= 0x100)) {
4585
+ val += this[offset + i] * mul
4586
+ }
4587
+
4588
+ return val
4589
+ }
4590
+
4591
+ Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
4592
+ offset = offset >>> 0
4593
+ byteLength = byteLength >>> 0
4594
+ if (!noAssert) {
4595
+ checkOffset(offset, byteLength, this.length)
4596
+ }
4597
+
4598
+ var val = this[offset + --byteLength]
4599
+ var mul = 1
4600
+ while (byteLength > 0 && (mul *= 0x100)) {
4601
+ val += this[offset + --byteLength] * mul
4602
+ }
4603
+
4604
+ return val
4605
+ }
4606
+
4607
+ Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
4608
+ offset = offset >>> 0
4609
+ if (!noAssert) checkOffset(offset, 1, this.length)
4610
+ return this[offset]
4611
+ }
4612
+
4613
+ Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
4614
+ offset = offset >>> 0
4615
+ if (!noAssert) checkOffset(offset, 2, this.length)
4616
+ return this[offset] | (this[offset + 1] << 8)
4617
+ }
4618
+
4619
+ Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
4620
+ offset = offset >>> 0
4621
+ if (!noAssert) checkOffset(offset, 2, this.length)
4622
+ return (this[offset] << 8) | this[offset + 1]
4623
+ }
4624
+
4625
+ Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
4626
+ offset = offset >>> 0
4627
+ if (!noAssert) checkOffset(offset, 4, this.length)
4628
+
4629
+ return ((this[offset]) |
4630
+ (this[offset + 1] << 8) |
4631
+ (this[offset + 2] << 16)) +
4632
+ (this[offset + 3] * 0x1000000)
4633
+ }
4634
+
4635
+ Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
4636
+ offset = offset >>> 0
4637
+ if (!noAssert) checkOffset(offset, 4, this.length)
4638
+
4639
+ return (this[offset] * 0x1000000) +
4640
+ ((this[offset + 1] << 16) |
4641
+ (this[offset + 2] << 8) |
4642
+ this[offset + 3])
4643
+ }
4644
+
4645
+ Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
4646
+ offset = offset >>> 0
4647
+ byteLength = byteLength >>> 0
4648
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
4649
+
4650
+ var val = this[offset]
4651
+ var mul = 1
4652
+ var i = 0
4653
+ while (++i < byteLength && (mul *= 0x100)) {
4654
+ val += this[offset + i] * mul
4655
+ }
4656
+ mul *= 0x80
4657
+
4658
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength)
4659
+
4660
+ return val
4661
+ }
4662
+
4663
+ Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
4664
+ offset = offset >>> 0
4665
+ byteLength = byteLength >>> 0
4666
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
4667
+
4668
+ var i = byteLength
4669
+ var mul = 1
4670
+ var val = this[offset + --i]
4671
+ while (i > 0 && (mul *= 0x100)) {
4672
+ val += this[offset + --i] * mul
4673
+ }
4674
+ mul *= 0x80
4675
+
4676
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength)
4677
+
4678
+ return val
4679
+ }
4680
+
4681
+ Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
4682
+ offset = offset >>> 0
4683
+ if (!noAssert) checkOffset(offset, 1, this.length)
4684
+ if (!(this[offset] & 0x80)) return (this[offset])
4685
+ return ((0xff - this[offset] + 1) * -1)
4686
+ }
4687
+
4688
+ Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
4689
+ offset = offset >>> 0
4690
+ if (!noAssert) checkOffset(offset, 2, this.length)
4691
+ var val = this[offset] | (this[offset + 1] << 8)
4692
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
4693
+ }
4694
+
4695
+ Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
4696
+ offset = offset >>> 0
4697
+ if (!noAssert) checkOffset(offset, 2, this.length)
4698
+ var val = this[offset + 1] | (this[offset] << 8)
4699
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
4700
+ }
4701
+
4702
+ Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
4703
+ offset = offset >>> 0
4704
+ if (!noAssert) checkOffset(offset, 4, this.length)
4705
+
4706
+ return (this[offset]) |
4707
+ (this[offset + 1] << 8) |
4708
+ (this[offset + 2] << 16) |
4709
+ (this[offset + 3] << 24)
4710
+ }
4711
+
4712
+ Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
4713
+ offset = offset >>> 0
4714
+ if (!noAssert) checkOffset(offset, 4, this.length)
4715
+
4716
+ return (this[offset] << 24) |
4717
+ (this[offset + 1] << 16) |
4718
+ (this[offset + 2] << 8) |
4719
+ (this[offset + 3])
4720
+ }
4721
+
4722
+ Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
4723
+ offset = offset >>> 0
4724
+ if (!noAssert) checkOffset(offset, 4, this.length)
4725
+ return ieee754.read(this, offset, true, 23, 4)
4726
+ }
4727
+
4728
+ Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
4729
+ offset = offset >>> 0
4730
+ if (!noAssert) checkOffset(offset, 4, this.length)
4731
+ return ieee754.read(this, offset, false, 23, 4)
4732
+ }
4733
+
4734
+ Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
4735
+ offset = offset >>> 0
4736
+ if (!noAssert) checkOffset(offset, 8, this.length)
4737
+ return ieee754.read(this, offset, true, 52, 8)
4738
+ }
4739
+
4740
+ Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
4741
+ offset = offset >>> 0
4742
+ if (!noAssert) checkOffset(offset, 8, this.length)
4743
+ return ieee754.read(this, offset, false, 52, 8)
4744
+ }
4745
+
4746
+ function checkInt (buf, value, offset, ext, max, min) {
4747
+ if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
4748
+ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
4749
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
4750
+ }
4751
+
4752
+ Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
4753
+ value = +value
4754
+ offset = offset >>> 0
4755
+ byteLength = byteLength >>> 0
4756
+ if (!noAssert) {
4757
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1
4758
+ checkInt(this, value, offset, byteLength, maxBytes, 0)
4759
+ }
4760
+
4761
+ var mul = 1
4762
+ var i = 0
4763
+ this[offset] = value & 0xFF
4764
+ while (++i < byteLength && (mul *= 0x100)) {
4765
+ this[offset + i] = (value / mul) & 0xFF
4766
+ }
4767
+
4768
+ return offset + byteLength
4769
+ }
4770
+
4771
+ Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
4772
+ value = +value
4773
+ offset = offset >>> 0
4774
+ byteLength = byteLength >>> 0
4775
+ if (!noAssert) {
4776
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1
4777
+ checkInt(this, value, offset, byteLength, maxBytes, 0)
4778
+ }
4779
+
4780
+ var i = byteLength - 1
4781
+ var mul = 1
4782
+ this[offset + i] = value & 0xFF
4783
+ while (--i >= 0 && (mul *= 0x100)) {
4784
+ this[offset + i] = (value / mul) & 0xFF
4785
+ }
4786
+
4787
+ return offset + byteLength
4788
+ }
4789
+
4790
+ Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
4791
+ value = +value
4792
+ offset = offset >>> 0
4793
+ if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
4794
+ this[offset] = (value & 0xff)
4795
+ return offset + 1
4796
+ }
4797
+
4798
+ Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
4799
+ value = +value
4800
+ offset = offset >>> 0
4801
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
4802
+ this[offset] = (value & 0xff)
4803
+ this[offset + 1] = (value >>> 8)
4804
+ return offset + 2
4805
+ }
4806
+
4807
+ Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
4808
+ value = +value
4809
+ offset = offset >>> 0
4810
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
4811
+ this[offset] = (value >>> 8)
4812
+ this[offset + 1] = (value & 0xff)
4813
+ return offset + 2
4814
+ }
4815
+
4816
+ Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
4817
+ value = +value
4818
+ offset = offset >>> 0
4819
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
4820
+ this[offset + 3] = (value >>> 24)
4821
+ this[offset + 2] = (value >>> 16)
4822
+ this[offset + 1] = (value >>> 8)
4823
+ this[offset] = (value & 0xff)
4824
+ return offset + 4
4825
+ }
4826
+
4827
+ Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
4828
+ value = +value
4829
+ offset = offset >>> 0
4830
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
4831
+ this[offset] = (value >>> 24)
4832
+ this[offset + 1] = (value >>> 16)
4833
+ this[offset + 2] = (value >>> 8)
4834
+ this[offset + 3] = (value & 0xff)
4835
+ return offset + 4
4836
+ }
4837
+
4838
+ Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
4839
+ value = +value
4840
+ offset = offset >>> 0
4841
+ if (!noAssert) {
4842
+ var limit = Math.pow(2, (8 * byteLength) - 1)
4843
+
4844
+ checkInt(this, value, offset, byteLength, limit - 1, -limit)
4845
+ }
4846
+
4847
+ var i = 0
4848
+ var mul = 1
4849
+ var sub = 0
4850
+ this[offset] = value & 0xFF
4851
+ while (++i < byteLength && (mul *= 0x100)) {
4852
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
4853
+ sub = 1
4854
+ }
4855
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
4856
+ }
4857
+
4858
+ return offset + byteLength
4859
+ }
4860
+
4861
+ Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
4862
+ value = +value
4863
+ offset = offset >>> 0
4864
+ if (!noAssert) {
4865
+ var limit = Math.pow(2, (8 * byteLength) - 1)
4866
+
4867
+ checkInt(this, value, offset, byteLength, limit - 1, -limit)
4868
+ }
4869
+
4870
+ var i = byteLength - 1
4871
+ var mul = 1
4872
+ var sub = 0
4873
+ this[offset + i] = value & 0xFF
4874
+ while (--i >= 0 && (mul *= 0x100)) {
4875
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
4876
+ sub = 1
4877
+ }
4878
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
4879
+ }
4880
+
4881
+ return offset + byteLength
4882
+ }
4883
+
4884
+ Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
4885
+ value = +value
4886
+ offset = offset >>> 0
4887
+ if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
4888
+ if (value < 0) value = 0xff + value + 1
4889
+ this[offset] = (value & 0xff)
4890
+ return offset + 1
4891
+ }
4892
+
4893
+ Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
4894
+ value = +value
4895
+ offset = offset >>> 0
4896
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
4897
+ this[offset] = (value & 0xff)
4898
+ this[offset + 1] = (value >>> 8)
4899
+ return offset + 2
4900
+ }
4901
+
4902
+ Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
4903
+ value = +value
4904
+ offset = offset >>> 0
4905
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
4906
+ this[offset] = (value >>> 8)
4907
+ this[offset + 1] = (value & 0xff)
4908
+ return offset + 2
4909
+ }
4910
+
4911
+ Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
4912
+ value = +value
4913
+ offset = offset >>> 0
4914
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
4915
+ this[offset] = (value & 0xff)
4916
+ this[offset + 1] = (value >>> 8)
4917
+ this[offset + 2] = (value >>> 16)
4918
+ this[offset + 3] = (value >>> 24)
4919
+ return offset + 4
4920
+ }
4921
+
4922
+ Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
4923
+ value = +value
4924
+ offset = offset >>> 0
4925
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
4926
+ if (value < 0) value = 0xffffffff + value + 1
4927
+ this[offset] = (value >>> 24)
4928
+ this[offset + 1] = (value >>> 16)
4929
+ this[offset + 2] = (value >>> 8)
4930
+ this[offset + 3] = (value & 0xff)
4931
+ return offset + 4
4932
+ }
4933
+
4934
+ function checkIEEE754 (buf, value, offset, ext, max, min) {
4935
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
4936
+ if (offset < 0) throw new RangeError('Index out of range')
4937
+ }
4938
+
4939
+ function writeFloat (buf, value, offset, littleEndian, noAssert) {
4940
+ value = +value
4941
+ offset = offset >>> 0
4942
+ if (!noAssert) {
4943
+ checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
4944
+ }
4945
+ ieee754.write(buf, value, offset, littleEndian, 23, 4)
4946
+ return offset + 4
4947
+ }
4948
+
4949
+ Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
4950
+ return writeFloat(this, value, offset, true, noAssert)
4951
+ }
4952
+
4953
+ Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
4954
+ return writeFloat(this, value, offset, false, noAssert)
4955
+ }
4956
+
4957
+ function writeDouble (buf, value, offset, littleEndian, noAssert) {
4958
+ value = +value
4959
+ offset = offset >>> 0
4960
+ if (!noAssert) {
4961
+ checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
4962
+ }
4963
+ ieee754.write(buf, value, offset, littleEndian, 52, 8)
4964
+ return offset + 8
4965
+ }
4966
+
4967
+ Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
4968
+ return writeDouble(this, value, offset, true, noAssert)
4969
+ }
4970
+
4971
+ Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
4972
+ return writeDouble(this, value, offset, false, noAssert)
4973
+ }
4974
+
4975
+ // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
4976
+ Buffer.prototype.copy = function copy (target, targetStart, start, end) {
4977
+ if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
4978
+ if (!start) start = 0
4979
+ if (!end && end !== 0) end = this.length
4980
+ if (targetStart >= target.length) targetStart = target.length
4981
+ if (!targetStart) targetStart = 0
4982
+ if (end > 0 && end < start) end = start
4983
+
4984
+ // Copy 0 bytes; we're done
4985
+ if (end === start) return 0
4986
+ if (target.length === 0 || this.length === 0) return 0
4987
+
4988
+ // Fatal error conditions
4989
+ if (targetStart < 0) {
4990
+ throw new RangeError('targetStart out of bounds')
4991
+ }
4992
+ if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
4993
+ if (end < 0) throw new RangeError('sourceEnd out of bounds')
4994
+
4995
+ // Are we oob?
4996
+ if (end > this.length) end = this.length
4997
+ if (target.length - targetStart < end - start) {
4998
+ end = target.length - targetStart + start
4999
+ }
5000
+
5001
+ var len = end - start
5002
+
5003
+ if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
5004
+ // Use built-in when available, missing from IE11
5005
+ this.copyWithin(targetStart, start, end)
5006
+ } else if (this === target && start < targetStart && targetStart < end) {
5007
+ // descending copy from end
5008
+ for (var i = len - 1; i >= 0; --i) {
5009
+ target[i + targetStart] = this[i + start]
5010
+ }
5011
+ } else {
5012
+ Uint8Array.prototype.set.call(
5013
+ target,
5014
+ this.subarray(start, end),
5015
+ targetStart
5016
+ )
5017
+ }
5018
+
5019
+ return len
5020
+ }
5021
+
5022
+ // Usage:
5023
+ // buffer.fill(number[, offset[, end]])
5024
+ // buffer.fill(buffer[, offset[, end]])
5025
+ // buffer.fill(string[, offset[, end]][, encoding])
5026
+ Buffer.prototype.fill = function fill (val, start, end, encoding) {
5027
+ // Handle string cases:
5028
+ if (typeof val === 'string') {
5029
+ if (typeof start === 'string') {
5030
+ encoding = start
5031
+ start = 0
5032
+ end = this.length
5033
+ } else if (typeof end === 'string') {
5034
+ encoding = end
5035
+ end = this.length
5036
+ }
5037
+ if (encoding !== undefined && typeof encoding !== 'string') {
5038
+ throw new TypeError('encoding must be a string')
5039
+ }
5040
+ if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
5041
+ throw new TypeError('Unknown encoding: ' + encoding)
5042
+ }
5043
+ if (val.length === 1) {
5044
+ var code = val.charCodeAt(0)
5045
+ if ((encoding === 'utf8' && code < 128) ||
5046
+ encoding === 'latin1') {
5047
+ // Fast path: If `val` fits into a single byte, use that numeric value.
5048
+ val = code
5049
+ }
5050
+ }
5051
+ } else if (typeof val === 'number') {
5052
+ val = val & 255
5053
+ }
5054
+
5055
+ // Invalid ranges are not set to a default, so can range check early.
5056
+ if (start < 0 || this.length < start || this.length < end) {
5057
+ throw new RangeError('Out of range index')
5058
+ }
5059
+
5060
+ if (end <= start) {
5061
+ return this
5062
+ }
5063
+
5064
+ start = start >>> 0
5065
+ end = end === undefined ? this.length : end >>> 0
5066
+
5067
+ if (!val) val = 0
5068
+
5069
+ var i
5070
+ if (typeof val === 'number') {
5071
+ for (i = start; i < end; ++i) {
5072
+ this[i] = val
5073
+ }
5074
+ } else {
5075
+ var bytes = Buffer.isBuffer(val)
5076
+ ? val
5077
+ : Buffer.from(val, encoding)
5078
+ var len = bytes.length
5079
+ if (len === 0) {
5080
+ throw new TypeError('The value "' + val +
5081
+ '" is invalid for argument "value"')
5082
+ }
5083
+ for (i = 0; i < end - start; ++i) {
5084
+ this[i + start] = bytes[i % len]
5085
+ }
5086
+ }
5087
+
5088
+ return this
5089
+ }
5090
+
5091
+ // HELPER FUNCTIONS
5092
+ // ================
5093
+
5094
+ var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
5095
+
5096
+ function base64clean (str) {
5097
+ // Node takes equal signs as end of the Base64 encoding
5098
+ str = str.split('=')[0]
5099
+ // Node strips out invalid characters like \n and \t from the string, base64-js does not
5100
+ str = str.trim().replace(INVALID_BASE64_RE, '')
5101
+ // Node converts strings with length < 2 to ''
5102
+ if (str.length < 2) return ''
5103
+ // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
5104
+ while (str.length % 4 !== 0) {
5105
+ str = str + '='
5106
+ }
5107
+ return str
5108
+ }
5109
+
5110
+ function toHex (n) {
5111
+ if (n < 16) return '0' + n.toString(16)
5112
+ return n.toString(16)
5113
+ }
5114
+
5115
+ function utf8ToBytes (string, units) {
5116
+ units = units || Infinity
5117
+ var codePoint
5118
+ var length = string.length
5119
+ var leadSurrogate = null
5120
+ var bytes = []
5121
+
5122
+ for (var i = 0; i < length; ++i) {
5123
+ codePoint = string.charCodeAt(i)
5124
+
5125
+ // is surrogate component
5126
+ if (codePoint > 0xD7FF && codePoint < 0xE000) {
5127
+ // last char was a lead
5128
+ if (!leadSurrogate) {
5129
+ // no lead yet
5130
+ if (codePoint > 0xDBFF) {
5131
+ // unexpected trail
5132
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
5133
+ continue
5134
+ } else if (i + 1 === length) {
5135
+ // unpaired lead
5136
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
5137
+ continue
5138
+ }
5139
+
5140
+ // valid lead
5141
+ leadSurrogate = codePoint
5142
+
5143
+ continue
5144
+ }
5145
+
5146
+ // 2 leads in a row
5147
+ if (codePoint < 0xDC00) {
5148
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
5149
+ leadSurrogate = codePoint
5150
+ continue
5151
+ }
5152
+
5153
+ // valid surrogate pair
5154
+ codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
5155
+ } else if (leadSurrogate) {
5156
+ // valid bmp char, but last char was a lead
5157
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
5158
+ }
5159
+
5160
+ leadSurrogate = null
5161
+
5162
+ // encode utf8
5163
+ if (codePoint < 0x80) {
5164
+ if ((units -= 1) < 0) break
5165
+ bytes.push(codePoint)
5166
+ } else if (codePoint < 0x800) {
5167
+ if ((units -= 2) < 0) break
5168
+ bytes.push(
5169
+ codePoint >> 0x6 | 0xC0,
5170
+ codePoint & 0x3F | 0x80
5171
+ )
5172
+ } else if (codePoint < 0x10000) {
5173
+ if ((units -= 3) < 0) break
5174
+ bytes.push(
5175
+ codePoint >> 0xC | 0xE0,
5176
+ codePoint >> 0x6 & 0x3F | 0x80,
5177
+ codePoint & 0x3F | 0x80
5178
+ )
5179
+ } else if (codePoint < 0x110000) {
5180
+ if ((units -= 4) < 0) break
5181
+ bytes.push(
5182
+ codePoint >> 0x12 | 0xF0,
5183
+ codePoint >> 0xC & 0x3F | 0x80,
5184
+ codePoint >> 0x6 & 0x3F | 0x80,
5185
+ codePoint & 0x3F | 0x80
5186
+ )
5187
+ } else {
5188
+ throw new Error('Invalid code point')
5189
+ }
5190
+ }
5191
+
5192
+ return bytes
5193
+ }
5194
+
5195
+ function asciiToBytes (str) {
5196
+ var byteArray = []
5197
+ for (var i = 0; i < str.length; ++i) {
5198
+ // Node's code seems to be doing this and not & 0x7F..
5199
+ byteArray.push(str.charCodeAt(i) & 0xFF)
5200
+ }
5201
+ return byteArray
5202
+ }
5203
+
5204
+ function utf16leToBytes (str, units) {
5205
+ var c, hi, lo
5206
+ var byteArray = []
5207
+ for (var i = 0; i < str.length; ++i) {
5208
+ if ((units -= 2) < 0) break
5209
+
5210
+ c = str.charCodeAt(i)
5211
+ hi = c >> 8
5212
+ lo = c % 256
5213
+ byteArray.push(lo)
5214
+ byteArray.push(hi)
5215
+ }
5216
+
5217
+ return byteArray
5218
+ }
5219
+
5220
+ function base64ToBytes (str) {
5221
+ return base64.toByteArray(base64clean(str))
5222
+ }
5223
+
5224
+ function blitBuffer (src, dst, offset, length) {
5225
+ for (var i = 0; i < length; ++i) {
5226
+ if ((i + offset >= dst.length) || (i >= src.length)) break
5227
+ dst[i + offset] = src[i]
5228
+ }
5229
+ return i
5230
+ }
5231
+
5232
+ // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
5233
+ // the `instanceof` check but they should be treated as of that type.
5234
+ // See: https://github.com/feross/buffer/issues/166
5235
+ function isInstance (obj, type) {
5236
+ return obj instanceof type ||
5237
+ (obj != null && obj.constructor != null && obj.constructor.name != null &&
5238
+ obj.constructor.name === type.name)
5239
+ }
5240
+ function numberIsNaN (obj) {
5241
+ // For IE11 support
5242
+ return obj !== obj // eslint-disable-line no-self-compare
5243
+ }
5244
+
5245
+ }).call(this)}).call(this,require("buffer").Buffer)
5246
+ },{"base64-js":45,"buffer":46,"ieee754":48}],47:[function(require,module,exports){
5247
+ // Copyright Joyent, Inc. and other Node contributors.
5248
+ //
5249
+ // Permission is hereby granted, free of charge, to any person obtaining a
5250
+ // copy of this software and associated documentation files (the
5251
+ // "Software"), to deal in the Software without restriction, including
5252
+ // without limitation the rights to use, copy, modify, merge, publish,
5253
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
5254
+ // persons to whom the Software is furnished to do so, subject to the
5255
+ // following conditions:
5256
+ //
5257
+ // The above copyright notice and this permission notice shall be included
5258
+ // in all copies or substantial portions of the Software.
5259
+ //
5260
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
5261
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
5262
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
5263
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
5264
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
5265
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
5266
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
5267
+
5268
+ 'use strict';
5269
+
5270
+ var R = typeof Reflect === 'object' ? Reflect : null
5271
+ var ReflectApply = R && typeof R.apply === 'function'
5272
+ ? R.apply
5273
+ : function ReflectApply(target, receiver, args) {
5274
+ return Function.prototype.apply.call(target, receiver, args);
5275
+ }
5276
+
5277
+ var ReflectOwnKeys
5278
+ if (R && typeof R.ownKeys === 'function') {
5279
+ ReflectOwnKeys = R.ownKeys
5280
+ } else if (Object.getOwnPropertySymbols) {
5281
+ ReflectOwnKeys = function ReflectOwnKeys(target) {
5282
+ return Object.getOwnPropertyNames(target)
5283
+ .concat(Object.getOwnPropertySymbols(target));
5284
+ };
5285
+ } else {
5286
+ ReflectOwnKeys = function ReflectOwnKeys(target) {
5287
+ return Object.getOwnPropertyNames(target);
5288
+ };
5289
+ }
5290
+
5291
+ function ProcessEmitWarning(warning) {
5292
+ if (console && console.warn) console.warn(warning);
5293
+ }
5294
+
5295
+ var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
5296
+ return value !== value;
5297
+ }
5298
+
5299
+ function EventEmitter() {
5300
+ EventEmitter.init.call(this);
5301
+ }
5302
+ module.exports = EventEmitter;
5303
+ module.exports.once = once;
5304
+
5305
+ // Backwards-compat with node 0.10.x
5306
+ EventEmitter.EventEmitter = EventEmitter;
5307
+
5308
+ EventEmitter.prototype._events = undefined;
5309
+ EventEmitter.prototype._eventsCount = 0;
5310
+ EventEmitter.prototype._maxListeners = undefined;
5311
+
5312
+ // By default EventEmitters will print a warning if more than 10 listeners are
5313
+ // added to it. This is a useful default which helps finding memory leaks.
5314
+ var defaultMaxListeners = 10;
5315
+
5316
+ function checkListener(listener) {
5317
+ if (typeof listener !== 'function') {
5318
+ throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
5319
+ }
5320
+ }
5321
+
5322
+ Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
5323
+ enumerable: true,
5324
+ get: function() {
5325
+ return defaultMaxListeners;
5326
+ },
5327
+ set: function(arg) {
5328
+ if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
5329
+ throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
5330
+ }
5331
+ defaultMaxListeners = arg;
5332
+ }
5333
+ });
5334
+
5335
+ EventEmitter.init = function() {
5336
+
5337
+ if (this._events === undefined ||
5338
+ this._events === Object.getPrototypeOf(this)._events) {
5339
+ this._events = Object.create(null);
5340
+ this._eventsCount = 0;
5341
+ }
5342
+
5343
+ this._maxListeners = this._maxListeners || undefined;
5344
+ };
5345
+
5346
+ // Obviously not all Emitters should be limited to 10. This function allows
5347
+ // that to be increased. Set to zero for unlimited.
5348
+ EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
5349
+ if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
5350
+ throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
5351
+ }
5352
+ this._maxListeners = n;
5353
+ return this;
5354
+ };
5355
+
5356
+ function _getMaxListeners(that) {
5357
+ if (that._maxListeners === undefined)
5358
+ return EventEmitter.defaultMaxListeners;
5359
+ return that._maxListeners;
5360
+ }
5361
+
5362
+ EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
5363
+ return _getMaxListeners(this);
5364
+ };
5365
+
5366
+ EventEmitter.prototype.emit = function emit(type) {
5367
+ var args = [];
5368
+ for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
5369
+ var doError = (type === 'error');
5370
+
5371
+ var events = this._events;
5372
+ if (events !== undefined)
5373
+ doError = (doError && events.error === undefined);
5374
+ else if (!doError)
5375
+ return false;
5376
+
5377
+ // If there is no 'error' event listener then throw.
5378
+ if (doError) {
5379
+ var er;
5380
+ if (args.length > 0)
5381
+ er = args[0];
5382
+ if (er instanceof Error) {
5383
+ // Note: The comments on the `throw` lines are intentional, they show
5384
+ // up in Node's output if this results in an unhandled exception.
5385
+ throw er; // Unhandled 'error' event
5386
+ }
5387
+ // At least give some kind of context to the user
5388
+ var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
5389
+ err.context = er;
5390
+ throw err; // Unhandled 'error' event
5391
+ }
5392
+
5393
+ var handler = events[type];
5394
+
5395
+ if (handler === undefined)
5396
+ return false;
5397
+
5398
+ if (typeof handler === 'function') {
5399
+ ReflectApply(handler, this, args);
5400
+ } else {
5401
+ var len = handler.length;
5402
+ var listeners = arrayClone(handler, len);
5403
+ for (var i = 0; i < len; ++i)
5404
+ ReflectApply(listeners[i], this, args);
5405
+ }
5406
+
5407
+ return true;
5408
+ };
5409
+
5410
+ function _addListener(target, type, listener, prepend) {
5411
+ var m;
5412
+ var events;
5413
+ var existing;
5414
+
5415
+ checkListener(listener);
5416
+
5417
+ events = target._events;
5418
+ if (events === undefined) {
5419
+ events = target._events = Object.create(null);
5420
+ target._eventsCount = 0;
5421
+ } else {
5422
+ // To avoid recursion in the case that type === "newListener"! Before
5423
+ // adding it to the listeners, first emit "newListener".
3340
5424
  if (events.newListener !== undefined) {
3341
5425
  target.emit('newListener', type,
3342
5426
  listener.listener ? listener.listener : listener);
@@ -3658,7 +5742,94 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
3658
5742
  }
3659
5743
  }
3660
5744
 
3661
- },{}],45:[function(require,module,exports){
5745
+ },{}],48:[function(require,module,exports){
5746
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
5747
+ exports.read = function (buffer, offset, isLE, mLen, nBytes) {
5748
+ var e, m
5749
+ var eLen = (nBytes * 8) - mLen - 1
5750
+ var eMax = (1 << eLen) - 1
5751
+ var eBias = eMax >> 1
5752
+ var nBits = -7
5753
+ var i = isLE ? (nBytes - 1) : 0
5754
+ var d = isLE ? -1 : 1
5755
+ var s = buffer[offset + i]
5756
+
5757
+ i += d
5758
+
5759
+ e = s & ((1 << (-nBits)) - 1)
5760
+ s >>= (-nBits)
5761
+ nBits += eLen
5762
+ for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
5763
+
5764
+ m = e & ((1 << (-nBits)) - 1)
5765
+ e >>= (-nBits)
5766
+ nBits += mLen
5767
+ for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
5768
+
5769
+ if (e === 0) {
5770
+ e = 1 - eBias
5771
+ } else if (e === eMax) {
5772
+ return m ? NaN : ((s ? -1 : 1) * Infinity)
5773
+ } else {
5774
+ m = m + Math.pow(2, mLen)
5775
+ e = e - eBias
5776
+ }
5777
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
5778
+ }
5779
+
5780
+ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
5781
+ var e, m, c
5782
+ var eLen = (nBytes * 8) - mLen - 1
5783
+ var eMax = (1 << eLen) - 1
5784
+ var eBias = eMax >> 1
5785
+ var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
5786
+ var i = isLE ? 0 : (nBytes - 1)
5787
+ var d = isLE ? 1 : -1
5788
+ var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
5789
+
5790
+ value = Math.abs(value)
5791
+
5792
+ if (isNaN(value) || value === Infinity) {
5793
+ m = isNaN(value) ? 1 : 0
5794
+ e = eMax
5795
+ } else {
5796
+ e = Math.floor(Math.log(value) / Math.LN2)
5797
+ if (value * (c = Math.pow(2, -e)) < 1) {
5798
+ e--
5799
+ c *= 2
5800
+ }
5801
+ if (e + eBias >= 1) {
5802
+ value += rt / c
5803
+ } else {
5804
+ value += rt * Math.pow(2, 1 - eBias)
5805
+ }
5806
+ if (value * c >= 2) {
5807
+ e++
5808
+ c /= 2
5809
+ }
5810
+
5811
+ if (e + eBias >= eMax) {
5812
+ m = 0
5813
+ e = eMax
5814
+ } else if (e + eBias >= 1) {
5815
+ m = ((value * c) - 1) * Math.pow(2, mLen)
5816
+ e = e + eBias
5817
+ } else {
5818
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
5819
+ e = 0
5820
+ }
5821
+ }
5822
+
5823
+ for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
5824
+
5825
+ e = (e << mLen) | m
5826
+ eLen += mLen
5827
+ for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
5828
+
5829
+ buffer[offset + i - d] |= s * 128
5830
+ }
5831
+
5832
+ },{}],49:[function(require,module,exports){
3662
5833
  // shim for using process in browser
3663
5834
  var process = module.exports = {};
3664
5835
 
@@ -3844,7 +6015,7 @@ process.chdir = function (dir) {
3844
6015
  };
3845
6016
  process.umask = function() { return 0; };
3846
6017
 
3847
- },{}],46:[function(require,module,exports){
6018
+ },{}],50:[function(require,module,exports){
3848
6019
  "use strict";
3849
6020
 
3850
6021
  Object.defineProperty(exports, "__esModule", {