forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultipart.web.js
More file actions
37 lines (37 loc) · 903 Bytes
/
Copy pathmultipart.web.js
File metadata and controls
37 lines (37 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"use strict";
/**
* Utility function for constructing a multipart form in the browser.
*
* @packageDocumentation
* @internal
* @hidden
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.toForm = void 0;
/**
* @internal
* @hidden
*/
function toForm(fields, callback) {
let form;
try {
form = new FormData();
for (const key of Object.keys(fields)) {
let value = fields[key];
if (value === undefined)
continue;
if (!(value instanceof Blob) &&
(typeof value === "object" || typeof value === "function")) {
value = JSON.stringify(value);
}
form.append(key, value);
}
}
catch (e) {
callback(e);
return;
}
callback(null, { body: form });
}
exports.toForm = toForm;
//# sourceMappingURL=multipart.web.js.map