@@ -84,14 +84,30 @@ export class FormDataEncoder {
84
84
*
85
85
* @example
86
86
*
87
- * import {Encoder} from "form-data-encoder"
88
- * import {FormData} from "formdata-node"
87
+ * import {Readable} from "stream"
88
+ *
89
+ * import {FormData, File, fileFromPath} from "formdata-node"
90
+ * import {FormDataEncoder} from "form-data-encoder"
91
+ *
92
+ * import fetch from "node-fetch"
93
+ *
94
+ * const form = new FormData()
95
+ *
96
+ * form.set("field", "Just a random string")
97
+ * form.set("file", new File(["Using files is class amazing"]))
98
+ * form.set("fileFromPath", await fileFromPath("path/to/a/file.txt"))
89
99
*
90
- * const fd = new FormData( )
100
+ * const encoder = new FormDataEncoder(form )
91
101
*
92
- * fd.set("greeting", "Hello, World!")
102
+ * const options = {
103
+ * method: "post",
104
+ * headers: encoder.headers,
105
+ * body: Readable.from(encoder)
106
+ * }
93
107
*
94
- * const encoder = new Encoder(fd)
108
+ * const response = await fetch("https://httpbin.org/post", options)
109
+ *
110
+ * console.log(await response.json())
95
111
*/
96
112
constructor ( form : FormDataLike )
97
113
constructor ( form : FormDataLike , boundary : string )
@@ -212,7 +228,7 @@ export class FormDataEncoder {
212
228
*
213
229
* import {Readable} from "stream"
214
230
*
215
- * import {Encoder } from "form-data-encoder"
231
+ * import {FormDataEncoder } from "form-data-encoder"
216
232
*
217
233
* import {FormData} from "formdata-polyfill/esm-min.js"
218
234
* import {fileFrom} from "fetch-blob/form.js"
@@ -221,13 +237,13 @@ export class FormDataEncoder {
221
237
*
222
238
* import fetch from "node-fetch"
223
239
*
224
- * const fd = new FormData()
240
+ * const form = new FormData()
225
241
*
226
- * fd .set("field", "Just a random string")
227
- * fd .set("file", new File(["Using files is class amazing"]))
228
- * fd .set("fileFromPath", await fileFrom("path/to/a/file.txt"))
242
+ * form .set("field", "Just a random string")
243
+ * form .set("file", new File(["Using files is class amazing"]))
244
+ * form .set("fileFromPath", await fileFrom("path/to/a/file.txt"))
229
245
*
230
- * const encoder = new Encoder(fd )
246
+ * const encoder = new FormDataEncoder(form )
231
247
*
232
248
* const options = {
233
249
* method: "post",
@@ -261,17 +277,17 @@ export class FormDataEncoder {
261
277
* import {Readable} from "stream"
262
278
*
263
279
* import {FormData, File, fileFromPath} from "formdata-node"
264
- * import {Encoder } from "form-data-encoder"
280
+ * import {FormDataEncoder } from "form-data-encoder"
265
281
*
266
282
* import fetch from "node-fetch"
267
283
*
268
- * const fd = new FormData()
284
+ * const form = new FormData()
269
285
*
270
- * fd .set("field", "Just a random string")
271
- * fd .set("file", new File(["Using files is class amazing"]))
272
- * fd .set("fileFromPath", await fileFromPath("path/to/a/file.txt"))
286
+ * form .set("field", "Just a random string")
287
+ * form .set("file", new File(["Using files is class amazing"]))
288
+ * form .set("fileFromPath", await fileFromPath("path/to/a/file.txt"))
273
289
*
274
- * const encoder = new Encoder(fd )
290
+ * const encoder = new FormDataEncoder(form )
275
291
*
276
292
* const options = {
277
293
* method: "post",
0 commit comments