axios 0.26.0 → 0.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/axios.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* axios v0.27.1 | (c) 2022 by Matt Zabriskie */
1
2
  (function webpackUniversalModuleDefinition(root, factory) {
2
3
  if(typeof exports === 'object' && typeof module === 'object')
3
4
  module.exports = factory();
@@ -124,9 +125,9 @@ var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./lib/helpers/b
124
125
  var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./lib/core/buildFullPath.js");
125
126
  var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./lib/helpers/parseHeaders.js");
126
127
  var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./lib/helpers/isURLSameOrigin.js");
127
- var createError = __webpack_require__(/*! ../core/createError */ "./lib/core/createError.js");
128
- var defaults = __webpack_require__(/*! ../defaults */ "./lib/defaults.js");
129
- var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./lib/cancel/Cancel.js");
128
+ var transitionalDefaults = __webpack_require__(/*! ../defaults/transitional */ "./lib/defaults/transitional.js");
129
+ var AxiosError = __webpack_require__(/*! ../core/AxiosError */ "./lib/core/AxiosError.js");
130
+ var CanceledError = __webpack_require__(/*! ../cancel/CanceledError */ "./lib/cancel/CanceledError.js");
130
131
 
131
132
  module.exports = function xhrAdapter(config) {
132
133
  return new Promise(function dispatchXhrRequest(resolve, reject) {
@@ -144,10 +145,6 @@ module.exports = function xhrAdapter(config) {
144
145
  }
145
146
  }
146
147
 
147
- if (utils.isFormData(requestData)) {
148
- delete requestHeaders['Content-Type']; // Let the browser set it
149
- }
150
-
151
148
  var request = new XMLHttpRequest();
152
149
 
153
150
  // HTTP basic authentication
@@ -158,6 +155,7 @@ module.exports = function xhrAdapter(config) {
158
155
  }
159
156
 
160
157
  var fullPath = buildFullPath(config.baseURL, config.url);
158
+
161
159
  request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
162
160
 
163
161
  // Set the request timeout in MS
@@ -221,7 +219,7 @@ module.exports = function xhrAdapter(config) {
221
219
  return;
222
220
  }
223
221
 
224
- reject(createError('Request aborted', config, 'ECONNABORTED', request));
222
+ reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
225
223
 
226
224
  // Clean up request
227
225
  request = null;
@@ -231,7 +229,7 @@ module.exports = function xhrAdapter(config) {
231
229
  request.onerror = function handleError() {
232
230
  // Real errors are hidden from us by the browser
233
231
  // onerror should only fire if it's a network error
234
- reject(createError('Network Error', config, null, request));
232
+ reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, request));
235
233
 
236
234
  // Clean up request
237
235
  request = null;
@@ -240,14 +238,14 @@ module.exports = function xhrAdapter(config) {
240
238
  // Handle timeout
241
239
  request.ontimeout = function handleTimeout() {
242
240
  var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
243
- var transitional = config.transitional || defaults.transitional;
241
+ var transitional = config.transitional || transitionalDefaults;
244
242
  if (config.timeoutErrorMessage) {
245
243
  timeoutErrorMessage = config.timeoutErrorMessage;
246
244
  }
247
- reject(createError(
245
+ reject(new AxiosError(
248
246
  timeoutErrorMessage,
247
+ transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
249
248
  config,
250
- transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
251
249
  request));
252
250
 
253
251
  // Clean up request
@@ -308,7 +306,7 @@ module.exports = function xhrAdapter(config) {
308
306
  if (!request) {
309
307
  return;
310
308
  }
311
- reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);
309
+ reject(!cancel || (cancel && cancel.type) ? new CanceledError() : cancel);
312
310
  request.abort();
313
311
  request = null;
314
312
  };
@@ -323,6 +321,15 @@ module.exports = function xhrAdapter(config) {
323
321
  requestData = null;
324
322
  }
325
323
 
324
+ var tokens = fullPath.split(':', 2);
325
+ var protocol = tokens.length > 1 && tokens[0];
326
+
327
+ if (protocol && [ 'http', 'https', 'file' ].indexOf(protocol) === -1) {
328
+ reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
329
+ return;
330
+ }
331
+
332
+
326
333
  // Send the request
327
334
  request.send(requestData);
328
335
  });
@@ -345,7 +352,7 @@ var utils = __webpack_require__(/*! ./utils */ "./lib/utils.js");
345
352
  var bind = __webpack_require__(/*! ./helpers/bind */ "./lib/helpers/bind.js");
346
353
  var Axios = __webpack_require__(/*! ./core/Axios */ "./lib/core/Axios.js");
347
354
  var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./lib/core/mergeConfig.js");
348
- var defaults = __webpack_require__(/*! ./defaults */ "./lib/defaults.js");
355
+ var defaults = __webpack_require__(/*! ./defaults */ "./lib/defaults/index.js");
349
356
 
350
357
  /**
351
358
  * Create an instance of Axios
@@ -378,10 +385,17 @@ var axios = createInstance(defaults);
378
385
  axios.Axios = Axios;
379
386
 
380
387
  // Expose Cancel & CancelToken
381
- axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./lib/cancel/Cancel.js");
388
+ axios.CanceledError = __webpack_require__(/*! ./cancel/CanceledError */ "./lib/cancel/CanceledError.js");
382
389
  axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./lib/cancel/CancelToken.js");
383
390
  axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./lib/cancel/isCancel.js");
384
391
  axios.VERSION = __webpack_require__(/*! ./env/data */ "./lib/env/data.js").version;
392
+ axios.toFormData = __webpack_require__(/*! ./helpers/toFormData */ "./lib/helpers/toFormData.js");
393
+
394
+ // Expose AxiosError class
395
+ axios.AxiosError = __webpack_require__(/*! ../lib/core/AxiosError */ "./lib/core/AxiosError.js");
396
+
397
+ // alias for CanceledError for backward compatibility
398
+ axios.Cancel = axios.CanceledError;
385
399
 
386
400
  // Expose all/spread
387
401
  axios.all = function all(promises) {
@@ -398,37 +412,6 @@ module.exports = axios;
398
412
  module.exports.default = axios;
399
413
 
400
414
 
401
- /***/ }),
402
-
403
- /***/ "./lib/cancel/Cancel.js":
404
- /*!******************************!*\
405
- !*** ./lib/cancel/Cancel.js ***!
406
- \******************************/
407
- /*! no static exports found */
408
- /***/ (function(module, exports, __webpack_require__) {
409
-
410
- "use strict";
411
-
412
-
413
- /**
414
- * A `Cancel` is an object that is thrown when an operation is canceled.
415
- *
416
- * @class
417
- * @param {string=} message The message.
418
- */
419
- function Cancel(message) {
420
- this.message = message;
421
- }
422
-
423
- Cancel.prototype.toString = function toString() {
424
- return 'Cancel' + (this.message ? ': ' + this.message : '');
425
- };
426
-
427
- Cancel.prototype.__CANCEL__ = true;
428
-
429
- module.exports = Cancel;
430
-
431
-
432
415
  /***/ }),
433
416
 
434
417
  /***/ "./lib/cancel/CancelToken.js":
@@ -441,7 +424,7 @@ module.exports = Cancel;
441
424
  "use strict";
442
425
 
443
426
 
444
- var Cancel = __webpack_require__(/*! ./Cancel */ "./lib/cancel/Cancel.js");
427
+ var CanceledError = __webpack_require__(/*! ./CanceledError */ "./lib/cancel/CanceledError.js");
445
428
 
446
429
  /**
447
430
  * A `CancelToken` is an object that can be used to request cancellation of an operation.
@@ -497,13 +480,13 @@ function CancelToken(executor) {
497
480
  return;
498
481
  }
499
482
 
500
- token.reason = new Cancel(message);
483
+ token.reason = new CanceledError(message);
501
484
  resolvePromise(token.reason);
502
485
  });
503
486
  }
504
487
 
505
488
  /**
506
- * Throws a `Cancel` if cancellation has been requested.
489
+ * Throws a `CanceledError` if cancellation has been requested.
507
490
  */
508
491
  CancelToken.prototype.throwIfRequested = function throwIfRequested() {
509
492
  if (this.reason) {
@@ -560,6 +543,40 @@ CancelToken.source = function source() {
560
543
  module.exports = CancelToken;
561
544
 
562
545
 
546
+ /***/ }),
547
+
548
+ /***/ "./lib/cancel/CanceledError.js":
549
+ /*!*************************************!*\
550
+ !*** ./lib/cancel/CanceledError.js ***!
551
+ \*************************************/
552
+ /*! no static exports found */
553
+ /***/ (function(module, exports, __webpack_require__) {
554
+
555
+ "use strict";
556
+
557
+
558
+ var AxiosError = __webpack_require__(/*! ../core/AxiosError */ "./lib/core/AxiosError.js");
559
+ var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
560
+
561
+ /**
562
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
563
+ *
564
+ * @class
565
+ * @param {string=} message The message.
566
+ */
567
+ function CanceledError(message) {
568
+ // eslint-disable-next-line no-eq-null,eqeqeq
569
+ AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED);
570
+ this.name = 'CanceledError';
571
+ }
572
+
573
+ utils.inherits(CanceledError, AxiosError, {
574
+ __CANCEL__: true
575
+ });
576
+
577
+ module.exports = CanceledError;
578
+
579
+
563
580
  /***/ }),
564
581
 
565
582
  /***/ "./lib/cancel/isCancel.js":
@@ -594,6 +611,7 @@ var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./lib/helpers/bui
594
611
  var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./lib/core/InterceptorManager.js");
595
612
  var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./lib/core/dispatchRequest.js");
596
613
  var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./lib/core/mergeConfig.js");
614
+ var buildFullPath = __webpack_require__(/*! ./buildFullPath */ "./lib/core/buildFullPath.js");
597
615
  var validator = __webpack_require__(/*! ../helpers/validator */ "./lib/helpers/validator.js");
598
616
 
599
617
  var validators = validator.validators;
@@ -708,7 +726,8 @@ Axios.prototype.request = function request(configOrUrl, config) {
708
726
 
709
727
  Axios.prototype.getUri = function getUri(config) {
710
728
  config = mergeConfig(this.defaults, config);
711
- return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
729
+ var fullPath = buildFullPath(config.baseURL, config.url);
730
+ return buildURL(fullPath, config.params, config.paramsSerializer);
712
731
  };
713
732
 
714
733
  // Provide aliases for supported request methods
@@ -725,18 +744,126 @@ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData
725
744
 
726
745
  utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
727
746
  /*eslint func-names:0*/
728
- Axios.prototype[method] = function(url, data, config) {
729
- return this.request(mergeConfig(config || {}, {
730
- method: method,
731
- url: url,
732
- data: data
733
- }));
734
- };
747
+
748
+ function generateHTTPMethod(isForm) {
749
+ return function httpMethod(url, data, config) {
750
+ return this.request(mergeConfig(config || {}, {
751
+ method: method,
752
+ headers: isForm ? {
753
+ 'Content-Type': 'multipart/form-data'
754
+ } : {},
755
+ url: url,
756
+ data: data
757
+ }));
758
+ };
759
+ }
760
+
761
+ Axios.prototype[method] = generateHTTPMethod();
762
+
763
+ Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
735
764
  });
736
765
 
737
766
  module.exports = Axios;
738
767
 
739
768
 
769
+ /***/ }),
770
+
771
+ /***/ "./lib/core/AxiosError.js":
772
+ /*!********************************!*\
773
+ !*** ./lib/core/AxiosError.js ***!
774
+ \********************************/
775
+ /*! no static exports found */
776
+ /***/ (function(module, exports, __webpack_require__) {
777
+
778
+ "use strict";
779
+
780
+
781
+ var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
782
+
783
+ /**
784
+ * Create an Error with the specified message, config, error code, request and response.
785
+ *
786
+ * @param {string} message The error message.
787
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
788
+ * @param {Object} [config] The config.
789
+ * @param {Object} [request] The request.
790
+ * @param {Object} [response] The response.
791
+ * @returns {Error} The created error.
792
+ */
793
+ function AxiosError(message, code, config, request, response) {
794
+ Error.call(this);
795
+ this.message = message;
796
+ this.name = 'AxiosError';
797
+ code && (this.code = code);
798
+ config && (this.config = config);
799
+ request && (this.request = request);
800
+ response && (this.response = response);
801
+ }
802
+
803
+ utils.inherits(AxiosError, Error, {
804
+ toJSON: function toJSON() {
805
+ return {
806
+ // Standard
807
+ message: this.message,
808
+ name: this.name,
809
+ // Microsoft
810
+ description: this.description,
811
+ number: this.number,
812
+ // Mozilla
813
+ fileName: this.fileName,
814
+ lineNumber: this.lineNumber,
815
+ columnNumber: this.columnNumber,
816
+ stack: this.stack,
817
+ // Axios
818
+ config: this.config,
819
+ code: this.code,
820
+ status: this.response && this.response.status ? this.response.status : null
821
+ };
822
+ }
823
+ });
824
+
825
+ var prototype = AxiosError.prototype;
826
+ var descriptors = {};
827
+
828
+ [
829
+ 'ERR_BAD_OPTION_VALUE',
830
+ 'ERR_BAD_OPTION',
831
+ 'ECONNABORTED',
832
+ 'ETIMEDOUT',
833
+ 'ERR_NETWORK',
834
+ 'ERR_FR_TOO_MANY_REDIRECTS',
835
+ 'ERR_DEPRECATED',
836
+ 'ERR_BAD_RESPONSE',
837
+ 'ERR_BAD_REQUEST',
838
+ 'ERR_CANCELED'
839
+ // eslint-disable-next-line func-names
840
+ ].forEach(function(code) {
841
+ descriptors[code] = {value: code};
842
+ });
843
+
844
+ Object.defineProperties(AxiosError, descriptors);
845
+ Object.defineProperty(prototype, 'isAxiosError', {value: true});
846
+
847
+ // eslint-disable-next-line func-names
848
+ AxiosError.from = function(error, code, config, request, response, customProps) {
849
+ var axiosError = Object.create(prototype);
850
+
851
+ utils.toFlatObject(error, axiosError, function filter(obj) {
852
+ return obj !== Error.prototype;
853
+ });
854
+
855
+ AxiosError.call(axiosError, error.message, code, config, request, response);
856
+
857
+ axiosError.name = error.name;
858
+
859
+ customProps && Object.assign(axiosError, customProps);
860
+
861
+ return axiosError;
862
+ };
863
+
864
+ module.exports = AxiosError;
865
+
866
+
740
867
  /***/ }),
