/opt/canhelp/node_modules/openai/internal
NameSizeModeActions
decoders/-0755rm
qs/-0755rm
utils/-0755rm
builtin-types.d.mts28470644editdlrm
builtin-types.d.mts.map10990644editdlrm
builtin-types.d.ts28460644editdlrm
builtin-types.d.ts.map10980644editdlrm
builtin-types.js2050644editdlrm
builtin-types.js.map1390644editdlrm
builtin-types.mjs1400644editdlrm
builtin-types.mjs.map1390644editdlrm
detect-platform.d.mts7490644editdlrm
detect-platform.d.mts.map7360644editdlrm
detect-platform.d.ts7480644editdlrm
detect-platform.d.ts.map7350644editdlrm
detect-platform.js62000644editdlrm
detect-platform.js.map44170644editdlrm
detect-platform.mjs59220644editdlrm
detect-platform.mjs.map43900644editdlrm
errors.d.mts1530644editdlrm
errors.d.mts.map2100644editdlrm
errors.d.ts1520644editdlrm
errors.d.ts.map2090644editdlrm
errors.js15390644editdlrm
errors.js.map13700644editdlrm
errors.mjs13750644editdlrm
errors.mjs.map13480644editdlrm
headers.d.mts9170644editdlrm
headers.d.mts.map6480644editdlrm
headers.d.ts9160644editdlrm
headers.d.ts.map6470644editdlrm
headers.js27450644editdlrm
headers.js.map25230644editdlrm
headers.mjs25280644editdlrm
headers.mjs.map24910644editdlrm
parse.d.mts7960644editdlrm
parse.d.mts.map8510644editdlrm
parse.d.ts7920644editdlrm
parse.d.ts.map8500644editdlrm
parse.js26850644editdlrm
parse.js.map22400644editdlrm
parse.mjs25090644editdlrm
parse.mjs.map22390644editdlrm
request-options.d.mts25190644editdlrm
request-options.d.mts.map13610644editdlrm
request-options.d.ts25130644editdlrm
request-options.d.ts.map13600644editdlrm
request-options.js4740644editdlrm
request-options.js.map3550644editdlrm
request-options.mjs3280644editdlrm
request-options.mjs.map3410644editdlrm
shim-types.d.mts8730644editdlrm
shim-types.d.mts.map8520644editdlrm
shim-types.d.ts8720644editdlrm
shim-types.d.ts.map8510644editdlrm
shim-types.js2020644editdlrm
shim-types.js.map1330644editdlrm
shim-types.mjs1370644editdlrm
shim-types.mjs.map1330644editdlrm
shims.d.mts10510644editdlrm
shims.d.mts.map6140644editdlrm
shims.d.ts10480644editdlrm
shims.d.ts.map6130644editdlrm
shims.js34310644editdlrm
shims.js.map22710644editdlrm
shims.mjs31250644editdlrm
shims.mjs.map22380644editdlrm
stream-utils.d.mts4280644editdlrm
stream-utils.d.mts.map2240644editdlrm
stream-utils.d.ts4270644editdlrm
stream-utils.d.ts.map2230644editdlrm
stream-utils.js13380644editdlrm
stream-utils.js.map8680644editdlrm
stream-utils.mjs11980644editdlrm
stream-utils.mjs.map8580644editdlrm
to-file.d.mts22160644editdlrm
to-file.d.mts.map10480644editdlrm
to-file.d.ts22140644editdlrm
to-file.d.ts.map10470644editdlrm
to-file.js37210644editdlrm
to-file.js.map30800644editdlrm
to-file.mjs35690644editdlrm
to-file.mjs.map30780644editdlrm
tslib.js30890644editdlrm
tslib.mjs10800644editdlrm
types.d.mts62310644editdlrm
types.d.mts.map36570644editdlrm
types.d.ts62300644editdlrm
types.d.ts.map36560644editdlrm
types.js1970644editdlrm
types.js.map1230644editdlrm
types.mjs1320644editdlrm
types.mjs.map1230644editdlrm
uploads.d.mts19260644editdlrm
uploads.d.mts.map13120644editdlrm
uploads.d.ts19220644editdlrm
uploads.d.ts.map13110644editdlrm
uploads.js61510644editdlrm
uploads.js.map53840644editdlrm
uploads.mjs55730644editdlrm
uploads.mjs.map52760644editdlrm
utils.d.mts2780644editdlrm
utils.d.mts.map1140644editdlrm
utils.d.ts2700644editdlrm
utils.d.ts.map1130644editdlrm
utils.js6530644editdlrm
utils.js.map2160644editdlrm
utils.mjs3630644editdlrm
utils.mjs.map1230644editdlrm
Edit: /opt/canhelp/node_modules/openai/internal/to-file.mjs (3569B)
import { getName, makeFile, isAsyncIterable } from "./uploads.mjs"; import { checkFileSupport } from "./uploads.mjs"; /** * This check adds the arrayBuffer() method type because it is available and used at runtime */ const isBlobLike = (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'; /** * This check adds the arrayBuffer() method type because it is available and used at runtime */ const isFileLike = (value) => value != null && typeof value === 'object' && typeof value.name === 'string' && typeof value.lastModified === 'number' && isBlobLike(value); const isResponseLike = (value) => value != null && typeof value === 'object' && typeof value.url === 'string' && typeof value.blob === 'function'; /** * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats * @param value the raw content of the file. Can be an {@link Uploadable}, BlobLikePart, or AsyncIterable of BlobLikeParts * @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible * @param {Object=} options additional properties * @param {string=} options.type the MIME type of the content * @param {number=} options.lastModified the last modified timestamp * @returns a {@link File} with the given properties */ export async function toFile(value, name, options) { checkFileSupport(); // If it's a promise, resolve it. value = await value; // If we've been given a `File` we don't need to do anything if (isFileLike(value)) { if (value instanceof File) { return value; } return makeFile([await value.arrayBuffer()], value.name); } if (isResponseLike(value)) { const blob = await value.blob(); name || (name = new URL(value.url).pathname.split(/[\\/]/).pop()); return makeFile(await getBytes(blob), name, options); } const parts = await getBytes(value); name || (name = getName(value)); if (!options?.type) { const type = parts.find((part) => typeof part === 'object' && 'type' in part && part.type); if (typeof type === 'string') { options = { ...options, type }; } } return makeFile(parts, name, options); } async function getBytes(value) { let parts = []; if (typeof value === 'string' || ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc. value instanceof ArrayBuffer) { parts.push(value); } else if (isBlobLike(value)) { parts.push(value instanceof Blob ? value : await value.arrayBuffer()); } else if (isAsyncIterable(value) // includes Readable, ReadableStream, etc. ) { for await (const chunk of value) { parts.push(...(await getBytes(chunk))); // TODO, consider validating? } } else { const constructor = value?.constructor?.name; throw new Error(`Unexpected data type: ${typeof value}${constructor ? `; constructor: ${constructor}` : ''}${propsForError(value)}`); } return parts; } function propsForError(value) { if (typeof value !== 'object' || value === null) return ''; const props = Object.getOwnPropertyNames(value); return `; props: [${props.map((p) => `"${p}"`).join(', ')}]`; } //# sourceMappingURL=to-file.mjs.map