extra-request 3.0.0 → 4.0.0

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.
Files changed (42) hide show
  1. package/LICENSE +1 -1
  2. package/dist/es2015/index.min.mjs +2 -2
  3. package/dist/es2015/index.min.mjs.map +1 -1
  4. package/dist/es2015/index.mjs +201 -68
  5. package/dist/es2015/index.mjs.map +1 -1
  6. package/dist/es2015/index.umd.js +203 -70
  7. package/dist/es2015/index.umd.js.map +1 -1
  8. package/dist/es2015/index.umd.min.js +2 -2
  9. package/dist/es2015/index.umd.min.js.map +1 -1
  10. package/dist/es2018/index.min.mjs +2 -2
  11. package/dist/es2018/index.min.mjs.map +1 -1
  12. package/dist/es2018/index.mjs +201 -68
  13. package/dist/es2018/index.mjs.map +1 -1
  14. package/dist/es2018/index.umd.js +203 -70
  15. package/dist/es2018/index.umd.js.map +1 -1
  16. package/dist/es2018/index.umd.min.js +2 -2
  17. package/dist/es2018/index.umd.min.js.map +1 -1
  18. package/lib/es2015/request.js +1 -1
  19. package/lib/es2015/request.js.map +1 -1
  20. package/lib/es2015/transformers/accept.js +1 -1
  21. package/lib/es2015/transformers/accept.js.map +1 -1
  22. package/lib/es2015/transformers/basic-auth.js +1 -1
  23. package/lib/es2015/transformers/basic-auth.js.map +1 -1
  24. package/lib/es2015/transformers/bearer-auth.js +1 -1
  25. package/lib/es2015/transformers/bearer-auth.js.map +1 -1
  26. package/lib/es2015/transformers/csv.js +2 -2
  27. package/lib/es2015/transformers/csv.js.map +1 -1
  28. package/lib/es2015/transformers/form-data-field.js +2 -1
  29. package/lib/es2015/transformers/form-data-field.js.map +1 -1
  30. package/lib/es2018/request.js +1 -1
  31. package/lib/es2018/request.js.map +1 -1
  32. package/lib/es2018/transformers/accept.js +1 -1
  33. package/lib/es2018/transformers/accept.js.map +1 -1
  34. package/lib/es2018/transformers/basic-auth.js +1 -1
  35. package/lib/es2018/transformers/basic-auth.js.map +1 -1
  36. package/lib/es2018/transformers/bearer-auth.js +1 -1
  37. package/lib/es2018/transformers/bearer-auth.js.map +1 -1
  38. package/lib/es2018/transformers/csv.js +2 -2
  39. package/lib/es2018/transformers/csv.js.map +1 -1
  40. package/lib/es2018/transformers/form-data-field.js +2 -1
  41. package/lib/es2018/transformers/form-data-field.js.map +1 -1
  42. package/package.json +27 -25
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
3
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ExtraRequest = {}));
5
- }(this, (function (exports) { 'use strict';
5
+ })(this, (function (exports) { 'use strict';
6
6
 
7
7
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
8
8
 
@@ -38,6 +38,11 @@
38
38
  abortController_browser.AbortController = void 0;
39
39
  abortController_browser.AbortController = globalThis.AbortController;
40
40
 
41
+ var abortError_browser = {};
42
+
43
+ abortError_browser.AbortError = void 0;
44
+ abortError_browser.AbortError = globalThis.DOMException;
45
+
41
46
  var blob_browser = {};
42
47
 
43
48
  blob_browser.Blob = void 0;
@@ -64,6 +69,7 @@
64
69
  __exportStar(response_browser, exports);
65
70
  __exportStar(formData_browser, exports);
66
71
  __exportStar(abortController_browser, exports);
72
+ __exportStar(abortError_browser, exports);
67
73
  __exportStar(blob_browser, exports);
68
74
  __exportStar(eventSource_browser, exports);
69
75
 
@@ -121,8 +127,8 @@
121
127
  const null_1$1 = _null;
122
128
  const undefined_1$2 = _undefined;
123
129
  function isAsyncIterable(val) {
124
- return null_1$1.isntNull(val)
125
- && undefined_1$2.isntUndefined(val)
130
+ return (0, null_1$1.isntNull)(val)
131
+ && (0, undefined_1$2.isntUndefined)(val)
126
132
  && typeof val[Symbol.asyncIterator] === 'function';
127
133
  }
128
134
  asyncIterable.isAsyncIterable = isAsyncIterable;
@@ -159,36 +165,20 @@
159
165
 
160
166
  var string = {};
161
167
 
162
- string.isntStringObject = string.isStringObject = string.isntStringPrimitive = string.isStringPrimitive = string.isntString = string.isString = void 0;
168
+ string.isntString = string.isString = void 0;
163
169
  function isString(val) {
164
- return isStringPrimitive(val) || isStringObject(val);
170
+ return typeof val === 'string';
165
171
  }
166
172
  string.isString = isString;
167
173
  function isntString(val) {
168
174
  return !isString(val);
169
175
  }
170
176
  string.isntString = isntString;
171
- function isStringPrimitive(val) {
172
- return typeof val === 'string';
173
- }
174
- string.isStringPrimitive = isStringPrimitive;
175
- function isntStringPrimitive(val) {
176
- return !isStringPrimitive(val);
177
- }
178
- string.isntStringPrimitive = isntStringPrimitive;
179
- function isStringObject(val) {
180
- return typeof val === 'object' && val instanceof String;
181
- }
182
- string.isStringObject = isStringObject;
183
- function isntStringObject(val) {
184
- return !isStringObject(val);
185
- }
186
- string.isntStringObject = isntStringObject;
187
177
 
188
- char.isntCharObject = char.isCharObject = char.isntCharPrimitive = char.isCharPrimitive = char.isntChar = char.isChar = void 0;
178
+ char.isntChar = char.isChar = void 0;
189
179
  const string_1$1 = string;
190
180
  function isChar(val) {
191
- return (string_1$1.isString(val) || string_1$1.isStringObject(val))
181
+ return (0, string_1$1.isString)(val)
192
182
  && val.length === 1;
193
183
  }
194
184
  char.isChar = isChar;
@@ -196,24 +186,6 @@
196
186
  return !isChar(val);
197
187
  }
198
188
  char.isntChar = isntChar;
199
- function isCharPrimitive(val) {
200
- return string_1$1.isString(val)
201
- && val.length === 1;
202
- }
203
- char.isCharPrimitive = isCharPrimitive;
204
- function isntCharPrimitive(val) {
205
- return !isCharPrimitive(val);
206
- }
207
- char.isntCharPrimitive = isntCharPrimitive;
208
- function isCharObject(val) {
209
- return string_1$1.isStringObject(val)
210
- && val.length === 1;
211
- }
212
- char.isCharObject = isCharObject;
213
- function isntCharObject(val) {
214
- return !isCharObject(val);
215
- }
216
- char.isntCharObject = isntCharObject;
217
189
 
218
190
  var date = {};
219
191
 
@@ -235,6 +207,18 @@
235
207
  }
236
208
  _enum.inEnum = inEnum;
237
209
 
210
+ var error = {};
211
+
212
+ error.isntError = error.isError = void 0;
213
+ function isError(val) {
214
+ return val instanceof Error;
215
+ }
216
+ error.isError = isError;
217
+ function isntError(val) {
218
+ return !isError(val);
219
+ }
220
+ error.isntError = isntError;
221
+
238
222
  var falsy = {};
239
223
 
240
224
  falsy.isntFalsy = falsy.isFalsy = void 0;
@@ -265,8 +249,8 @@
265
249
  const null_1 = _null;
266
250
  const undefined_1$1 = _undefined;
267
251
  function isIterable(val) {
268
- return null_1.isntNull(val)
269
- && undefined_1$1.isntUndefined(val)
252
+ return (0, null_1.isntNull)(val)
253
+ && (0, undefined_1$1.isntUndefined)(val)
270
254
  && typeof val[Symbol.iterator] === 'function';
271
255
  }
272
256
  iterable.isIterable = isIterable;
@@ -279,19 +263,167 @@
279
263
 
280
264
  var object = {};
281
265
 
282
- object.isntEmptyObject = object.isEmptyObject = object.isRecord = object.isntObject = object.isObject = void 0;
266
+ /**
267
+ * lodash (Custom Build) <https://lodash.com/>
268
+ * Build: `lodash modularize exports="npm" -o ./`
269
+ * Copyright jQuery Foundation and other contributors <https://jquery.org/>
270
+ * Released under MIT license <https://lodash.com/license>
271
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
272
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
273
+ */
274
+
275
+ /** `Object#toString` result references. */
276
+ var objectTag = '[object Object]';
277
+
278
+ /**
279
+ * Checks if `value` is a host object in IE < 9.
280
+ *
281
+ * @private
282
+ * @param {*} value The value to check.
283
+ * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
284
+ */
285
+ function isHostObject(value) {
286
+ // Many host objects are `Object` objects that can coerce to strings
287
+ // despite having improperly defined `toString` methods.
288
+ var result = false;
289
+ if (value != null && typeof value.toString != 'function') {
290
+ try {
291
+ result = !!(value + '');
292
+ } catch (e) {}
293
+ }
294
+ return result;
295
+ }
296
+
297
+ /**
298
+ * Creates a unary function that invokes `func` with its argument transformed.
299
+ *
300
+ * @private
301
+ * @param {Function} func The function to wrap.
302
+ * @param {Function} transform The argument transform.
303
+ * @returns {Function} Returns the new function.
304
+ */
305
+ function overArg(func, transform) {
306
+ return function(arg) {
307
+ return func(transform(arg));
308
+ };
309
+ }
310
+
311
+ /** Used for built-in method references. */
312
+ var funcProto = Function.prototype,
313
+ objectProto = Object.prototype;
314
+
315
+ /** Used to resolve the decompiled source of functions. */
316
+ var funcToString = funcProto.toString;
317
+
318
+ /** Used to check objects for own properties. */
319
+ var hasOwnProperty = objectProto.hasOwnProperty;
320
+
321
+ /** Used to infer the `Object` constructor. */
322
+ var objectCtorString = funcToString.call(Object);
323
+
324
+ /**
325
+ * Used to resolve the
326
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
327
+ * of values.
328
+ */
329
+ var objectToString = objectProto.toString;
330
+
331
+ /** Built-in value references. */
332
+ var getPrototype = overArg(Object.getPrototypeOf, Object);
333
+
334
+ /**
335
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
336
+ * and has a `typeof` result of "object".
337
+ *
338
+ * @static
339
+ * @memberOf _
340
+ * @since 4.0.0
341
+ * @category Lang
342
+ * @param {*} value The value to check.
343
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
344
+ * @example
345
+ *
346
+ * _.isObjectLike({});
347
+ * // => true
348
+ *
349
+ * _.isObjectLike([1, 2, 3]);
350
+ * // => true
351
+ *
352
+ * _.isObjectLike(_.noop);
353
+ * // => false
354
+ *
355
+ * _.isObjectLike(null);
356
+ * // => false
357
+ */
358
+ function isObjectLike(value) {
359
+ return !!value && typeof value == 'object';
360
+ }
361
+
362
+ /**
363
+ * Checks if `value` is a plain object, that is, an object created by the
364
+ * `Object` constructor or one with a `[[Prototype]]` of `null`.
365
+ *
366
+ * @static
367
+ * @memberOf _
368
+ * @since 0.8.0
369
+ * @category Lang
370
+ * @param {*} value The value to check.
371
+ * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
372
+ * @example
373
+ *
374
+ * function Foo() {
375
+ * this.a = 1;
376
+ * }
377
+ *
378
+ * _.isPlainObject(new Foo);
379
+ * // => false
380
+ *
381
+ * _.isPlainObject([1, 2, 3]);
382
+ * // => false
383
+ *
384
+ * _.isPlainObject({ 'x': 0, 'y': 0 });
385
+ * // => true
386
+ *
387
+ * _.isPlainObject(Object.create(null));
388
+ * // => true
389
+ */
390
+ function isPlainObject$1(value) {
391
+ if (!isObjectLike(value) ||
392
+ objectToString.call(value) != objectTag || isHostObject(value)) {
393
+ return false;
394
+ }
395
+ var proto = getPrototype(value);
396
+ if (proto === null) {
397
+ return true;
398
+ }
399
+ var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
400
+ return (typeof Ctor == 'function' &&
401
+ Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString);
402
+ }
403
+
404
+ var lodash_isplainobject = isPlainObject$1;
405
+
406
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
407
+ return (mod && mod.__esModule) ? mod : { "default": mod };
408
+ };object.isntEmptyObject = object.isEmptyObject = object.isntPlainObject = object.isPlainObject = object.isntObject = object.isObject = void 0;
409
+ const lodash_isplainobject_1 = __importDefault(lodash_isplainobject);
283
410
  function isObject(val) {
284
- return val !== null && typeof val === 'object';
411
+ return val !== null
412
+ && typeof val === 'object';
285
413
  }
286
414
  object.isObject = isObject;
287
415
  function isntObject(val) {
288
416
  return !isObject(val);
289
417
  }
290
418
  object.isntObject = isntObject;
291
- function isRecord(val) {
292
- return isObject(val);
419
+ function isPlainObject(val) {
420
+ return (0, lodash_isplainobject_1.default)(val);
421
+ }
422
+ object.isPlainObject = isPlainObject;
423
+ function isntPlainObject(val) {
424
+ return !isPlainObject(val);
293
425
  }
294
- object.isRecord = isRecord;
426
+ object.isntPlainObject = isntPlainObject;
295
427
  function isEmptyObject(val) {
296
428
  return Object.keys(val).length === 0;
297
429
  }
@@ -320,16 +452,16 @@
320
452
  const number_1 = number;
321
453
  const undefined_1 = _undefined;
322
454
  function isJsonRpcId(val) {
323
- return string_1.isString(val) || number_1.isNumber(val);
455
+ return (0, string_1.isString)(val) || (0, number_1.isNumber)(val);
324
456
  }
325
457
  function isJsonRpcParams(val) {
326
- return array_1.isArray(val) || object_1.isObject(val);
458
+ return (0, array_1.isArray)(val) || (0, object_1.isObject)(val);
327
459
  }
328
460
  function isJsonRpcNotification(val) {
329
- return object_1.isRecord(val)
330
- && string_1.isString(val.jsonrpc)
331
- && string_1.isString(val.method)
332
- && undefined_1.isUndefined(val.id)
461
+ return (0, object_1.isPlainObject)(val)
462
+ && (0, string_1.isString)(val.jsonrpc)
463
+ && (0, string_1.isString)(val.method)
464
+ && (0, undefined_1.isUndefined)(val.id)
333
465
  && isJsonRpcParams(val.params);
334
466
  }
335
467
  jsonRpc.isJsonRpcNotification = isJsonRpcNotification;
@@ -338,9 +470,9 @@
338
470
  }
339
471
  jsonRpc.isntJsonRpcNotification = isntJsonRpcNotification;
340
472
  function isJsonRpcRequest(val) {
341
- return object_1.isRecord(val)
342
- && string_1.isString(val.jsonrpc)
343
- && string_1.isString(val.method)
473
+ return (0, object_1.isPlainObject)(val)
474
+ && (0, string_1.isString)(val.jsonrpc)
475
+ && (0, string_1.isString)(val.method)
344
476
  && isJsonRpcId(val.id)
345
477
  && isJsonRpcParams(val.params);
346
478
  }
@@ -350,10 +482,10 @@
350
482
  }
