(form, key, value)
| 80436 | const form = await createForm(opts.body); |
| 80437 | return getMultipartRequestOptions3(form, opts); |
| 80438 | }; |
| 80439 | var createForm = async (body) => { |
| 80440 | const form = new FormData5(); |
| 80441 | await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value))); |
| 80442 | return form; |
| 80443 | }; |
| 80444 | var addFormValue = async (form, key, value) => { |
| 80445 | if (value === void 0) |
| 80446 | return; |
| 80447 | if (value == null) { |
| 80448 | throw new TypeError(`Received null for "${key}"; to pass null in FormData, you must use the string 'null'`); |
| 80449 | } |
| 80450 | if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") { |
| 80451 | form.append(key, String(value)); |
| 80452 | } else if (isUploadable(value)) { |
| 80453 | const file = await toFile2(value); |
| 80454 | form.append(key, file); |
| 80455 | } else if (Array.isArray(value)) { |
| 80456 | await Promise.all(value.map((entry) => addFormValue(form, key + "[]", entry))); |
| 80457 | } else if (typeof value === "object") { |
| 80458 | await Promise.all(Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop))); |
| 80459 | } else { |
no test coverage detected
searching dependent graphs…