MCPcopy
hub / github.com/di-sukharev/opencommit / toFile

Function toFile

out/cli.cjs:69431–69448  ·  view source on GitHub ↗
(value, name, options)

Source from the content-addressed store, hash-verified

69429 }
69430 };
69431}
69432
69433// node_modules/@anthropic-ai/sdk/uploads.mjs
69434var isResponseLike = (value) => value != null && typeof value === "object" && typeof value.url === "string" && typeof value.blob === "function";
69435var isFileLike2 = (value) => value != null && typeof value === "object" && typeof value.name === "string" && typeof value.lastModified === "number" && isBlobLike(value);
69436var 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";
69437async function toFile(value, name, options) {
69438 value = await value;
69439 options ?? (options = isFileLike2(value) ? { lastModified: value.lastModified, type: value.type } : {});
69440 if (isResponseLike(value)) {
69441 const blob = await value.blob();
69442 name || (name = new URL(value.url).pathname.split(/[\\/]/).pop() ?? "unknown_file");
69443 return new File2([blob], name, options);
69444 }
69445 const bits = await getBytes(value);
69446 name || (name = getName(value) ?? "unknown_file");
69447 if (!options.type) {
69448 const type2 = bits[0]?.type;
69449 if (typeof type2 === "string") {
69450 options = { ...options, type: type2 };
69451 }

Callers

nothing calls this directly

Calls 5

isFileLike2Function · 0.85
isResponseLikeFunction · 0.85
getBytesFunction · 0.85
getNameFunction · 0.85
blobMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…