@naturalcycles/js-lib 14.131.0 → 14.131.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.
@@ -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
  });
@@ -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
  }
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.1",
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
  })