351
483
  jsonRpc.isntJsonRpcRequest = isntJsonRpcRequest;
352
484
  function isJsonRpcSuccess(val) {
353
- return object_1.isRecord(val)
354
- && string_1.isString(val.jsonrpc)
355
- && string_1.isString(val.id)
356
- && undefined_1.isntUndefined(val.result);
485
+ return (0, object_1.isPlainObject)(val)
486
+ && (0, string_1.isString)(val.jsonrpc)
487
+ && (0, string_1.isString)(val.id)
488
+ && 'result' in val;
357
489
  }
358
490
  jsonRpc.isJsonRpcSuccess = isJsonRpcSuccess;
359
491
  function isntJsonRpcSuccess(val) {
@@ -361,8 +493,8 @@
361
493
  }
362
494
  jsonRpc.isntJsonRpcSuccess = isntJsonRpcSuccess;
363
495
  function isJsonRpcError(val) {
364
- return object_1.isRecord(val)
365
- && string_1.isString(val.jsonrpc)
496
+ return (0, object_1.isPlainObject)(val)
497
+ && (0, string_1.isString)(val.jsonrpc)
366
498
  && isJsonRpcId(val.id)
367
499
  && isJsonRpcErrorObject(val.error);
368
500
  }
@@ -372,10 +504,10 @@
372
504
  }
