(value, name, options)
| 80376 | |
| 80377 | // node_modules/openai/uploads.mjs |
| 80378 | var isResponseLike2 = (value) => value != null && typeof value === "object" && typeof value.url === "string" && typeof value.blob === "function"; |
| 80379 | var isFileLike3 = (value) => value != null && typeof value === "object" && typeof value.name === "string" && typeof value.lastModified === "number" && isBlobLike2(value); |
| 80380 | var isBlobLike2 = (value) => value != null && typeof value === "object" && typeof value.size === "number" && typeof value.type === "string" && typeof value.text === "function" && typeof value.slice === "function" && typeof value.arrayBuffer === "function"; |
| 80381 | var isUploadable = (value) => { |
| 80382 | return isFileLike3(value) || isResponseLike2(value) || isFsReadStream2(value); |
| 80383 | }; |
| 80384 | async function toFile2(value, name, options) { |
| 80385 | value = await value; |
| 80386 | options ?? (options = isFileLike3(value) ? { lastModified: value.lastModified, type: value.type } : {}); |
| 80387 | if (isResponseLike2(value)) { |
| 80388 | const blob = await value.blob(); |
| 80389 | name || (name = new URL(value.url).pathname.split(/[\\/]/).pop() ?? "unknown_file"); |
| 80390 | return new File4([blob], name, options); |
| 80391 | } |
| 80392 | const bits = await getBytes2(value); |
| 80393 | name || (name = getName2(value) ?? "unknown_file"); |
| 80394 | if (!options.type) { |
| 80395 | const type2 = bits[0]?.type; |
| 80396 | if (typeof type2 === "string") { |
| 80397 | options = { ...options, type: type2 }; |
| 80398 | } |
no test coverage detected
searching dependent graphs…