741
868
 
742
869
  /***/ "./lib/core/InterceptorManager.js":
@@ -835,36 +962,6 @@ module.exports = function buildFullPath(baseURL, requestedURL) {
835
962
  };
836
963
 
837
964
 
838
- /***/ }),
839
-
840
- /***/ "./lib/core/createError.js":
841
- /*!*********************************!*\
842
- !*** ./lib/core/createError.js ***!
843
- \*********************************/
844
- /*! no static exports found */
845
- /***/ (function(module, exports, __webpack_require__) {
846
-
847
- "use strict";
848
-
849
-
850
- var enhanceError = __webpack_require__(/*! ./enhanceError */ "./lib/core/enhanceError.js");
851
-
852
- /**
853
- * Create an Error with the specified message, config, error code, request and response.
854
- *
855
- * @param {string} message The error message.
856
- * @param {Object} config The config.
857
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
858
- * @param {Object} [request] The request.
859
- * @param {Object} [response] The response.
860
- * @returns {Error} The created error.
861
- */
862
- module.exports = function createError(message, config, code, request, response) {
863
- var error = new Error(message);
864
- return enhanceError(error, config, code, request, response);
865
- };
866
-
867
-
868
965
  /***/ }),
869
966
 
870
967
  /***/ "./lib/core/dispatchRequest.js":
@@ -880,11 +977,11 @@ module.exports = function createError(message, config, code, request, response)
880
977
  var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
881
978
  var transformData = __webpack_require__(/*! ./transformData */ "./lib/core/transformData.js");
882
979
  var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./lib/cancel/isCancel.js");
883
- var defaults = __webpack_require__(/*! ../defaults */ "./lib/defaults.js");
884
- var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./lib/cancel/Cancel.js");
980
+ var defaults = __webpack_require__(/*! ../defaults */ "./lib/defaults/index.js");
981
+ var CanceledError = __webpack_require__(/*! ../cancel/CanceledError */ "./lib/cancel/CanceledError.js");
885
982
 
886
983
  /**
887
- * Throws a `Cancel` if cancellation has been requested.
984
+ * Throws a `CanceledError` if cancellation has been requested.
888
985
  */
889
986
  function throwIfCancellationRequested(config) {
890
987
  if (config.cancelToken) {
@@ -892,7 +989,7 @@ function throwIfCancellationRequested(config) {
892
989
  }
893
990
 
894
991
  if (config.signal && config.signal.aborted) {
895
- throw new Cancel('canceled');
992
+ throw new CanceledError();
896
993
  }
897
994
  }
898
995
 
@@ -964,61 +1061,6 @@ module.exports = function dispatchRequest(config) {
964
1061
  };
965
1062
 
966
1063
 
967
- /***/ }),
968
-
969
- /***/ "./lib/core/enhanceError.js":
970
- /*!**********************************!*\
971
- !*** ./lib/core/enhanceError.js ***!
972
- \**********************************/
973
- /*! no static exports found */
974
- /***/ (function(module, exports, __webpack_require__) {
975
-
976
- "use strict";
977
-
978
-
979
- /**
980
- * Update an Error with the specified config, error code, and response.
981
- *
982
- * @param {Error} error The error to update.
983
- * @param {Object} config The config.
984
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
985
- * @param {Object} [request] The request.
986
- * @param {Object} [response] The response.
987
- * @returns {Error} The error.
988
- */
989
- module.exports = function enhanceError(error, config, code, request, response) {
990
- error.config = config;
991
- if (code) {
992
- error.code = code;
993
- }
994
-
995
- error.request = request;
996
- error.response = response;
997
- error.isAxiosError = true;
998
-
999
- error.toJSON = function toJSON() {
1000
- return {
1001
- // Standard
1002
- message: this.message,
1003
- name: this.name,
1004
- // Microsoft
1005
- description: this.description,
1006
- number: this.number,
1007
- // Mozilla
1008
- fileName: this.fileName,
1009
- lineNumber: this.lineNumber,
1010
- columnNumber: this.columnNumber,
1011
- stack: this.stack,
1012
- // Axios
1013
- config: this.config,
1014
- code: this.code,
1015
- status: this.response && this.response.status ? this.response.status : null
1016
- };
1017
- };
1018
- return error;
1019
- };
1020
-
1021
-
1022
1064
  /***/ }),
1023
1065
 
1024
1066
  /***/ "./lib/core/mergeConfig.js":
@@ -1111,6 +1153,7 @@ module.exports = function mergeConfig(config1, config2) {
1111
1153
  'decompress': defaultToConfig2,
1112
1154
  'maxContentLength': defaultToConfig2,
1113
1155
  'maxBodyLength': defaultToConfig2,
1156
+ 'beforeRedirect': defaultToConfig2,
1114
1157
  'transport': defaultToConfig2,
1115
1158
  'httpAgent': defaultToConfig2,
1116
1159
  'httpsAgent': defaultToConfig2,
@@ -1142,7 +1185,7 @@ module.exports = function mergeConfig(config1, config2) {
1142
1185
  "use strict";
1143
1186
 
1144
1187
 
1145
- var createError = __webpack_require__(/*! ./createError */ "./lib/core/createError.js");
1188
+ var AxiosError = __webpack_require__(/*! ./AxiosError */ "./lib/core/AxiosError.js");
1146
1189
 
1147
1190
  /**
1148
1191
  * Resolve or reject a Promise based on response status.
@@ -1156,10 +1199,10 @@ module.exports = function settle(resolve, reject, response) {
1156
1199
  if (!response.status || !validateStatus || validateStatus(response.status)) {
1157
1200
  resolve(response);
1158
1201
  } else {
1159
- reject(createError(
1202
+ reject(new AxiosError(
1160
1203
  'Request failed with status code ' + response.status,
1204
+ [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
1161
1205
  response.config,
1162
- null,
1163
1206
  response.request,
1164
1207
  response
1165
1208
  ));
@@ -1180,7 +1223,7 @@ module.exports = function settle(resolve, reject, response) {
1180
1223
 
1181
1224
 
1182
1225
  var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
1183
- var defaults = __webpack_require__(/*! ./../defaults */ "./lib/defaults.js");
1226
+ var defaults = __webpack_require__(/*! ../defaults */ "./lib/defaults/index.js");
1184
1227
 
1185
1228
  /**
1186
1229
  * Transform the data for a request or a response
@@ -1203,19 +1246,21 @@ module.exports = function transformData(data, headers, fns) {
1203
1246
 
1204
1247
  /***/ }),
1205
1248
 
1206
- /***/ "./lib/defaults.js":
1207
- /*!*************************!*\
1208
- !*** ./lib/defaults.js ***!
1209
- \*************************/
1249
+ /***/ "./lib/defaults/index.js":
1250
+ /*!*******************************!*\
1251
+ !*** ./lib/defaults/index.js ***!
1252
+ \*******************************/
1210
1253
  /*! no static exports found */
1211
1254
  /***/ (function(module, exports, __webpack_require__) {
1212
1255
 
1213
1256
  "use strict";
1214
1257
 
1215
1258
 
1216
- var utils = __webpack_require__(/*! ./utils */ "./lib/utils.js");
1217
- var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./lib/helpers/normalizeHeaderName.js");
1218
- var enhanceError = __webpack_require__(/*! ./core/enhanceError */ "./lib/core/enhanceError.js");
1259
+ var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
1260
+ var normalizeHeaderName = __webpack_require__(/*! ../helpers/normalizeHeaderName */ "./lib/helpers/normalizeHeaderName.js");
1261
+ var AxiosError = __webpack_require__(/*! ../core/AxiosError */ "./lib/core/AxiosError.js");
1262
+ var transitionalDefaults = __webpack_require__(/*! ./transitional */ "./lib/defaults/transitional.js");
1263
+ var toFormData = __webpack_require__(/*! ../helpers/toFormData */ "./lib/helpers/toFormData.js");
1219
1264
 
1220
1265
  var DEFAULT_CONTENT_TYPE = {
1221
1266
  'Content-Type': 'application/x-www-form-urlencoded'
@@ -1231,10 +1276,10 @@ function getDefaultAdapter() {
1231
1276
  var adapter;
1232
1277
  if (typeof XMLHttpRequest !== 'undefined') {
1233
1278
  // For browsers use XHR adapter
1234
- adapter = __webpack_require__(/*! ./adapters/xhr */ "./lib/adapters/xhr.js");
1279
+ adapter = __webpack_require__(/*! ../adapters/xhr */ "./lib/adapters/xhr.js");
1235
1280
  } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
1236
1281
  // For node use HTTP adapter
1237
- adapter = __webpack_require__(/*! ./adapters/http */ "./lib/adapters/xhr.js");
1282
+ adapter = __webpack_require__(/*! ../adapters/http */ "./lib/adapters/xhr.js");
1238
1283
  }
1239
1284
  return adapter;
1240
1285
  }
@@ -1256,11 +1301,7 @@ function stringifySafely(rawValue, parser, encoder) {
1256
1301
 
1257
1302
  var defaults = {
1258
1303
 
1259
- transitional: {
1260
- silentJSONParsing: true,
1261
- forcedJSONParsing: true,
1262
- clarifyTimeoutError: false
1263
- },
1304
+ transitional: transitionalDefaults,
1264
1305
 
1265
1306
  adapter: getDefaultAdapter(),
1266
1307
 
@@ -1284,10 +1325,20 @@ var defaults = {
1284
1325
  setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
1285
1326
  return data.toString();
1286
1327
  }
1287
- if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
1328
+
1329
+ var isObjectPayload = utils.isObject(data);
1330
+ var contentType = headers && headers['Content-Type'];
1331
+
1332
+ var isFileList;
1333
+
1334
+ if ((isFileList = utils.isFileList(data)) || (isObjectPayload && contentType === 'multipart/form-data')) {
1335
+ var _FormData = this.env && this.env.FormData;
1336
+ return toFormData(isFileList ? {'files[]': data} : data, _FormData && new _FormData());
1337
+ } else if (isObjectPayload || contentType === 'application/json') {
1288
1338
  setContentTypeIfUnset(headers, 'application/json');
1289
1339
  return stringifySafely(data);
1290
1340
  }
1341
+
1291
1342
  return data;
1292
1343
  }],
1293
1344
 
@@ -1303,7 +1354,7 @@ var defaults = {
1303
1354
  } catch (e) {
1304
1355
  if (strictJSONParsing) {
1305
1356
  if (e.name === 'SyntaxError') {
1306
- throw enhanceError(e, this, 'E_JSON_PARSE');
1357
+ throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
1307
1358
  }
1308
1359
  throw e;
1309
1360
  }
@@ -1325,6 +1376,10 @@ var defaults = {
1325
1376
  maxContentLength: -1,
1326
1377
  maxBodyLength: -1,
1327
1378
 
1379
+ env: {
1380
+ FormData: __webpack_require__(/*! ./env/FormData */ "./lib/helpers/null.js")
1381
+ },
1382
+
1328
1383
  validateStatus: function validateStatus(status) {
1329
1384
  return status >= 200 && status < 300;
1330
1385
  },
@@ -1347,6 +1402,25 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1347
1402
  module.exports = defaults;
1348
1403
 
1349
1404
 
1405
+ /***/ }),
1406
+
1407
+ /***/ "./lib/defaults/transitional.js":
1408
+ /*!**************************************!*\
1409
+ !*** ./lib/defaults/transitional.js ***!
1410
+ \**************************************/
1411
+ /*! no static exports found */
1412
+ /***/ (function(module, exports, __webpack_require__) {
1413
+
1414
+ "use strict";
1415
+
1416
+
1417
+ module.exports = {
1418
+ silentJSONParsing: true,
1419
+ forcedJSONParsing: true,
1420
+ clarifyTimeoutError: false
1421
+ };
1422
+
1423
+
1350
1424
  /***/ }),
1351
1425
 
1352
1426
  /***/ "./lib/env/data.js":
@@ -1357,7 +1431,7 @@ module.exports = defaults;
1357
1431
  /***/ (function(module, exports) {
1358
1432
 
1359
1433
  module.exports = {
1360
- "version": "0.26.0"
1434
+ "version": "0.27.1"
1361
1435
  };
1362
1436
 
1363
1437
  /***/ }),
@@ -1711,6 +1785,19 @@ module.exports = function normalizeHeaderName(headers, normalizedName) {
1711
1785
  };
1712
1786
 
1713
1787
 
1788
+ /***/ }),
1789
+
1790
+ /***/ "./lib/helpers/null.js":
1791
+ /*!*****************************!*\
1792
+ !*** ./lib/helpers/null.js ***!
1793
+ \*****************************/
1794
+ /*! no static exports found */
1795
+ /***/ (function(module, exports) {
1796
+
1797
+ // eslint-disable-next-line strict
1798
+ module.exports = null;
1799
+
1800
+
1714
1801
  /***/ }),
1715
1802
 
1716
1803
  /***/ "./lib/helpers/parseHeaders.js":
@@ -1817,48 +1904,137 @@ module.exports = function spread(callback) {
1817
1904
 
1818
1905
  /***/ }),
1819
1906
 
1820
- /***/ "./lib/helpers/validator.js":
1821
- /*!**********************************!*\
1822
- !*** ./lib/helpers/validator.js ***!
1823
- \**********************************/
1907
+ /***/ "./lib/helpers/toFormData.js":
1908
+ /*!***********************************!*\
1909
+ !*** ./lib/helpers/toFormData.js ***!
1910
+ \***********************************/
1824
1911
  /*! no static exports found */