373
505
  jsonRpc.isntJsonRpcError = isntJsonRpcError;
374
506
  function isJsonRpcErrorObject(val) {
375
- return object_1.isRecord(val)
376
- && number_1.isNumber(val.code)
377
- && string_1.isString(val.message)
378
- && (undefined_1.isUndefined(val.data) || object_1.isObject(val.data));
507
+ return (0, object_1.isPlainObject)(val)
508
+ && (0, number_1.isNumber)(val.code)
509
+ && (0, string_1.isString)(val.message)
510
+ && ((0, undefined_1.isUndefined)(val.data) || (0, object_1.isObject)(val.data));
379
511
  }
380
512
 
381
513
  var json$1 = {};
@@ -427,6 +559,7 @@
427
559
  __exportStar(char, exports);
428
560
  __exportStar(date, exports);
429
561
  __exportStar(_enum, exports);
562
+ __exportStar(error, exports);
430
563
  __exportStar(falsy, exports);
431
564
  __exportStar(_function, exports);
432
565
  __exportStar(iterable, exports);
@@ -709,7 +842,7 @@
709
842
  const formData = options.payload instanceof es2018$2.FormData
710
843
  ? cloneFormData(options.payload)
711
844
  : new es2018$2.FormData();
712
- if (Array.isArray(value)) {
845
+ if (es2018$1.isArray(value)) {
713
846
  value.forEach(x => formData.append(name, x));
714
847
  }
715
848
  else {
@@ -742,7 +875,7 @@
742
875
  typeof TextDecoder === 'function' ? new TextDecoder() : undefined;
743
876
  typeof TextEncoder === 'function' ? new TextEncoder() : undefined;
744
877
  const b64ch = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
745
- const b64chs = [...b64ch];
878
+ const b64chs = Array.prototype.slice.call(b64ch);
746
879
  ((a) => {
747
880
  let tab = {};
748
881
  a.forEach((c, i) => tab[c] = i);
@@ -824,5 +957,5 @@
824
957
 
825
958
  Object.defineProperty(exports, '__esModule', { value: true });
826
959
 
827
- })));
960
+ }));
828
961
  //# sourceMappingURL=index.umd.js.map