@naturalcycles/js-lib 14.131.0 → 14.131.2

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.
@@ -33,9 +33,9 @@ class Fetcher {
33
33
  // mode=void
34
34
  this[`${method}Void`] = async (url, opt) => {
35
35
  return await this.fetch(url, {
36
- ...opt,
37
36
  method,
38
37
  mode: 'void',
38
+ ...opt,
39
39
  });
40
40
  };
41
41
  if (method === 'head')
@@ -43,17 +43,17 @@ class Fetcher {
43
43
  ;
44
44
  this[`${method}Text`] = async (url, opt) => {
45
45
  return await this.fetch(url, {
46
- ...opt,
47
46
  method,
48
47
  mode: 'text',
48
+ ...opt,
49
49
  });
50
50
  };
51
- // mode=json
51
+ // Default mode=json, but overridable
52
52
  this[method] = async (url, opt) => {
53
53
  return await this.fetch(url, {
54
- ...opt,
55
54
  method,
56
55
  mode: 'json',
56
+ ...opt,
57
57
  });
58
58
  };
59
59
  });
@@ -346,7 +346,7 @@ class Fetcher {
346
346
  return norm;
347
347
  }
348
348
  normalizeOptions(url, opt) {
349
- const { baseUrl, timeoutSeconds, throwHttpErrors, retryPost, retry4xx, retry5xx, retry, mode } = this.cfg;
349
+ const { baseUrl, timeoutSeconds, throwHttpErrors, retryPost, retry4xx, retry5xx, retry, mode, jsonReviver, } = this.cfg;
350
350
  const req = {
351
351
  mode,
352
352
  url,
@@ -355,6 +355,7 @@ class Fetcher {
355
355
  retryPost,
356
356
  retry4xx,
357
357
  retry5xx,
358
+ jsonReviver,
358
359
  ...(0, object_util_1._omit)(opt, ['method', 'headers', 'credentials']),
359
360
  retry: {
360
361
  ...retry,
@@ -30,17 +30,17 @@ export class Fetcher {
30
30
  HTTP_METHODS.forEach(method => {
31
31
  // mode=void
32
32
  this[`${method}Void`] = async (url, opt) => {
33
- return await this.fetch(url, Object.assign(Object.assign({}, opt), { method, mode: 'void' }));
33
+ return await this.fetch(url, Object.assign({ method, mode: 'void' }, opt));
34
34
  };
35
35
  if (method === 'head')
36
36
  return // mode=text
37
37
  ;
38
38
  this[`${method}Text`] = async (url, opt) => {
39
- return await this.fetch(url, Object.assign(Object.assign({}, opt), { method, mode: 'text' }));
39
+ return await this.fetch(url, Object.assign({ method, mode: 'text' }, opt));
40
40
  };
41
- // mode=json
41
+ // Default mode=json, but overridable
42
42
  this[method] = async (url, opt) => {
43
- return await this.fetch(url, Object.assign(Object.assign({}, opt), { method, mode: 'json' }));
43
+ return await this.fetch(url, Object.assign({ method, mode: 'json' }, opt));
44
44
  };
45
45
  });
46
46
  }
@@ -388,14 +388,15 @@ export class Fetcher {
388
388
  }
389
389
  normalizeOptions(url, opt) {
390
390
  var _a, _b;
391
- const { baseUrl, timeoutSeconds, throwHttpErrors, retryPost, retry4xx, retry5xx, retry, mode } = this.cfg;
391
+ const { baseUrl, timeoutSeconds, throwHttpErrors, retryPost, retry4xx, retry5xx, retry, mode, jsonReviver, } = this.cfg;
392
392
  const req = Object.assign(Object.assign({ mode,
393
393
  url,
394
394
  timeoutSeconds,
395
395
  throwHttpErrors,
396
396
  retryPost,
397
397
  retry4xx,
398
- retry5xx }, _omit(opt, ['method', 'headers', 'credentials'])), { retry: Object.assign(Object.assign({}, retry), _filterUndefinedValues(opt.retry || {})), init: _merge(Object.assign(Object.assign({}, this.cfg.init), { method: opt.method || this.cfg.init.method, credentials: opt.credentials || this.cfg.init.credentials, redirect: ((_b = (_a = opt.followRedirects) !== null && _a !== void 0 ? _a : this.cfg.followRedirects) !== null && _b !== void 0 ? _b : true) ? 'follow' : 'error' }), {
398
+ retry5xx,
399
+ jsonReviver }, _omit(opt, ['method', 'headers', 'credentials'])), { retry: Object.assign(Object.assign({}, retry), _filterUndefinedValues(opt.retry || {})), init: _merge(Object.assign(Object.assign({}, this.cfg.init), { method: opt.method || this.cfg.init.method, credentials: opt.credentials || this.cfg.init.credentials, redirect: ((_b = (_a = opt.followRedirects) !== null && _a !== void 0 ? _a : this.cfg.followRedirects) !== null && _b !== void 0 ? _b : true) ? 'follow' : 'error' }), {
399
400
  headers: _mapKeys(opt.headers || {}, k => k.toLowerCase()),
400
401
  }) });
401
402
  // setup url
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.131.0",
3
+ "version": "14.131.2",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -54,9 +54,9 @@ export class Fetcher {
54
54
  // mode=void
55
55
  this[`${method}Void`] = async (url: string, opt?: FetcherOptions): Promise<void> => {
56
56
  return await this.fetch<void>(url, {
57
- ...opt,
58
57
  method,
59
58
  mode: 'void',
59
+ ...opt,
60
60
  })
61
61
  }
62
62
 
@@ -66,18 +66,18 @@ export class Fetcher {
66
66
  opt?: FetcherOptions,
67
67
  ): Promise<string> => {
68
68
  return await this.fetch<string>(url, {
69
- ...opt,
70
69
  method,
71
70
  mode: 'text',
71
+ ...opt,
72
72
  })
73
73
  }
74
74
 
75
- // mode=json
75
+ // Default mode=json, but overridable
76
76
  this[method] = async <T = unknown>(url: string, opt?: FetcherOptions): Promise<T> => {
77
77
  return await this.fetch<T>(url, {
78
- ...opt,
79
78
  method,
80
79
  mode: 'json',
80
+ ...opt,
81
81
  })
82
82
  }
83
83
  })
@@ -436,8 +436,17 @@ export class Fetcher {
436
436
  }
437
437
 
438
438
  private normalizeOptions(url: string, opt: FetcherOptions): FetcherRequest {
439
- const { baseUrl, timeoutSeconds, throwHttpErrors, retryPost, retry4xx, retry5xx, retry, mode } =
440
- this.cfg
439
+ const {
440
+ baseUrl,
441
+ timeoutSeconds,
442
+ throwHttpErrors,
443
+ retryPost,
444
+ retry4xx,
445
+ retry5xx,
446
+ retry,
447
+ mode,
448
+ jsonReviver,
449
+ } = this.cfg
441
450
 
442
451
  const req: FetcherRequest = {
443
452
  mode,
@@ -447,6 +456,7 @@ export class Fetcher {
447
456
  retryPost,
448
457
  retry4xx,
449
458
  retry5xx,
459
+ jsonReviver,
450
460
  ..._omit(opt, ['method', 'headers', 'credentials']),
451
461
  retry: {
452
462
  ...retry,