@aplus-frontend/ui
Version:
64 lines (63 loc) • 1.33 kB
JavaScript
import { ApNeedNameKeyDefault as p } from "../interface.mjs";
function n(y, t) {
if (y === !0) {
if (typeof t == "string")
return [
{
path: t,
fileName: t
}
];
if (Array.isArray(t))
return t.map((r) => ({
path: r?.[p.pathKey] ?? r,
fileName: r?.[p.nameKey] ?? r
}));
if (typeof t == "object")
return [
{
path: t?.[p.pathKey],
fileName: t?.[p.nameKey]
}
];
} else if (typeof y == "object") {
if (typeof t == "string")
return [
{
path: t,
fileName: t
}
];
if (Array.isArray(t))
return t.map((r) => ({
path: r?.[y?.pathKey || p.pathKey] ?? r,
fileName: r?.[y?.nameKey || p.nameKey] ?? r
}));
if (typeof t == "object")
return [
{
path: t?.[y?.pathKey || p.pathKey],
fileName: t?.[y?.nameKey || p.nameKey]
}
];
} else {
if (typeof t == "string")
return [
{
path: t,
fileName: t
}
];
if (Array.isArray(t))
return t.map((r) => typeof r == "string" ? {
path: r,
fileName: r
} : r);
if (typeof t == "object")
return [t];
}
return [];
}
export {
n as getFileInfo
};