1825
1912
  /***/ (function(module, exports, __webpack_require__) {
1826
1913
 
1827
1914
  "use strict";
1915
+ /* WEBPACK VAR INJECTION */(function(Buffer) {
1828
1916
 
1917
+ var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
1829
1918
 
1830
- var VERSION = __webpack_require__(/*! ../env/data */ "./lib/env/data.js").version;
1919
+ /**
1920
+ * Convert a data object to FormData
1921
+ * @param {Object} obj
1922
+ * @param {?Object} [formData]
1923
+ * @returns {Object}
1924
+ **/
1831
1925
 
1832
- var validators = {};
1926
+ function toFormData(obj, formData) {
1927
+ // eslint-disable-next-line no-param-reassign
1928
+ formData = formData || new FormData();
1833
1929
 
1834
- // eslint-disable-next-line func-names
1835
- ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
1836
- validators[type] = function validator(thing) {
1837
- return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
1838
- };
1839
- });
1930
+ var stack = [];
1840
1931
 
1841
- var deprecatedWarnings = {};
1932
+ function convertValue(value) {
1933
+ if (value === null) return '';
1842
1934
 
1843
- /**
1844
- * Transitional option validator
1845
- * @param {function|boolean?} validator - set to false if the transitional option has been removed
1846
- * @param {string?} version - deprecated version / removed since version
1847
- * @param {string?} message - some message with additional info
1848
- * @returns {function}
1849
- */
1850
- validators.transitional = function transitional(validator, version, message) {
1851
- function formatMessage(opt, desc) {
1852
- return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
1853
- }
1935
+ if (utils.isDate(value)) {
1936
+ return value.toISOString();
1937
+ }
1854
1938
 
1855
- // eslint-disable-next-line func-names
1856
- return function(value, opt, opts) {
1857
- if (validator === false) {
1858
- throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
1939
+ if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
1940
+ return typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
1859
1941
  }
1860
1942
 
1861
- if (version && !deprecatedWarnings[opt]) {
1943
+ return value;
1944
+ }
1945
+
1946
+ function build(data, parentKey) {
1947
+ if (utils.isPlainObject(data) || utils.isArray(data)) {
1948
+ if (stack.indexOf(data) !== -1) {
1949
+ throw Error('Circular reference detected in ' + parentKey);
1950
+ }
1951
+
1952
+ stack.push(data);
1953
+
1954
+ utils.forEach(data, function each(value, key) {
1955
+ if (utils.isUndefined(value)) return;
1956
+ var fullKey = parentKey ? parentKey + '.' + key : key;
1957
+ var arr;
1958
+
1959
+ if (value && !parentKey && typeof value === 'object') {
1960
+ if (utils.endsWith(key, '{}')) {
1961
+ // eslint-disable-next-line no-param-reassign
1962
+ value = JSON.stringify(value);
1963
+ } else if (utils.endsWith(key, '[]') && (arr = utils.toArray(value))) {
1964
+ // eslint-disable-next-line func-names
1965
+ arr.forEach(function(el) {
1966
+ !utils.isUndefined(el) && formData.append(fullKey, convertValue(el));
1967
+ });
1968
+ return;
1969
+ }
1970
+ }
1971
+
1972
+ build(value, fullKey);
1973
+ });
1974
+
1975
+ stack.pop();
1976
+ } else {
1977
+ formData.append(parentKey, convertValue(data));
1978
+ }
1979
+ }
1980
+
1981
+ build(obj);
1982
+
1983
+ return formData;
1984
+ }
1985
+
1986
+ module.exports = toFormData;
1987
+
1988
+ /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/node-libs-browser/node_modules/buffer/index.js */ "./node_modules/node-libs-browser/node_modules/buffer/index.js").Buffer))
1989
+
1990
+ /***/ }),
1991
+
1992
+ /***/ "./lib/helpers/validator.js":
1993
+ /*!**********************************!*\
1994
+ !*** ./lib/helpers/validator.js ***!
1995
+ \**********************************/
1996
+ /*! no static exports found */
1997
+ /***/ (function(module, exports, __webpack_require__) {
1998
+
1999
+ "use strict";
2000
+
2001
+
2002
+ var VERSION = __webpack_require__(/*! ../env/data */ "./lib/env/data.js").version;
2003
+ var AxiosError = __webpack_require__(/*! ../core/AxiosError */ "./lib/core/AxiosError.js");
2004
+
2005
+ var validators = {};
2006
+
2007
+ // eslint-disable-next-line func-names
2008
+ ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
2009
+ validators[type] = function validator(thing) {
2010
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
2011
+ };
2012
+ });
2013
+
2014
+ var deprecatedWarnings = {};
2015
+
2016
+ /**
2017
+ * Transitional option validator
2018
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
2019
+ * @param {string?} version - deprecated version / removed since version
2020
+ * @param {string?} message - some message with additional info
2021
+ * @returns {function}
2022
+ */
2023
+ validators.transitional = function transitional(validator, version, message) {
2024
+ function formatMessage(opt, desc) {
2025
+ return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
2026
+ }
2027
+
2028
+ // eslint-disable-next-line func-names
2029
+ return function(value, opt, opts) {
2030
+ if (validator === false) {
2031
+ throw new AxiosError(
2032
+ formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
2033
+ AxiosError.ERR_DEPRECATED
2034
+ );
2035
+ }
2036
+
2037
+ if (version && !deprecatedWarnings[opt]) {
1862
2038
  deprecatedWarnings[opt] = true;
1863
2039
  // eslint-disable-next-line no-console
1864
2040
  console.warn(
@@ -1882,7 +2058,7 @@ validators.transitional = function transitional(validator, version, message) {
1882
2058
 
1883
2059
  function assertOptions(options, schema, allowUnknown) {
1884
2060
  if (typeof options !== 'object') {
1885
- throw new TypeError('options must be an object');
2061
+ throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
1886
2062
  }
1887
2063
  var keys = Object.keys(options);
1888
2064
  var i = keys.length;
@@ -1893,12 +2069,12 @@ function assertOptions(options, schema, allowUnknown) {
1893
2069
  var value = options[opt];
1894
2070
  var result = value === undefined || validator(value, opt, options);
1895
2071
  if (result !== true) {
1896
- throw new TypeError('option ' + opt + ' must be ' + result);
2072
+ throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
1897
2073
  }
1898
2074
  continue;
1899
2075
  }
1900
2076
  if (allowUnknown !== true) {
1901
- throw Error('Unknown option ' + opt);
2077
+ throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
1902
2078
  }
1903
2079
  }
1904
2080
  }
@@ -1927,6 +2103,22 @@ var bind = __webpack_require__(/*! ./helpers/bind */ "./lib/helpers/bind.js");
1927
2103
 
1928
2104
  var toString = Object.prototype.toString;
1929
2105
 
2106
+ // eslint-disable-next-line func-names
2107
+ var kindOf = (function(cache) {
2108
+ // eslint-disable-next-line func-names
2109
+ return function(thing) {
2110
+ var str = toString.call(thing);
2111
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
2112
+ };
2113
+ })(Object.create(null));
2114
+
2115
+ function kindOfTest(type) {
2116
+ type = type.toLowerCase();
2117
+ return function isKindOf(thing) {
2118
+ return kindOf(thing) === type;
2119
+ };
2120
+ }
2121
+
1930
2122
  /**
1931
2123
  * Determine if a value is an Array
1932
2124
  *
@@ -1961,22 +2153,12 @@ function isBuffer(val) {
1961
2153
  /**
1962
2154
  * Determine if a value is an ArrayBuffer
1963
2155
  *
2156
+ * @function
1964
2157
  * @param {Object} val The value to test
1965
2158
  * @returns {boolean} True if value is an ArrayBuffer, otherwise false
1966
2159
  */
1967
- function isArrayBuffer(val) {
1968
- return toString.call(val) === '[object ArrayBuffer]';
1969
- }
2160
+ var isArrayBuffer = kindOfTest('ArrayBuffer');
1970
2161
 
1971
- /**
1972
- * Determine if a value is a FormData
1973
- *
1974
- * @param {Object} val The value to test
1975
- * @returns {boolean} True if value is an FormData, otherwise false
1976
- */
1977
- function isFormData(val) {
1978
- return toString.call(val) === '[object FormData]';
1979
- }
1980
2162
 
1981
2163
  /**
1982
2164
  * Determine if a value is a view on an ArrayBuffer
@@ -2031,7 +2213,7 @@ function isObject(val) {
2031
2213
  * @return {boolean} True if value is a plain Object, otherwise false
2032
2214
  */
2033
2215
  function isPlainObject(val) {
2034
- if (toString.call(val) !== '[object Object]') {
2216
+ if (kindOf(val) !== 'object') {
2035
2217
  return false;
2036
2218
  }
2037
2219
 
@@ -2042,32 +2224,38 @@ function isPlainObject(val) {
2042
2224
  /**
2043
2225
  * Determine if a value is a Date
2044
2226
  *
2227
+ * @function
2045
2228
  * @param {Object} val The value to test
2046
2229
  * @returns {boolean} True if value is a Date, otherwise false
2047
2230
  */
2048
- function isDate(val) {
2049
- return toString.call(val) === '[object Date]';
2050
- }
2231
+ var isDate = kindOfTest('Date');
2051
2232
 
2052
2233
  /**
2053
2234
  * Determine if a value is a File
2054
2235
  *
2236
+ * @function
2055
2237
  * @param {Object} val The value to test
2056
2238
  * @returns {boolean} True if value is a File, otherwise false
2057
2239
  */
2058
- function isFile(val) {
2059
- return toString.call(val) === '[object File]';
2060
- }
2240
+ var isFile = kindOfTest('File');
2061
2241
 
2062
2242
  /**
2063
2243
  * Determine if a value is a Blob
2064
2244
  *
2245
+ * @function
2065
2246
  * @param {Object} val The value to test
2066
2247
  * @returns {boolean} True if value is a Blob, otherwise false
2067
2248
  */
2068
- function isBlob(val) {
2069
- return toString.call(val) === '[object Blob]';
2070
- }
2249
+ var isBlob = kindOfTest('Blob');
2250
+
2251
+ /**
2252
+ * Determine if a value is a FileList
2253
+ *
2254
+ * @function
2255
+ * @param {Object} val The value to test
2256
+ * @returns {boolean} True if value is a File, otherwise false
2257
+ */
2258
+ var isFileList = kindOfTest('FileList');
2071
2259
 
2072
2260
  /**
2073
2261
  * Determine if a value is a Function
@@ -2090,14 +2278,27 @@ function isStream(val) {
2090
2278
  }
2091
2279
 
2092
2280
  /**
2093
- * Determine if a value is a URLSearchParams object
2281
+ * Determine if a value is a FormData
2094
2282
  *
2283
+ * @param {Object} thing The value to test
2284
+ * @returns {boolean} True if value is an FormData, otherwise false
2285
+ */
2286
+ function isFormData(thing) {
2287
+ var pattern = '[object FormData]';
2288
+ return thing && (
2289
+ (typeof FormData === 'function' && thing instanceof FormData) ||
2290
+ toString.call(thing) === pattern ||
2291
+ (isFunction(thing.toString) && thing.toString() === pattern)
2292
+ );
2293
+ }
2294
+
2295
+ /**
2296
+ * Determine if a value is a URLSearchParams object
2297
+ * @function
2095
2298
  * @param {Object} val The value to test
2096
2299
  * @returns {boolean} True if value is a URLSearchParams object, otherwise false
2097
2300
  */
2098
- function isURLSearchParams(val) {
2099
- return toString.call(val) === '[object URLSearchParams]';
2100
- }
2301
+ var isURLSearchParams = kindOfTest('URLSearchParams');
2101
2302
 
2102
2303
  /**
2103
2304
  * Trim excess whitespace off the beginning and end of a string
@@ -2244,6 +2445,94 @@ function stripBOM(content) {
2244
2445
  return content;
2245
2446
  }
2246
2447
 
2448
+ /**
2449
+ * Inherit the prototype methods from one constructor into another
2450
+ * @param {function} constructor
2451
+ * @param {function} superConstructor
2452
+ * @param {object} [props]
2453
+ * @param {object} [descriptors]
2454
+ */
2455
+
2456
+ function inherits(constructor, superConstructor, props, descriptors) {
2457
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors);
2458
+ constructor.prototype.constructor = constructor;
2459
+ props && Object.assign(constructor.prototype, props);
2460
+ }
2461
+
2462
+ /**
2463
+ * Resolve object with deep prototype chain to a flat object
2464
+ * @param {Object} sourceObj source object
2465
+ * @param {Object} [destObj]
2466
+ * @param {Function} [filter]
2467
+ * @returns {Object}
2468
+ */
2469
+
2470
+ function toFlatObject(sourceObj, destObj, filter) {
2471
+ var props;
2472
+ var i;
2473
+ var prop;
2474
+ var merged = {};
2475
+
2476
+ destObj = destObj || {};
2477
+
2478
+ do {
2479
+ props = Object.getOwnPropertyNames(sourceObj);
2480
+ i = props.length;
2481
+ while (i-- > 0) {
2482
+ prop = props[i];
2483
+ if (!merged[prop]) {
2484
+ destObj[prop] = sourceObj[prop];
2485
+ merged[prop] = true;
2486
+ }
2487
+ }
2488
+ sourceObj = Object.getPrototypeOf(sourceObj);
2489
+ } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
2490
+
2491
+ return destObj;
2492
+ }
2493
+
2494
+ /*
2495
+ * determines whether a string ends with the characters of a specified string
2496
+ * @param {String} str
2497
+ * @param {String} searchString
2498
+ * @param {Number} [position= 0]
2499
+ * @returns {boolean}
2500
+ */
2501
+ function endsWith(str, searchString, position) {
2502
+ str = String(str);
2503
+ if (position === undefined || position > str.length) {
2504
+ position = str.length;
2505
+ }
2506
+ position -= searchString.length;
2507
+ var lastIndex = str.indexOf(searchString, position);
2508
+ return lastIndex !== -1 && lastIndex === position;
2509
+ }
2510
+
2511
+
2512
+ /**
2513
+ * Returns new array from array like object
2514
+ * @param {*} [thing]
2515
+ * @returns {Array}
2516
+ */
2517
+ function toArray(thing) {
2518
+ if (!thing) return null;
2519
+ var i = thing.length;
2520
+ if (isUndefined(i)) return null;
2521
+ var arr = new Array(i);
2522
+ while (i-- > 0) {
2523
+ arr[i] = thing[i];
2524
+ }
2525
+ return arr;
2526
+ }
2527
+
2528
+ // eslint-disable-next-line func-names
2529
+ var isTypedArray = (function(TypedArray) {
2530
+ // eslint-disable-next-line func-names
2531
+ return function(thing) {
2532
+ return TypedArray && thing instanceof TypedArray;
2533
+ };
2534
+ })(typeof Uint8Array !== 'undefined' && Object.getPrototypeOf(Uint8Array));
2535
+
2247
2536
  module.exports = {
2248
2537
  isArray: isArray,
2249
2538
  isArrayBuffer: isArrayBuffer,
@@ -2266,10 +2555,2125 @@ module.exports = {
2266
2555
  merge: merge,
2267
2556
  extend: extend,
2268
2557
  trim: trim,
2269
- stripBOM: stripBOM
2558
+ stripBOM: stripBOM,
2559
+ inherits: inherits,
2560
+ toFlatObject: toFlatObject,
2561
+ kindOf: kindOf,
2562
+ kindOfTest: kindOfTest,
2563
+ endsWith: endsWith,
2564
+ toArray: toArray,
2565
+ isTypedArray: isTypedArray,
2566
+ isFileList: isFileList
2270
2567
  };
2271
2568
 
2272
2569
 
2570
+ /***/ }),
2571
+
2572
+ /***/ "./node_modules/base64-js/index.js":
2573
+ /*!*****************************************!*\
2574
+ !*** ./node_modules/base64-js/index.js ***!
2575
+ \*****************************************/
2576
+ /*! no static exports found */
2577
+ /***/ (function(module, exports, __webpack_require__) {
2578
+
2579
+ "use strict";
2580
+
2581
+
2582
+ exports.byteLength = byteLength
2583
+ exports.toByteArray = toByteArray
2584
+ exports.fromByteArray = fromByteArray
2585
+
2586
+ var lookup = []
2587
+ var revLookup = []
2588
+ var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
2589
+
2590
+ var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
2591
+ for (var i = 0, len = code.length; i < len; ++i) {
2592
+ lookup[i] = code[i]
2593
+ revLookup[code.charCodeAt(i)] = i
2594
+ }
2595
+
2596
+ // Support decoding URL-safe base64 strings, as Node.js does.
2597
+ // See: https://en.wikipedia.org/wiki/Base64#URL_applications
2598
+ revLookup['-'.charCodeAt(0)] = 62
2599
+ revLookup['_'.charCodeAt(0)] = 63
2600
+
2601
+ function getLens (b64) {
2602
+ var len = b64.length
2603
+
2604
+ if (len % 4 > 0) {
2605
+ throw new Error('Invalid string. Length must be a multiple of 4')
2606
+ }
2607
+
2608
+ // Trim off extra bytes after placeholder bytes are found
2609
+ // See: https://github.com/beatgammit/base64-js/issues/42
2610
+ var validLen = b64.indexOf('=')
2611
+ if (validLen === -1) validLen = len
2612
+
2613
+ var placeHoldersLen = validLen === len
2614
+ ? 0
2615
+ : 4 - (validLen % 4)
2616
+
2617
+ return [validLen, placeHoldersLen]
2618
+ }
2619
+
2620
+ // base64 is 4/3 + up to two characters of the original data
2621
+ function byteLength (b64) {
2622
+ var lens = getLens(b64)
2623
+ var validLen = lens[0]
2624
+ var placeHoldersLen = lens[1]
2625
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
2626
+ }
2627
+
2628
+ function _byteLength (b64, validLen, placeHoldersLen) {
2629
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
2630
+ }
2631
+
2632
+ function toByteArray (b64) {
2633
+ var tmp
2634
+ var lens = getLens(b64)
2635
+ var validLen = lens[0]
2636
+ var placeHoldersLen = lens[1]
2637
+
2638
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
2639
+
2640
+ var curByte = 0
2641
+
2642
+ // if there are placeholders, only get up to the last complete 4 chars
2643
+ var len = placeHoldersLen > 0
2644
+ ? validLen - 4
2645
+ : validLen
2646
+
2647
+ var i
2648
+ for (i = 0; i < len; i += 4) {
2649
+ tmp =
2650
+ (revLookup[b64.charCodeAt(i)] << 18) |
2651
+ (revLookup[b64.charCodeAt(i + 1)] << 12) |
2652
+ (revLookup[b64.charCodeAt(i + 2)] << 6) |
2653
+ revLookup[b64.charCodeAt(i + 3)]
2654
+ arr[curByte++] = (tmp >> 16) & 0xFF
2655
+ arr[curByte++] = (tmp >> 8) & 0xFF
2656
+ arr[curByte++] = tmp & 0xFF
2657
+ }
2658
+
2659
+ if (placeHoldersLen === 2) {
2660
+ tmp =
2661
+ (revLookup[b64.charCodeAt(i)] << 2) |
2662
+ (revLookup[b64.charCodeAt(i + 1)] >> 4)
2663
+ arr[curByte++] = tmp & 0xFF
2664
+ }
2665
+
2666
+ if (placeHoldersLen === 1) {
2667
+ tmp =
2668
+ (revLookup[b64.charCodeAt(i)] << 10) |
2669
+ (revLookup[b64.charCodeAt(i + 1)] << 4) |
2670
+ (revLookup[b64.charCodeAt(i + 2)] >> 2)
2671
+ arr[curByte++] = (tmp >> 8) & 0xFF
2672
+ arr[curByte++] = tmp & 0xFF
2673
+ }
2674
+
2675
+ return arr
2676
+ }
2677
+
2678
+ function tripletToBase64 (num) {
2679
+ return lookup[num >> 18 & 0x3F] +
2680
+ lookup[num >> 12 & 0x3F] +
2681
+ lookup[num >> 6 & 0x3F] +
2682
+ lookup[num & 0x3F]
2683
+ }
2684
+
2685
+ function encodeChunk (uint8, start, end) {
2686
+ var tmp
2687
+ var output = []
2688
+ for (var i = start; i < end; i += 3) {
2689
+ tmp =
2690
+ ((uint8[i] << 16) & 0xFF0000) +
2691
+ ((uint8[i + 1] << 8) & 0xFF00) +
2692
+ (uint8[i + 2] & 0xFF)
2693
+ output.push(tripletToBase64(tmp))
2694
+ }
2695
+ return output.join('')
2696
+ }
2697
+
2698
+ function fromByteArray (uint8) {
2699
+ var tmp
2700
+ var len = uint8.length
2701
+ var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
2702
+ var parts = []
2703
+ var maxChunkLength = 16383 // must be multiple of 3
2704
+
2705
+ // go through the array every three bytes, we'll deal with trailing stuff later
2706
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
2707
+ parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
2708
+ }
2709
+
2710
+ // pad the end with zeros, but make sure to not forget the extra bytes
2711
+ if (extraBytes === 1) {
2712
+ tmp = uint8[len - 1]
2713
+ parts.push(
2714
+ lookup[tmp >> 2] +
2715
+ lookup[(tmp << 4) & 0x3F] +
2716
+ '=='
2717
+ )
2718
+ } else if (extraBytes === 2) {
2719
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1]
2720
+ parts.push(
2721
+ lookup[tmp >> 10] +
2722
+ lookup[(tmp >> 4) & 0x3F] +
2723
+ lookup[(tmp << 2) & 0x3F] +
2724
+ '='
2725
+ )
2726
+ }
2727
+
2728
+ return parts.join('')
2729
+ }
2730
+
2731
+
2732
+ /***/ }),
2733
+
2734
+ /***/ "./node_modules/ieee754/index.js":
2735
+ /*!***************************************!*\
2736
+ !*** ./node_modules/ieee754/index.js ***!
2737
+ \***************************************/
2738
+ /*! no static exports found */
2739
+ /***/ (function(module, exports) {
2740
+
2741
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
2742
+ exports.read = function (buffer, offset, isLE, mLen, nBytes) {
2743
+ var e, m
2744
+ var eLen = (nBytes * 8) - mLen - 1
2745
+ var eMax = (1 << eLen) - 1
2746
+ var eBias = eMax >> 1
2747
+ var nBits = -7
2748
+ var i = isLE ? (nBytes - 1) : 0
2749
+ var d = isLE ? -1 : 1
2750
+ var s = buffer[offset + i]
2751
+
2752
+ i += d
2753
+
2754
+ e = s & ((1 << (-nBits)) - 1)
2755
+ s >>= (-nBits)
2756
+ nBits += eLen
2757
+ for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
2758
+
2759
+ m = e & ((1 << (-nBits)) - 1)
2760
+ e >>= (-nBits)
2761
+ nBits += mLen
2762
+ for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
2763
+
2764
+ if (e === 0) {
2765
+ e = 1 - eBias
2766
+ } else if (e === eMax) {
2767
+ return m ? NaN : ((s ? -1 : 1) * Infinity)
2768
+ } else {
2769
+ m = m + Math.pow(2, mLen)
2770
+ e = e - eBias
2771
+ }
2772
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
2773
+ }
2774
+
2775
+ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
2776
+ var e, m, c
2777
+ var eLen = (nBytes * 8) - mLen - 1
2778
+ var eMax = (1 << eLen) - 1
2779
+ var eBias = eMax >> 1
2780
+ var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
2781
+ var i = isLE ? 0 : (nBytes - 1)
2782
+ var d = isLE ? 1 : -1
2783
+ var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
2784
+
2785
+ value = Math.abs(value)
2786
+
2787
+ if (isNaN(value) || value === Infinity) {
2788
+ m = isNaN(value) ? 1 : 0
2789
+ e = eMax
2790
+ } else {
2791
+ e = Math.floor(Math.log(value) / Math.LN2)
2792
+ if (value * (c = Math.pow(2, -e)) < 1) {
2793
+ e--
2794
+ c *= 2
2795
+ }
2796
+ if (e + eBias >= 1) {
2797
+ value += rt / c
2798
+ } else {
2799
+ value += rt * Math.pow(2, 1 - eBias)
2800
+ }
2801
+ if (value * c >= 2) {
2802
+ e++
2803
+ c /= 2
2804
+ }
2805
+
2806
+ if (e + eBias >= eMax) {
2807
+ m = 0
2808
+ e = eMax
2809
+ } else if (e + eBias >= 1) {
2810
+ m = ((value * c) - 1) * Math.pow(2, mLen)
2811
+ e = e + eBias
2812
+ } else {
2813
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
2814
+ e = 0
2815
+ }
2816
+ }
2817
+
2818
+ for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
2819
+
2820
+ e = (e << mLen) | m
2821
+ eLen += mLen
2822
+ for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
2823
+
2824
+ buffer[offset + i - d] |= s * 128
2825
+ }
2826
+
2827
+
2828
+ /***/ }),
2829
+
2830
+ /***/ "./node_modules/node-libs-browser/node_modules/buffer/index.js":
2831
+ /*!*********************************************************************!*\
2832
+ !*** ./node_modules/node-libs-browser/node_modules/buffer/index.js ***!
2833
+ \*********************************************************************/
2834
+ /*! no static exports found */
2835
+ /***/ (function(module, exports, __webpack_require__) {
2836
+
2837
+ "use strict";
2838
+ /* WEBPACK VAR INJECTION */(function(global) {/*!
2839
+ * The buffer module from node.js, for the browser.
2840
+ *
2841
+ * @author Feross Aboukhadijeh <http://feross.org>
2842
+ * @license MIT
2843
+ */
2844
+ /* eslint-disable no-proto */
2845
+
2846
+
2847
+
2848
+ var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
2849
+ var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
2850
+ var isArray = __webpack_require__(/*! isarray */ "./node_modules/node-libs-browser/node_modules/isarray/index.js")
2851
+
2852
+ exports.Buffer = Buffer
2853
+ exports.SlowBuffer = SlowBuffer
2854
+ exports.INSPECT_MAX_BYTES = 50
2855
+
2856
+ /**
2857
+ * If `Buffer.TYPED_ARRAY_SUPPORT`:
2858
+ * === true Use Uint8Array implementation (fastest)
2859
+ * === false Use Object implementation (most compatible, even IE6)
2860
+ *
2861
+ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
2862
+ * Opera 11.6+, iOS 4.2+.
2863
+ *
2864
+ * Due to various browser bugs, sometimes the Object implementation will be used even
2865
+ * when the browser supports typed arrays.
2866
+ *
2867
+ * Note:
2868
+ *
2869
+ * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
2870
+ * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
2871
+ *
2872
+ * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
2873
+ *
2874
+ * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
2875
+ * incorrect length in some situations.
2876
+
2877
+ * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
2878
+ * get the Object implementation, which is slower but behaves correctly.
2879
+ */
2880
+ Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
2881
+ ? global.TYPED_ARRAY_SUPPORT
2882
+ : typedArraySupport()
2883
+
2884
+ /*
2885
+ * Export kMaxLength after typed array support is determined.
2886
+ */
2887
+ exports.kMaxLength = kMaxLength()
2888
+
2889
+ function typedArraySupport () {
2890
+ try {
2891
+ var arr = new Uint8Array(1)
2892
+ arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
2893
+ return arr.foo() === 42 && // typed array instances can be augmented
2894
+ typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
2895
+ arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
2896
+ } catch (e) {
2897
+ return false
2898
+ }
2899
+ }
2900
+
2901
+ function kMaxLength () {
2902
+ return Buffer.TYPED_ARRAY_SUPPORT
2903
+ ? 0x7fffffff
2904
+ : 0x3fffffff
2905
+ }
2906
+
2907
+ function createBuffer (that, length) {
2908
+ if (kMaxLength() < length) {
2909
+ throw new RangeError('Invalid typed array length')
2910
+ }
2911
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
2912
+ // Return an augmented `Uint8Array` instance, for best performance
2913
+ that = new Uint8Array(length)
2914
+ that.__proto__ = Buffer.prototype
2915
+ } else {
2916
+ // Fallback: Return an object instance of the Buffer class
2917
+ if (that === null) {
2918
+ that = new Buffer(length)
2919
+ }
2920
+ that.length = length
2921
+ }
2922
+
2923
+ return that
2924
+ }
2925
+
2926
+ /**
2927
+ * The Buffer constructor returns instances of `Uint8Array` that have their
2928
+ * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
2929
+ * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
2930
+ * and the `Uint8Array` methods. Square bracket notation works as expected -- it
2931
+ * returns a single octet.
2932
+ *
2933
+ * The `Uint8Array` prototype remains unmodified.
2934
+ */
2935
+
2936
+ function Buffer (arg, encodingOrOffset, length) {
2937
+ if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
2938
+ return new Buffer(arg, encodingOrOffset, length)
2939
+ }
2940
+
2941
+ // Common case.
2942
+ if (typeof arg === 'number') {
2943
+ if (typeof encodingOrOffset === 'string') {
2944
+ throw new Error(
2945
+ 'If encoding is specified then the first argument must be a string'
2946
+ )
2947
+ }
2948
+ return allocUnsafe(this, arg)
2949
+ }
2950
+ return from(this, arg, encodingOrOffset, length)
2951
+ }
2952
+
2953
+ Buffer.poolSize = 8192 // not used by this implementation
2954
+
2955
+ // TODO: Legacy, not needed anymore. Remove in next major version.
2956
+ Buffer._augment = function (arr) {
2957
+ arr.__proto__ = Buffer.prototype
2958
+ return arr
2959
+ }
2960
+
2961
+ function from (that, value, encodingOrOffset, length) {
2962
+ if (typeof value === 'number') {
2963
+ throw new TypeError('"value" argument must not be a number')
2964
+ }
2965
+
2966
+ if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
2967
+ return fromArrayBuffer(that, value, encodingOrOffset, length)
2968
+ }
2969
+
2970
+ if (typeof value === 'string') {
2971
+ return fromString(that, value, encodingOrOffset)
2972
+ }
2973
+
2974
+ return fromObject(that, value)
2975
+ }
2976
+
2977
+ /**
2978
+ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
2979
+ * if value is a number.
2980
+ * Buffer.from(str[, encoding])
2981
+ * Buffer.from(array)
2982
+ * Buffer.from(buffer)
2983
+ * Buffer.from(arrayBuffer[, byteOffset[, length]])
2984
+ **/
2985
+ Buffer.from = function (value, encodingOrOffset, length) {
2986
+ return from(null, value, encodingOrOffset, length)
2987
+ }
2988
+
2989
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
2990
+ Buffer.prototype.__proto__ = Uint8Array.prototype
2991
+ Buffer.__proto__ = Uint8Array
2992
+ if (typeof Symbol !== 'undefined' && Symbol.species &&
2993
+ Buffer[Symbol.species] === Buffer) {
2994
+ // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
2995
+ Object.defineProperty(Buffer, Symbol.species, {
2996
+ value: null,
2997
+ configurable: true
2998
+ })
2999
+ }
3000
+ }
3001
+
3002
+ function assertSize (size) {
3003
+ if (typeof size !== 'number') {
3004
+ throw new TypeError('"size" argument must be a number')
3005
+ } else if (size < 0) {
3006
+ throw new RangeError('"size" argument must not be negative')
3007
+ }
3008
+ }
3009
+
3010
+ function alloc (that, size, fill, encoding) {
3011
+ assertSize(size)
3012
+ if (size <= 0) {
3013
+ return createBuffer(that, size)
3014
+ }
3015
+ if (fill !== undefined) {
3016
+ // Only pay attention to encoding if it's a string. This
3017
+ // prevents accidentally sending in a number that would
3018
+ // be interpretted as a start offset.
3019
+ return typeof encoding === 'string'
3020
+ ? createBuffer(that, size).fill(fill, encoding)
3021
+ : createBuffer(that, size).fill(fill)
3022
+ }
3023
+ return createBuffer(that, size)
3024
+ }
3025
+
3026
+ /**
3027
+ * Creates a new filled Buffer instance.
3028
+ * alloc(size[, fill[, encoding]])
3029
+ **/
3030
+ Buffer.alloc = function (size, fill, encoding) {
3031
+ return alloc(null, size, fill, encoding)
3032
+ }
3033
+
3034
+ function allocUnsafe (that, size) {
3035
+ assertSize(size)
3036
+ that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
3037
+ if (!Buffer.TYPED_ARRAY_SUPPORT) {
3038
+ for (var i = 0; i < size; ++i) {
3039
+ that[i] = 0
3040
+ }
3041
+ }
3042
+ return that
3043
+ }
3044
+
3045
+ /**
3046
+ * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
3047
+ * */
3048
+ Buffer.allocUnsafe = function (size) {
3049
+ return allocUnsafe(null, size)
3050
+ }
3051
+ /**
3052
+ * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
3053
+ */
3054
+ Buffer.allocUnsafeSlow = function (size) {
3055
+ return allocUnsafe(null, size)
3056
+ }
3057
+
3058
+ function fromString (that, string, encoding) {
3059
+ if (typeof encoding !== 'string' || encoding === '') {
3060
+ encoding = 'utf8'
3061
+ }
3062
+
3063
+ if (!Buffer.isEncoding(encoding)) {
3064
+ throw new TypeError('"encoding" must be a valid string encoding')
3065
+ }
3066
+
3067
+ var length = byteLength(string, encoding) | 0
3068
+ that = createBuffer(that, length)
3069
+
3070
+ var actual = that.write(string, encoding)
3071
+
3072
+ if (actual !== length) {
3073
+ // Writing a hex string, for example, that contains invalid characters will
3074
+ // cause everything after the first invalid character to be ignored. (e.g.
3075
+ // 'abxxcd' will be treated as 'ab')
3076
+ that = that.slice(0, actual)
3077
+ }
3078
+
3079
+ return that
3080
+ }
3081
+
3082
+ function fromArrayLike (that, array) {
3083
+ var length = array.length < 0 ? 0 : checked(array.length) | 0
3084
+ that = createBuffer(that, length)
3085
+ for (var i = 0; i < length; i += 1) {
3086
+ that[i] = array[i] & 255
3087
+ }
3088
+ return that
3089
+ }
3090
+
3091
+ function fromArrayBuffer (that, array, byteOffset, length) {
3092
+ array.byteLength // this throws if `array` is not a valid ArrayBuffer
3093
+
3094
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
3095
+ throw new RangeError('\'offset\' is out of bounds')
3096
+ }
3097
+
3098
+ if (array.byteLength < byteOffset + (length || 0)) {
3099
+ throw new RangeError('\'length\' is out of bounds')
3100
+ }
3101
+
3102
+ if (byteOffset === undefined && length === undefined) {
3103
+ array = new Uint8Array(array)
3104
+ } else if (length === undefined) {
3105
+ array = new Uint8Array(array, byteOffset)
3106
+ } else {
3107
+ array = new Uint8Array(array, byteOffset, length)
3108
+ }
3109
+
3110
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
3111
+ // Return an augmented `Uint8Array` instance, for best performance
3112
+ that = array
3113
+ that.__proto__ = Buffer.prototype
3114
+ } else {
3115
+ // Fallback: Return an object instance of the Buffer class
3116
+ that = fromArrayLike(that, array)
3117
+ }
3118
+ return that
3119
+ }
3120
+
3121
+ function fromObject (that, obj) {
3122
+ if (Buffer.isBuffer(obj)) {
3123
+ var len = checked(obj.length) | 0
3124
+ that = createBuffer(that, len)
3125
+
3126
+ if (that.length === 0) {
3127
+ return that
3128
+ }
3129
+
3130
+ obj.copy(that, 0, 0, len)
3131
+ return that
3132
+ }
3133
+
3134
+ if (obj) {
3135
+ if ((typeof ArrayBuffer !== 'undefined' &&
3136
+ obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
3137
+ if (typeof obj.length !== 'number' || isnan(obj.length)) {
3138
+ return createBuffer(that, 0)
3139
+ }
3140
+ return fromArrayLike(that, obj)
3141
+ }
3142
+
3143
+ if (obj.type === 'Buffer' && isArray(obj.data)) {
3144
+ return fromArrayLike(that, obj.data)
3145
+ }
3146
+ }
3147
+
3148
+ throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
3149
+ }
3150
+
3151
+ function checked (length) {
3152
+ // Note: cannot use `length < kMaxLength()` here because that fails when
3153
+ // length is NaN (which is otherwise coerced to zero.)
3154
+ if (length >= kMaxLength()) {
3155
+ throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
3156
+ 'size: 0x' + kMaxLength().toString(16) + ' bytes')
3157
+ }
3158
+ return length | 0
3159
+ }
3160
+
3161
+ function SlowBuffer (length) {
3162
+ if (+length != length) { // eslint-disable-line eqeqeq
3163
+ length = 0
3164
+ }
3165
+ return Buffer.alloc(+length)
3166
+ }
3167
+
3168
+ Buffer.isBuffer = function isBuffer (b) {
3169
+ return !!(b != null && b._isBuffer)
3170
+ }
3171
+
3172
+ Buffer.compare = function compare (a, b) {
3173
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
3174
+ throw new TypeError('Arguments must be Buffers')
3175
+ }
3176
+
3177
+ if (a === b) return 0
3178
+
3179
+ var x = a.length
3180
+ var y = b.length
3181
+
3182
+ for (var i = 0, len = Math.min(x, y); i < len; ++i) {
3183
+ if (a[i] !== b[i]) {
3184
+ x = a[i]
3185
+ y = b[i]
3186
+ break
3187
+ }
3188
+ }
3189
+
3190
+ if (x < y) return -1
3191
+ if (y < x) return 1
3192
+ return 0
3193
+ }
3194
+
3195
+ Buffer.isEncoding = function isEncoding (encoding) {
3196
+ switch (String(encoding).toLowerCase()) {
3197
+ case 'hex':
3198
+ case 'utf8':
3199
+ case 'utf-8':
3200
+ case 'ascii':
3201
+ case 'latin1':
3202
+ case 'binary':
3203
+ case 'base64':
3204
+ case 'ucs2':
3205
+ case 'ucs-2':
3206
+ case 'utf16le':
3207
+ case 'utf-16le':
3208
+ return true
3209
+ default:
3210
+ return false
3211
+ }
3212
+ }
3213
+
3214
+ Buffer.concat = function concat (list, length) {
3215
+ if (!isArray(list)) {
3216
+ throw new TypeError('"list" argument must be an Array of Buffers')
3217
+ }
3218
+
3219
+ if (list.length === 0) {
3220
+ return Buffer.alloc(0)
3221
+ }
3222
+
3223
+ var i
3224
+ if (length === undefined) {
3225
+ length = 0
3226
+ for (i = 0; i < list.length; ++i) {
3227
+ length += list[i].length
3228
+ }
3229
+ }
3230
+
3231
+ var buffer = Buffer.allocUnsafe(length)
3232
+ var pos = 0
3233
+ for (i = 0; i < list.length; ++i) {
3234
+ var buf = list[i]
3235
+ if (!Buffer.isBuffer(buf)) {
3236
+ throw new TypeError('"list" argument must be an Array of Buffers')
3237
+ }
3238
+ buf.copy(buffer, pos)
3239
+ pos += buf.length
3240
+ }
3241
+ return buffer
3242
+ }
3243
+
3244
+ function byteLength (string, encoding) {
3245
+ if (Buffer.isBuffer(string)) {
3246
+ return string.length
3247
+ }
3248
+ if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
3249
+ (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
3250
+ return string.byteLength
3251
+ }
3252
+ if (typeof string !== 'string') {
3253
+ string = '' + string
3254
+ }
3255
+
3256
+ var len = string.length
3257
+ if (len === 0) return 0
3258
+
3259
+ // Use a for loop to avoid recursion
3260
+ var loweredCase = false
3261
+ for (;;) {
3262
+ switch (encoding) {
3263
+ case 'ascii':
3264
+ case 'latin1':
3265
+ case 'binary':
3266
+ return len
3267
+ case 'utf8':
3268
+ case 'utf-8':
3269
+ case undefined:
3270
+ return utf8ToBytes(string).length
3271
+ case 'ucs2':
3272
+ case 'ucs-2':
3273
+ case 'utf16le':
3274
+ case 'utf-16le':
3275
+ return len * 2
3276
+ case 'hex':
3277
+ return len >>> 1
3278
+ case 'base64':
3279
+ return base64ToBytes(string).length
3280
+ default:
3281
+ if (loweredCase) return utf8ToBytes(string).length // assume utf8
3282
+ encoding = ('' + encoding).toLowerCase()
3283
+ loweredCase = true
3284
+ }
3285
+ }
3286
+ }
3287
+ Buffer.byteLength = byteLength
3288
+
3289
+ function slowToString (encoding, start, end) {
3290
+ var loweredCase = false
3291
+
3292
+ // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
3293
+ // property of a typed array.
3294
+
3295
+ // This behaves neither like String nor Uint8Array in that we set start/end
3296
+ // to their upper/lower bounds if the value passed is out of range.
3297
+ // undefined is handled specially as per ECMA-262 6th Edition,
3298
+ // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
3299
+ if (start === undefined || start < 0) {
3300
+ start = 0
3301
+ }
3302
+ // Return early if start > this.length. Done here to prevent potential uint32
3303
+ // coercion fail below.
3304
+ if (start > this.length) {
3305
+ return ''
3306
+ }
3307
+
3308
+ if (end === undefined || end > this.length) {
3309
+ end = this.length
3310
+ }
3311
+
3312
+ if (end <= 0) {
3313
+ return ''
3314
+ }
3315
+
3316
+ // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
3317
+ end >>>= 0
3318
+ start >>>= 0
3319
+
3320
+ if (end <= start) {
3321
+ return ''
3322
+ }
3323
+
3324
+ if (!encoding) encoding = 'utf8'
3325
+
3326
+ while (true) {
3327
+ switch (encoding) {
3328
+ case 'hex':
3329
+ return hexSlice(this, start, end)
3330
+
3331
+ case 'utf8':
3332
+ case 'utf-8':
3333
+ return utf8Slice(this, start, end)
3334
+
3335
+ case 'ascii':
3336
+ return asciiSlice(this, start, end)
3337
+
3338
+ case 'latin1':
3339
+ case 'binary':
3340
+ return latin1Slice(this, start, end)
3341
+
3342
+ case 'base64':
3343
+ return base64Slice(this, start, end)
3344
+
3345
+ case 'ucs2':
3346
+ case 'ucs-2':
3347
+ case 'utf16le':
3348
+ case 'utf-16le':
3349
+ return utf16leSlice(this, start, end)
3350
+
3351
+ default:
3352
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
3353
+ encoding = (encoding + '').toLowerCase()
3354
+ loweredCase = true
3355
+ }
3356
+ }
3357
+ }
3358
+
3359
+ // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
3360
+ // Buffer instances.
3361
+ Buffer.prototype._isBuffer = true
3362
+
3363
+ function swap (b, n, m) {
3364
+ var i = b[n]
3365
+ b[n] = b[m]
3366
+ b[m] = i
3367
+ }
3368
+
3369
+ Buffer.prototype.swap16 = function swap16 () {
3370
+ var len = this.length
3371
+ if (len % 2 !== 0) {
3372
+ throw new RangeError('Buffer size must be a multiple of 16-bits')
3373
+ }
3374
+ for (var i = 0; i < len; i += 2) {
3375
+ swap(this, i, i + 1)
3376
+ }
3377
+ return this
3378
+ }
3379
+
3380
+ Buffer.prototype.swap32 = function swap32 () {
3381
+ var len = this.length
3382
+ if (len % 4 !== 0) {
3383
+ throw new RangeError('Buffer size must be a multiple of 32-bits')
3384
+ }
3385
+ for (var i = 0; i < len; i += 4) {
3386
+ swap(this, i, i + 3)
3387
+ swap(this, i + 1, i + 2)
3388
+ }
3389
+ return this
3390
+ }
3391
+
3392
+ Buffer.prototype.swap64 = function swap64 () {
3393
+ var len = this.length
3394
+ if (len % 8 !== 0) {
3395
+ throw new RangeError('Buffer size must be a multiple of 64-bits')
3396
+ }
3397
+ for (var i = 0; i < len; i += 8) {
3398
+ swap(this, i, i + 7)
3399
+ swap(this, i + 1, i + 6)
3400
+ swap(this, i + 2, i + 5)
3401
+ swap(this, i + 3, i + 4)
3402
+ }
3403
+ return this
3404
+ }
3405
+
3406
+ Buffer.prototype.toString = function toString () {
3407
+ var length = this.length | 0
3408
+ if (length === 0) return ''
3409
+ if (arguments.length === 0) return utf8Slice(this, 0, length)
3410
+ return slowToString.apply(this, arguments)
3411
+ }
3412
+
3413
+ Buffer.prototype.equals = function equals (b) {
3414
+ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
3415
+ if (this === b) return true
3416
+ return Buffer.compare(this, b) === 0
3417
+ }
3418
+
3419
+ Buffer.prototype.inspect = function inspect () {
3420
+ var str = ''
3421
+ var max = exports.INSPECT_MAX_BYTES
3422
+ if (this.length > 0) {
3423
+ str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
3424
+ if (this.length > max) str += ' ... '
3425
+ }
3426
+ return '<Buffer ' + str + '>'
3427
+ }
3428
+
3429
+ Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
3430
+ if (!Buffer.isBuffer(target)) {
3431
+ throw new TypeError('Argument must be a Buffer')
3432
+ }
3433
+
3434
+ if (start === undefined) {
3435
+ start = 0
3436
+ }
3437
+ if (end === undefined) {
3438
+ end = target ? target.length : 0
3439
+ }
3440
+ if (thisStart === undefined) {
3441
+ thisStart = 0
3442
+ }
3443
+ if (thisEnd === undefined) {
3444
+ thisEnd = this.length
3445
+ }
3446
+
3447
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
3448
+ throw new RangeError('out of range index')
3449
+ }
3450
+
3451
+ if (thisStart >= thisEnd && start >= end) {
3452
+ return 0
3453
+ }
3454
+ if (thisStart >= thisEnd) {
3455
+ return -1
3456
+ }
3457
+ if (start >= end) {
3458
+ return 1
3459
+ }
3460
+
3461
+ start >>>= 0
3462
+ end >>>= 0
3463
+ thisStart >>>= 0
3464
+ thisEnd >>>= 0
3465
+
3466
+ if (this === target) return 0
3467
+
3468
+ var x = thisEnd - thisStart
3469
+ var y = end - start
3470
+ var len = Math.min(x, y)
3471
+
3472
+ var thisCopy = this.slice(thisStart, thisEnd)
3473
+ var targetCopy = target.slice(start, end)
3474
+
3475
+ for (var i = 0; i < len; ++i) {
3476
+ if (thisCopy[i] !== targetCopy[i]) {
3477
+ x = thisCopy[i]
3478
+ y = targetCopy[i]
3479
+ break
3480
+ }
3481
+ }
3482
+
3483
+ if (x < y) return -1
3484
+ if (y < x) return 1
3485
+ return 0
3486
+ }
3487
+
3488
+ // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
3489
+ // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
3490
+ //
3491
+ // Arguments:
3492
+ // - buffer - a Buffer to search
3493
+ // - val - a string, Buffer, or number
3494
+ // - byteOffset - an index into `buffer`; will be clamped to an int32
3495
+ // - encoding - an optional encoding, relevant is val is a string
3496
+ // - dir - true for indexOf, false for lastIndexOf
3497
+ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
3498
+ // Empty buffer means no match
3499
+ if (buffer.length === 0) return -1
3500
+
3501
+ // Normalize byteOffset
3502
+ if (typeof byteOffset === 'string') {
3503
+ encoding = byteOffset
3504
+ byteOffset = 0
3505
+ } else if (byteOffset > 0x7fffffff) {
3506
+ byteOffset = 0x7fffffff
3507
+ } else if (byteOffset < -0x80000000) {
3508
+ byteOffset = -0x80000000
3509
+ }
3510
+ byteOffset = +byteOffset // Coerce to Number.
3511
+ if (isNaN(byteOffset)) {
3512
+ // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
3513
+ byteOffset = dir ? 0 : (buffer.length - 1)
3514
+ }
3515
+
3516
+ // Normalize byteOffset: negative offsets start from the end of the buffer
3517
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset
3518
+ if (byteOffset >= buffer.length) {
3519
+ if (dir) return -1
3520
+ else byteOffset = buffer.length - 1
3521
+ } else if (byteOffset < 0) {
3522
+ if (dir) byteOffset = 0
3523
+ else return -1
3524
+ }
3525
+
3526
+ // Normalize val
3527
+ if (typeof val === 'string') {
3528
+ val = Buffer.from(val, encoding)
3529
+ }
3530
+
3531
+ // Finally, search either indexOf (if dir is true) or lastIndexOf
3532
+ if (Buffer.isBuffer(val)) {
3533
+ // Special case: looking for empty string/buffer always fails
3534
+ if (val.length === 0) {
3535
+ return -1
3536
+ }
3537
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
3538
+ } else if (typeof val === 'number') {
3539
+ val = val & 0xFF // Search for a byte value [0-255]
3540
+ if (Buffer.TYPED_ARRAY_SUPPORT &&
3541
+ typeof Uint8Array.prototype.indexOf === 'function') {
3542
+ if (dir) {
3543
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
3544
+ } else {
3545
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
3546
+ }
3547
+ }
3548
+ return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
3549
+ }
3550
+
3551
+ throw new TypeError('val must be string, number or Buffer')
3552
+ }
3553
+
3554
+ function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
3555
+ var indexSize = 1
3556
+ var arrLength = arr.length
3557
+ var valLength = val.length
3558
+
3559
+ if (encoding !== undefined) {
3560
+ encoding = String(encoding).toLowerCase()
3561
+ if (encoding === 'ucs2' || encoding === 'ucs-2' ||
3562
+ encoding === 'utf16le' || encoding === 'utf-16le') {
3563
+ if (arr.length < 2 || val.length < 2) {
3564
+ return -1
3565
+ }
3566
+ indexSize = 2
3567
+ arrLength /= 2
3568
+ valLength /= 2
3569
+ byteOffset /= 2
3570
+ }
3571
+ }
3572
+
3573
+ function read (buf, i) {
3574
+ if (indexSize === 1) {
3575
+ return buf[i]
3576
+ } else {
3577
+ return buf.readUInt16BE(i * indexSize)
3578
+ }
3579
+ }
3580
+
3581
+ var i
3582
+ if (dir) {
3583
+ var foundIndex = -1
3584
+ for (i = byteOffset; i < arrLength; i++) {
3585
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
3586
+ if (foundIndex === -1) foundIndex = i
3587
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
3588
+ } else {
3589
+ if (foundIndex !== -1) i -= i - foundIndex
3590
+ foundIndex = -1
3591
+ }
3592
+ }
3593
+ } else {
3594
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
3595
+ for (i = byteOffset; i >= 0; i--) {
3596
+ var found = true
3597
+ for (var j = 0; j < valLength; j++) {
3598
+ if (read(arr, i + j) !== read(val, j)) {
3599
+ found = false
3600
+ break
3601
+ }
3602
+ }
3603
+ if (found) return i
3604
+ }
3605
+ }
3606
+
3607
+ return -1
3608
+ }
3609
+
3610
+ Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
3611
+ return this.indexOf(val, byteOffset, encoding) !== -1
3612
+ }
3613
+
3614
+ Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
3615
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
3616
+ }
3617
+
3618
+ Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
3619
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
3620
+ }
3621
+
3622
+ function hexWrite (buf, string, offset, length) {
3623
+ offset = Number(offset) || 0
3624
+ var remaining = buf.length - offset
3625
+ if (!length) {
3626
+ length = remaining
3627
+ } else {
3628
+ length = Number(length)
3629
+ if (length > remaining) {
3630
+ length = remaining
3631
+ }
3632
+ }
3633
+
3634
+ // must be an even number of digits
3635
+ var strLen = string.length
3636
+ if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
3637
+
3638
+ if (length > strLen / 2) {
3639
+ length = strLen / 2
3640
+ }
3641
+ for (var i = 0; i < length; ++i) {
3642
+ var parsed = parseInt(string.substr(i * 2, 2), 16)
3643
+ if (isNaN(parsed)) return i
3644
+ buf[offset + i] = parsed
3645
+ }
3646
+ return i
3647
+ }
3648
+
3649
+ function utf8Write (buf, string, offset, length) {
3650
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
3651
+ }
3652
+
3653
+ function asciiWrite (buf, string, offset, length) {
3654
+ return blitBuffer(asciiToBytes(string), buf, offset, length)
3655
+ }
3656
+
3657
+ function latin1Write (buf, string, offset, length) {
3658
+ return asciiWrite(buf, string, offset, length)
3659
+ }
3660
+
3661
+ function base64Write (buf, string, offset, length) {
3662
+ return blitBuffer(base64ToBytes(string), buf, offset, length)
3663
+ }
3664
+
3665
+ function ucs2Write (buf, string, offset, length) {
3666
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
3667
+ }
3668
+
3669
+ Buffer.prototype.write = function write (string, offset, length, encoding) {
3670
+ // Buffer#write(string)
3671
+ if (offset === undefined) {
3672
+ encoding = 'utf8'
3673
+ length = this.length
3674
+ offset = 0
3675
+ // Buffer#write(string, encoding)
3676
+ } else if (length === undefined && typeof offset === 'string') {
3677
+ encoding = offset
3678
+ length = this.length
3679
+ offset = 0
3680
+ // Buffer#write(string, offset[, length][, encoding])
3681
+ } else if (isFinite(offset)) {
3682
+ offset = offset | 0
3683
+ if (isFinite(length)) {
3684
+ length = length | 0
3685
+ if (encoding === undefined) encoding = 'utf8'
3686
+ } else {
3687
+ encoding = length
3688
+ length = undefined
3689
+ }
3690
+ // legacy write(string, encoding, offset, length) - remove in v0.13
3691
+ } else {
3692
+ throw new Error(
3693
+ 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
3694
+ )
3695
+ }
3696
+
3697
+ var remaining = this.length - offset
3698
+ if (length === undefined || length > remaining) length = remaining
3699
+
3700
+ if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
3701
+ throw new RangeError('Attempt to write outside buffer bounds')
3702
+ }
3703
+
3704
+ if (!encoding) encoding = 'utf8'
3705
+
3706
+ var loweredCase = false
3707
+ for (;;) {
3708
+ switch (encoding) {
3709
+ case 'hex':
3710
+ return hexWrite(this, string, offset, length)
3711
+
3712
+ case 'utf8':
3713
+ case 'utf-8':
3714
+ return utf8Write(this, string, offset, length)
3715
+
3716
+ case 'ascii':
3717
+ return asciiWrite(this, string, offset, length)
3718
+
3719
+ case 'latin1':
3720
+ case 'binary':
3721
+ return latin1Write(this, string, offset, length)
3722
+
3723
+ case 'base64':
3724
+ // Warning: maxLength not taken into account in base64Write
3725
+ return base64Write(this, string, offset, length)
3726
+
3727
+ case 'ucs2':
3728
+ case 'ucs-2':
3729
+ case 'utf16le':
3730
+ case 'utf-16le':
3731
+ return ucs2Write(this, string, offset, length)
3732
+
3733
+ default:
3734
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
3735
+ encoding = ('' + encoding).toLowerCase()
3736
+ loweredCase = true
3737
+ }
3738
+ }
3739
+ }
3740
+
3741
+ Buffer.prototype.toJSON = function toJSON () {
3742
+ return {
3743
+ type: 'Buffer',
3744
+ data: Array.prototype.slice.call(this._arr || this, 0)
3745
+ }
3746
+ }
3747
+
3748
+ function base64Slice (buf, start, end) {
3749
+ if (start === 0 && end === buf.length) {
3750
+ return base64.fromByteArray(buf)
3751
+ } else {
3752
+ return base64.fromByteArray(buf.slice(start, end))
3753
+ }
3754
+ }
3755
+
3756
+ function utf8Slice (buf, start, end) {
3757
+ end = Math.min(buf.length, end)
3758
+ var res = []
3759
+
3760
+ var i = start
3761
+ while (i < end) {
3762
+ var firstByte = buf[i]
3763
+ var codePoint = null
3764
+ var bytesPerSequence = (firstByte > 0xEF) ? 4
3765
+ : (firstByte > 0xDF) ? 3
3766
+ : (firstByte > 0xBF) ? 2
3767
+ : 1
3768
+
3769
+ if (i + bytesPerSequence <= end) {
3770
+ var secondByte, thirdByte, fourthByte, tempCodePoint
3771
+
3772
+ switch (bytesPerSequence) {
3773
+ case 1:
3774
+ if (firstByte < 0x80) {
3775
+ codePoint = firstByte
3776
+ }
3777
+ break
3778
+ case 2:
3779
+ secondByte = buf[i + 1]
3780
+ if ((secondByte & 0xC0) === 0x80) {
3781
+ tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
3782
+ if (tempCodePoint > 0x7F) {
3783
+ codePoint = tempCodePoint
3784
+ }
3785
+ }
3786
+ break
3787
+ case 3:
3788
+ secondByte = buf[i + 1]
3789
+ thirdByte = buf[i + 2]
3790
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
3791
+ tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
3792
+ if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
3793
+ codePoint = tempCodePoint
3794
+ }
3795
+ }
3796
+ break
3797
+ case 4:
3798
+ secondByte = buf[i + 1]
3799
+ thirdByte = buf[i + 2]
3800
+ fourthByte = buf[i + 3]
3801
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
3802
+ tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
3803
+ if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
3804
+ codePoint = tempCodePoint
3805
+ }
3806
+ }
3807
+ }
3808
+ }
3809
+
3810
+ if (codePoint === null) {
3811
+ // we did not generate a valid codePoint so insert a
3812
+ // replacement char (U+FFFD) and advance only 1 byte
3813
+ codePoint = 0xFFFD
3814
+ bytesPerSequence = 1
3815
+ } else if (codePoint > 0xFFFF) {
3816
+ // encode to utf16 (surrogate pair dance)
3817
+ codePoint -= 0x10000
3818
+ res.push(codePoint >>> 10 & 0x3FF | 0xD800)
3819
+ codePoint = 0xDC00 | codePoint & 0x3FF
3820
+ }
3821
+
3822
+ res.push(codePoint)
3823
+ i += bytesPerSequence
3824
+ }
3825
+
3826
+ return decodeCodePointsArray(res)
3827
+ }
3828
+
3829
+ // Based on http://stackoverflow.com/a/22747272/680742, the browser with
3830
+ // the lowest limit is Chrome, with 0x10000 args.
3831
+ // We go 1 magnitude less, for safety
3832
+ var MAX_ARGUMENTS_LENGTH = 0x1000
3833
+
3834
+ function decodeCodePointsArray (codePoints) {
3835
+ var len = codePoints.length
3836
+ if (len <= MAX_ARGUMENTS_LENGTH) {
3837
+ return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
3838
+ }
3839
+
3840
+ // Decode in chunks to avoid "call stack size exceeded".
3841
+ var res = ''
3842
+ var i = 0
3843
+ while (i < len) {
3844
+ res += String.fromCharCode.apply(
3845
+ String,
3846
+ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
3847
+ )
3848
+ }
3849
+ return res
3850
+ }
3851
+
3852
+ function asciiSlice (buf, start, end) {
3853
+ var ret = ''
3854
+ end = Math.min(buf.length, end)
3855
+
3856
+ for (var i = start; i < end; ++i) {
3857
+ ret += String.fromCharCode(buf[i] & 0x7F)
3858
+ }
3859
+ return ret
3860
+ }
3861
+
3862
+ function latin1Slice (buf, start, end) {
3863
+ var ret = ''
3864
+ end = Math.min(buf.length, end)
3865
+
3866
+ for (var i = start; i < end; ++i) {
3867
+ ret += String.fromCharCode(buf[i])
3868
+ }
3869
+ return ret
3870
+ }
3871
+
3872
+ function hexSlice (buf, start, end) {
3873
+ var len = buf.length
3874
+
3875
+ if (!start || start < 0) start = 0
3876
+ if (!end || end < 0 || end > len) end = len
3877
+
3878
+ var out = ''
3879
+ for (var i = start; i < end; ++i) {
3880
+ out += toHex(buf[i])
3881
+ }
3882
+ return out
3883
+ }
3884
+
3885
+ function utf16leSlice (buf, start, end) {
3886
+ var bytes = buf.slice(start, end)
3887
+ var res = ''
3888
+ for (var i = 0; i < bytes.length; i += 2) {
3889
+ res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
3890
+ }
3891
+ return res
3892
+ }
3893
+
3894
+ Buffer.prototype.slice = function slice (start, end) {
3895
+ var len = this.length
3896
+ start = ~~start
3897
+ end = end === undefined ? len : ~~end
3898
+
3899
+ if (start < 0) {
3900
+ start += len
3901
+ if (start < 0) start = 0
3902
+ } else if (start > len) {
3903
+ start = len
3904
+ }
3905
+
3906
+ if (end < 0) {
3907
+ end += len
3908
+ if (end < 0) end = 0
3909
+ } else if (end > len) {
3910
+ end = len
3911
+ }
3912
+
3913
+ if (end < start) end = start
3914
+
3915
+ var newBuf
3916
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
3917
+ newBuf = this.subarray(start, end)
3918
+ newBuf.__proto__ = Buffer.prototype
3919
+ } else {
3920
+ var sliceLen = end - start
3921
+ newBuf = new Buffer(sliceLen, undefined)
3922
+ for (var i = 0; i < sliceLen; ++i) {
3923
+ newBuf[i] = this[i + start]
3924
+ }
3925
+ }
3926
+
3927
+ return newBuf
3928
+ }
3929
+
3930
+ /*
3931
+ * Need to make sure that buffer isn't trying to write out of bounds.
3932
+ */
3933
+ function checkOffset (offset, ext, length) {
3934
+ if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
3935
+ if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
3936
+ }
3937
+
3938
+ Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
3939
+ offset = offset | 0
3940
+ byteLength = byteLength | 0
3941
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
3942
+
3943
+ var val = this[offset]
3944
+ var mul = 1
3945
+ var i = 0
3946
+ while (++i < byteLength && (mul *= 0x100)) {
3947
+ val += this[offset + i] * mul
3948
+ }
3949
+
3950
+ return val
3951
+ }
3952
+
3953
+ Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
3954
+ offset = offset | 0
3955
+ byteLength = byteLength | 0
3956
+ if (!noAssert) {
3957
+ checkOffset(offset, byteLength, this.length)
3958
+ }
3959
+
3960
+ var val = this[offset + --byteLength]
3961
+ var mul = 1
3962
+ while (byteLength > 0 && (mul *= 0x100)) {
3963
+ val += this[offset + --byteLength] * mul
3964
+ }
3965
+
3966
+ return val
3967
+ }
3968
+
3969
+ Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
3970
+ if (!noAssert) checkOffset(offset, 1, this.length)
3971
+ return this[offset]
3972
+ }
3973
+
3974
+ Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
3975
+ if (!noAssert) checkOffset(offset, 2, this.length)
3976
+ return this[offset] | (this[offset + 1] << 8)
3977
+ }
3978
+
3979
+ Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
3980
+ if (!noAssert) checkOffset(offset, 2, this.length)
3981
+ return (this[offset] << 8) | this[offset + 1]
3982
+ }
3983
+
3984
+ Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
3985
+ if (!noAssert) checkOffset(offset, 4, this.length)
3986
+
3987
+ return ((this[offset]) |
3988
+ (this[offset + 1] << 8) |
3989
+ (this[offset + 2] << 16)) +
3990
+ (this[offset + 3] * 0x1000000)
3991
+ }
3992
+
3993
+ Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
3994
+ if (!noAssert) checkOffset(offset, 4, this.length)
3995
+
3996
+ return (this[offset] * 0x1000000) +
3997
+ ((this[offset + 1] << 16) |
3998
+ (this[offset + 2] << 8) |
3999
+ this[offset + 3])
4000
+ }
4001
+
4002
+ Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
4003
+ offset = offset | 0
4004
+ byteLength = byteLength | 0
4005
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
4006
+
4007
+ var val = this[offset]
4008
+ var mul = 1
4009
+ var i = 0
4010
+ while (++i < byteLength && (mul *= 0x100)) {
4011
+ val += this[offset + i] * mul
4012
+ }
4013
+ mul *= 0x80
4014
+
4015
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength)
4016
+
4017
+ return val
4018
+ }
4019
+
4020
+ Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
4021
+ offset = offset | 0
4022
+ byteLength = byteLength | 0
4023
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
4024
+
4025
+ var i = byteLength
4026
+ var mul = 1
4027
+ var val = this[offset + --i]
4028
+ while (i > 0 && (mul *= 0x100)) {
4029
+ val += this[offset + --i] * mul
4030
+ }
4031
+ mul *= 0x80
4032
+
4033
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength)
4034
+
4035
+ return val
4036
+ }
4037
+
4038
+ Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
4039
+ if (!noAssert) checkOffset(offset, 1, this.length)
4040
+ if (!(this[offset] & 0x80)) return (this[offset])
4041
+ return ((0xff - this[offset] + 1) * -1)
4042
+ }
4043
+
4044
+ Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
4045
+ if (!noAssert) checkOffset(offset, 2, this.length)
4046
+ var val = this[offset] | (this[offset + 1] << 8)
4047
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
4048
+ }
4049
+
4050
+ Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
4051
+ if (!noAssert) checkOffset(offset, 2, this.length)
4052
+ var val = this[offset + 1] | (this[offset] << 8)
4053
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
4054
+ }
4055
+
4056
+ Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
4057
+ if (!noAssert) checkOffset(offset, 4, this.length)
4058
+
4059
+ return (this[offset]) |
4060
+ (this[offset + 1] << 8) |
4061
+ (this[offset + 2] << 16) |
4062
+ (this[offset + 3] << 24)
4063
+ }
4064
+
4065
+ Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
4066
+ if (!noAssert) checkOffset(offset, 4, this.length)
4067
+
4068
+ return (this[offset] << 24) |
4069
+ (this[offset + 1] << 16) |
4070
+ (this[offset + 2] << 8) |
4071
+ (this[offset + 3])
4072
+ }
4073
+
4074
+ Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
4075
+ if (!noAssert) checkOffset(offset, 4, this.length)
4076
+ return ieee754.read(this, offset, true, 23, 4)
4077
+ }
4078
+
4079
+ Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
4080
+ if (!noAssert) checkOffset(offset, 4, this.length)
4081
+ return ieee754.read(this, offset, false, 23, 4)
4082
+ }
4083
+
4084
+ Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
4085
+ if (!noAssert) checkOffset(offset, 8, this.length)
4086
+ return ieee754.read(this, offset, true, 52, 8)
4087
+ }
4088
+
4089
+ Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
4090
+ if (!noAssert) checkOffset(offset, 8, this.length)
4091
+ return ieee754.read(this, offset, false, 52, 8)
4092
+ }
4093
+
4094
+ function checkInt (buf, value, offset, ext, max, min) {
4095
+ if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
4096
+ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
4097
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
4098
+ }
4099
+
4100
+ Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
4101
+ value = +value
4102
+ offset = offset | 0
4103
+ byteLength = byteLength | 0
4104
+ if (!noAssert) {
4105
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1
4106
+ checkInt(this, value, offset, byteLength, maxBytes, 0)
4107
+ }
4108
+
4109
+ var mul = 1
4110
+ var i = 0
4111
+ this[offset] = value & 0xFF
4112
+ while (++i < byteLength && (mul *= 0x100)) {
4113
+ this[offset + i] = (value / mul) & 0xFF
4114
+ }
4115
+
4116
+ return offset + byteLength
4117
+ }
4118
+
4119
+ Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
4120
+ value = +value
4121
+ offset = offset | 0
4122
+ byteLength = byteLength | 0
4123
+ if (!noAssert) {
4124
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1
4125
+ checkInt(this, value, offset, byteLength, maxBytes, 0)
4126
+ }
4127
+
4128
+ var i = byteLength - 1
4129
+ var mul = 1
4130
+ this[offset + i] = value & 0xFF
4131
+ while (--i >= 0 && (mul *= 0x100)) {
4132
+ this[offset + i] = (value / mul) & 0xFF
4133
+ }
4134
+
4135
+ return offset + byteLength
4136
+ }
4137
+
4138
+ Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
4139
+ value = +value
4140
+ offset = offset | 0
4141
+ if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
4142
+ if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
4143
+ this[offset] = (value & 0xff)
4144
+ return offset + 1
4145
+ }
4146
+
4147
+ function objectWriteUInt16 (buf, value, offset, littleEndian) {
4148
+ if (value < 0) value = 0xffff + value + 1
4149
+ for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
4150
+ buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
4151
+ (littleEndian ? i : 1 - i) * 8
4152
+ }
4153
+ }
4154
+
4155
+ Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
4156
+ value = +value
4157
+ offset = offset | 0
4158
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
4159
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
4160
+ this[offset] = (value & 0xff)
4161
+ this[offset + 1] = (value >>> 8)
4162
+ } else {
4163
+ objectWriteUInt16(this, value, offset, true)
4164
+ }
4165
+ return offset + 2
4166
+ }
4167
+
4168
+ Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
4169
+ value = +value
4170
+ offset = offset | 0
4171
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
4172
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
4173
+ this[offset] = (value >>> 8)
4174
+ this[offset + 1] = (value & 0xff)
4175
+ } else {
4176
+ objectWriteUInt16(this, value, offset, false)
4177
+ }
4178
+ return offset + 2
4179
+ }
4180
+
4181
+ function objectWriteUInt32 (buf, value, offset, littleEndian) {
4182
+ if (value < 0) value = 0xffffffff + value + 1
4183
+ for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
4184
+ buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
4185
+ }
4186
+ }
4187
+
4188
+ Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
4189
+ value = +value
4190
+ offset = offset | 0
4191
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
4192
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
4193
+ this[offset + 3] = (value >>> 24)
4194
+ this[offset + 2] = (value >>> 16)
4195
+ this[offset + 1] = (value >>> 8)
4196
+ this[offset] = (value & 0xff)
4197
+ } else {
4198
+ objectWriteUInt32(this, value, offset, true)
4199
+ }
4200
+ return offset + 4
4201
+ }
4202
+
4203
+ Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
4204
+ value = +value
4205
+ offset = offset | 0
4206
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
4207
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
4208
+ this[offset] = (value >>> 24)
4209
+ this[offset + 1] = (value >>> 16)
4210
+ this[offset + 2] = (value >>> 8)
4211
+ this[offset + 3] = (value & 0xff)
4212
+ } else {
4213
+ objectWriteUInt32(this, value, offset, false)
4214
+ }
4215
+ return offset + 4
4216
+ }
4217
+
4218
+ Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
4219
+ value = +value
4220
+ offset = offset | 0
4221
+ if (!noAssert) {
4222
+ var limit = Math.pow(2, 8 * byteLength - 1)
4223
+
4224
+ checkInt(this, value, offset, byteLength, limit - 1, -limit)
4225
+ }
4226
+
4227
+ var i = 0
4228
+ var mul = 1
4229
+ var sub = 0
4230
+ this[offset] = value & 0xFF
4231
+ while (++i < byteLength && (mul *= 0x100)) {
4232
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
4233
+ sub = 1
4234
+ }
4235
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
4236
+ }
4237
+
4238
+ return offset + byteLength
4239
+ }
4240
+
4241
+ Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
4242
+ value = +value
4243
+ offset = offset | 0
4244
+ if (!noAssert) {
4245
+ var limit = Math.pow(2, 8 * byteLength - 1)
4246
+
4247
+ checkInt(this, value, offset, byteLength, limit - 1, -limit)
4248
+ }
4249
+
4250
+ var i = byteLength - 1
4251
+ var mul = 1
4252
+ var sub = 0
4253
+ this[offset + i] = value & 0xFF
4254
+ while (--i >= 0 && (mul *= 0x100)) {
4255
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
4256
+ sub = 1
4257
+ }
4258
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
4259
+ }
4260
+
4261
+ return offset + byteLength
4262
+ }
4263
+
4264
+ Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
4265
+ value = +value
4266
+ offset = offset | 0
4267
+ if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
4268
+ if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
4269
+ if (value < 0) value = 0xff + value + 1
4270
+ this[offset] = (value & 0xff)
4271
+ return offset + 1
4272
+ }
4273
+
4274
+ Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
4275
+ value = +value
4276
+ offset = offset | 0
4277
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
4278
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
4279
+ this[offset] = (value & 0xff)
4280
+ this[offset + 1] = (value >>> 8)
4281
+ } else {
4282
+ objectWriteUInt16(this, value, offset, true)
4283
+ }
4284
+ return offset + 2
4285
+ }
4286
+
4287
+ Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
4288
+ value = +value
4289
+ offset = offset | 0
4290
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
4291
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
4292
+ this[offset] = (value >>> 8)
4293
+ this[offset + 1] = (value & 0xff)
4294
+ } else {
4295
+ objectWriteUInt16(this, value, offset, false)
4296
+ }
4297
+ return offset + 2
4298
+ }
4299
+
4300
+ Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
4301
+ value = +value
4302
+ offset = offset | 0
4303
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
4304
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
4305
+ this[offset] = (value & 0xff)
4306
+ this[offset + 1] = (value >>> 8)
4307
+ this[offset + 2] = (value >>> 16)
4308
+ this[offset + 3] = (value >>> 24)
4309
+ } else {
4310
+ objectWriteUInt32(this, value, offset, true)
4311
+ }
4312
+ return offset + 4
4313
+ }
4314
+
4315
+ Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
4316
+ value = +value
4317
+ offset = offset | 0
4318
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
4319
+ if (value < 0) value = 0xffffffff + value + 1
4320
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
4321
+ this[offset] = (value >>> 24)
4322
+ this[offset + 1] = (value >>> 16)
4323
+ this[offset + 2] = (value >>> 8)
4324
+ this[offset + 3] = (value & 0xff)
4325
+ } else {
4326
+ objectWriteUInt32(this, value, offset, false)
4327
+ }
4328
+ return offset + 4
4329
+ }
4330
+
4331
+ function checkIEEE754 (buf, value, offset, ext, max, min) {
4332
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
4333
+ if (offset < 0) throw new RangeError('Index out of range')
4334
+ }
4335
+
4336
+ function writeFloat (buf, value, offset, littleEndian, noAssert) {
4337
+ if (!noAssert) {
4338
+ checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
4339
+ }
4340
+ ieee754.write(buf, value, offset, littleEndian, 23, 4)
4341
+ return offset + 4
4342
+ }
4343
+
4344
+ Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
4345
+ return writeFloat(this, value, offset, true, noAssert)
4346
+ }
4347
+
4348
+ Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
4349
+ return writeFloat(this, value, offset, false, noAssert)
4350
+ }
4351
+
4352
+ function writeDouble (buf, value, offset, littleEndian, noAssert) {
4353
+ if (!noAssert) {
4354
+ checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
4355
+ }
4356
+ ieee754.write(buf, value, offset, littleEndian, 52, 8)
4357
+ return offset + 8
4358
+ }
4359
+
4360
+ Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
4361
+ return writeDouble(this, value, offset, true, noAssert)
4362
+ }
4363
+
4364
+ Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
4365
+ return writeDouble(this, value, offset, false, noAssert)
4366
+ }
4367
+
4368
+ // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
4369
+ Buffer.prototype.copy = function copy (target, targetStart, start, end) {
4370
+ if (!start) start = 0
4371
+ if (!end && end !== 0) end = this.length
4372
+ if (targetStart >= target.length) targetStart = target.length
4373
+ if (!targetStart) targetStart = 0
4374
+ if (end > 0 && end < start) end = start
4375
+
4376
+ // Copy 0 bytes; we're done
4377
+ if (end === start) return 0
4378
+ if (target.length === 0 || this.length === 0) return 0
4379
+
4380
+ // Fatal error conditions
4381
+ if (targetStart < 0) {
4382
+ throw new RangeError('targetStart out of bounds')
4383
+ }
4384
+ if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
4385
+ if (end < 0) throw new RangeError('sourceEnd out of bounds')
4386
+
4387
+ // Are we oob?
4388
+ if (end > this.length) end = this.length
4389
+ if (target.length - targetStart < end - start) {
4390
+ end = target.length - targetStart + start
4391
+ }
4392
+
4393
+ var len = end - start
4394
+ var i
4395
+
4396
+ if (this === target && start < targetStart && targetStart < end) {
4397
+ // descending copy from end
4398
+ for (i = len - 1; i >= 0; --i) {
4399
+ target[i + targetStart] = this[i + start]
4400
+ }
4401
+ } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
4402
+ // ascending copy from start
4403
+ for (i = 0; i < len; ++i) {
4404
+ target[i + targetStart] = this[i + start]
4405
+ }
4406
+ } else {
4407
+ Uint8Array.prototype.set.call(
4408
+ target,
4409
+ this.subarray(start, start + len),
4410
+ targetStart
4411
+ )
4412
+ }
4413
+
4414
+ return len
4415
+ }
4416
+
4417
+ // Usage:
4418
+ // buffer.fill(number[, offset[, end]])
4419
+ // buffer.fill(buffer[, offset[, end]])
4420
+ // buffer.fill(string[, offset[, end]][, encoding])
4421
+ Buffer.prototype.fill = function fill (val, start, end, encoding) {
4422
+ // Handle string cases:
4423
+ if (typeof val === 'string') {
4424
+ if (typeof start === 'string') {
4425
+ encoding = start
4426
+ start = 0
4427
+ end = this.length
4428
+ } else if (typeof end === 'string') {
4429
+ encoding = end
4430
+ end = this.length
4431
+ }
4432
+ if (val.length === 1) {
4433
+ var code = val.charCodeAt(0)
4434
+ if (code < 256) {
4435
+ val = code
4436
+ }
4437
+ }
4438
+ if (encoding !== undefined && typeof encoding !== 'string') {
4439
+ throw new TypeError('encoding must be a string')
4440
+ }
4441
+ if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
4442
+ throw new TypeError('Unknown encoding: ' + encoding)
4443
+ }
4444
+ } else if (typeof val === 'number') {
4445
+ val = val & 255
4446
+ }
4447
+
4448
+ // Invalid ranges are not set to a default, so can range check early.
4449
+ if (start < 0 || this.length < start || this.length < end) {
4450
+ throw new RangeError('Out of range index')
4451
+ }
4452
+
4453
+ if (end <= start) {
4454
+ return this
4455
+ }
4456
+
4457
+ start = start >>> 0
4458
+ end = end === undefined ? this.length : end >>> 0
4459
+
4460
+ if (!val) val = 0
4461
+
4462
+ var i
4463
+ if (typeof val === 'number') {
4464
+ for (i = start; i < end; ++i) {
4465
+ this[i] = val
4466
+ }
4467
+ } else {
4468
+ var bytes = Buffer.isBuffer(val)
4469
+ ? val
4470
+ : utf8ToBytes(new Buffer(val, encoding).toString())
4471
+ var len = bytes.length
4472
+ for (i = 0; i < end - start; ++i) {
4473
+ this[i + start] = bytes[i % len]
4474
+ }
4475
+ }
4476
+
4477
+ return this
4478
+ }
4479
+
4480
+ // HELPER FUNCTIONS
4481
+ // ================
4482
+
4483
+ var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
4484
+
4485
+ function base64clean (str) {
4486
+ // Node strips out invalid characters like \n and \t from the string, base64-js does not
4487
+ str = stringtrim(str).replace(INVALID_BASE64_RE, '')
4488
+ // Node converts strings with length < 2 to ''
4489
+ if (str.length < 2) return ''
4490
+ // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
4491
+ while (str.length % 4 !== 0) {
4492
+ str = str + '='
4493
+ }
4494
+ return str
4495
+ }
4496
+
4497
+ function stringtrim (str) {
4498
+ if (str.trim) return str.trim()
4499
+ return str.replace(/^\s+|\s+$/g, '')
4500
+ }
4501
+
4502
+ function toHex (n) {
4503
+ if (n < 16) return '0' + n.toString(16)
4504
+ return n.toString(16)
4505
+ }
4506
+
4507
+ function utf8ToBytes (string, units) {
4508
+ units = units || Infinity
4509
+ var codePoint
4510
+ var length = string.length
4511
+ var leadSurrogate = null
4512
+ var bytes = []
4513
+
4514
+ for (var i = 0; i < length; ++i) {
4515
+ codePoint = string.charCodeAt(i)
4516
+
4517
+ // is surrogate component
4518
+ if (codePoint > 0xD7FF && codePoint < 0xE000) {
4519
+ // last char was a lead
4520
+ if (!leadSurrogate) {
4521
+ // no lead yet
4522
+ if (codePoint > 0xDBFF) {
4523
+ // unexpected trail
4524
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
4525
+ continue
4526
+ } else if (i + 1 === length) {
4527
+ // unpaired lead
4528
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
4529
+ continue
4530
+ }
4531
+
4532
+ // valid lead
4533
+ leadSurrogate = codePoint
4534
+
4535
+ continue
4536
+ }
4537
+
4538
+ // 2 leads in a row
4539
+ if (codePoint < 0xDC00) {
4540
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
4541
+ leadSurrogate = codePoint
4542
+ continue
4543
+ }
4544
+
4545
+ // valid surrogate pair
4546
+ codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
4547
+ } else if (leadSurrogate) {
4548
+ // valid bmp char, but last char was a lead
4549
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
4550
+ }
4551
+
4552
+ leadSurrogate = null
4553
+
4554
+ // encode utf8
4555
+ if (codePoint < 0x80) {
4556
+ if ((units -= 1) < 0) break
4557
+ bytes.push(codePoint)
4558
+ } else if (codePoint < 0x800) {
4559
+ if ((units -= 2) < 0) break
4560
+ bytes.push(
4561
+ codePoint >> 0x6 | 0xC0,
4562
+ codePoint & 0x3F | 0x80
4563
+ )
4564
+ } else if (codePoint < 0x10000) {
4565
+ if ((units -= 3) < 0) break
4566
+ bytes.push(
4567
+ codePoint >> 0xC | 0xE0,
4568
+ codePoint >> 0x6 & 0x3F | 0x80,
4569
+ codePoint & 0x3F | 0x80
4570
+ )
4571
+ } else if (codePoint < 0x110000) {
4572
+ if ((units -= 4) < 0) break
4573
+ bytes.push(
4574
+ codePoint >> 0x12 | 0xF0,
4575
+ codePoint >> 0xC & 0x3F | 0x80,
4576
+ codePoint >> 0x6 & 0x3F | 0x80,
4577
+ codePoint & 0x3F | 0x80
4578
+ )
4579
+ } else {
4580
+ throw new Error('Invalid code point')
4581
+ }
4582
+ }
4583
+
4584
+ return bytes
4585
+ }
4586
+
4587
+ function asciiToBytes (str) {
4588
+ var byteArray = []
4589
+ for (var i = 0; i < str.length; ++i) {
4590
+ // Node's code seems to be doing this and not & 0x7F..
4591
+ byteArray.push(str.charCodeAt(i) & 0xFF)
4592
+ }
4593
+ return byteArray
4594
+ }
4595
+
4596
+ function utf16leToBytes (str, units) {
4597
+ var c, hi, lo
4598
+ var byteArray = []
4599
+ for (var i = 0; i < str.length; ++i) {
4600
+ if ((units -= 2) < 0) break
4601
+
4602
+ c = str.charCodeAt(i)
4603
+ hi = c >> 8
4604
+ lo = c % 256
4605
+ byteArray.push(lo)
4606
+ byteArray.push(hi)
4607
+ }
4608
+
4609
+ return byteArray
4610
+ }
4611
+
4612
+ function base64ToBytes (str) {
4613
+ return base64.toByteArray(base64clean(str))
4614
+ }
4615
+
4616
+ function blitBuffer (src, dst, offset, length) {
4617
+ for (var i = 0; i < length; ++i) {
4618
+ if ((i + offset >= dst.length) || (i >= src.length)) break
4619
+ dst[i + offset] = src[i]
4620
+ }
4621
+ return i
4622
+ }
4623
+
4624
+ function isnan (val) {
4625
+ return val !== val // eslint-disable-line no-self-compare
4626
+ }
4627
+
4628
+ /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
4629
+
4630
+ /***/ }),
4631
+
4632
+ /***/ "./node_modules/node-libs-browser/node_modules/isarray/index.js":
4633
+ /*!**********************************************************************!*\
4634
+ !*** ./node_modules/node-libs-browser/node_modules/isarray/index.js ***!
4635
+ \**********************************************************************/
4636
+ /*! no static exports found */
4637
+ /***/ (function(module, exports) {
4638
+
4639
+ var toString = {}.toString;
4640
+
4641
+ module.exports = Array.isArray || function (arr) {
4642
+ return toString.call(arr) == '[object Array]';
4643
+ };
4644
+
4645
+
4646
+ /***/ }),
4647
+
4648
+ /***/ "./node_modules/webpack/buildin/global.js":
4649
+ /*!***********************************!*\
4650
+ !*** (webpack)/buildin/global.js ***!
4651
+ \***********************************/
4652
+ /*! no static exports found */
4653
+ /***/ (function(module, exports) {
4654
+
4655
+ var g;
4656
+
4657
+ // This works in non-strict mode
4658
+ g = (function() {
4659
+ return this;
4660
+ })();
4661
+
4662
+ try {
4663
+ // This works if eval is allowed (see CSP)
4664
+ g = g || new Function("return this")();
4665
+ } catch (e) {
4666
+ // This works if the window reference is available
4667
+ if (typeof window === "object") g = window;
4668
+ }
4669
+
4670
+ // g can still be undefined, but nothing to do about it...
4671
+ // We return undefined, instead of nothing here, so it's
4672
+ // easier to handle this case. if(!global) { ...}
4673
+
4674
+ module.exports = g;
4675
+
4676
+
2273
4677
  /***/ })
2274
4678
 
2275
4679
  /******/ });