@naturalcycles/js-lib 14.121.0 → 14.122.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.
@@ -80,6 +80,12 @@ export interface FetcherOptions {
80
80
  timeoutSeconds?: number;
81
81
  json?: any;
82
82
  text?: string;
83
+ /**
84
+ * Supports all the types that RequestInit.body supports.
85
+ *
86
+ * Useful when you want to e.g pass FormData.
87
+ */
88
+ body?: Blob | BufferSource | FormData | URLSearchParams | string;
83
89
  credentials?: RequestCredentials;
84
90
  headers?: Record<string, any>;
85
91
  mode?: FetcherMode;
@@ -309,6 +309,9 @@ class Fetcher {
309
309
  req.init.body = opt.text;
310
310
  req.init.headers['content-type'] = 'text/plain';
311
311
  }
312
+ else if (opt.body !== undefined) {
313
+ req.init.body = opt.body;
314
+ }
312
315
  return req;
313
316
  }
314
317
  }
@@ -338,6 +338,9 @@ export class Fetcher {
338
338
  req.init.body = opt.text;
339
339
  req.init.headers['content-type'] = 'text/plain';
340
340
  }
341
+ else if (opt.body !== undefined) {
342
+ req.init.body = opt.body;
343
+ }
341
344
  return req;
342
345
  }
343
346
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.121.0",
3
+ "version": "14.122.0",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -103,8 +103,15 @@ export interface FetcherOptions {
103
103
  * so both should finish within this single timeout (not each).
104
104
  */
105
105
  timeoutSeconds?: number
106
+
106
107
  json?: any
107
108
  text?: string
109
+ /**
110
+ * Supports all the types that RequestInit.body supports.
111
+ *
112
+ * Useful when you want to e.g pass FormData.
113
+ */
114
+ body?: Blob | BufferSource | FormData | URLSearchParams | string
108
115
 
109
116
  credentials?: RequestCredentials
110
117
 
@@ -546,6 +553,8 @@ export class Fetcher {
546
553
  } else if (opt.text !== undefined) {
547
554
  req.init.body = opt.text
548
555
  req.init.headers['content-type'] = 'text/plain'
556
+ } else if (opt.body !== undefined) {
557
+ req.init.body = opt.body
549
558
  }
550
559
 
551
560
  return req