Neah/node_modules/layerr/dist/tools.js
2025-04-24 19:10:05 +02:00

29 lines
756 B
JavaScript

import { isError } from "./error.js";
export function parseArguments(args) {
let options, shortMessage = "";
if (args.length === 0) {
options = {};
}
else if (isError(args[0])) {
options = {
cause: args[0],
};
shortMessage = args.slice(1).join(" ") || "";
}
else if (args[0] && typeof args[0] === "object") {
options = Object.assign({}, args[0]);
shortMessage = args.slice(1).join(" ") || "";
}
else if (typeof args[0] === "string") {
options = {};
shortMessage = shortMessage = args.join(" ") || "";
}
else {
throw new Error("Invalid arguments passed to Layerr");
}
return {
options,
shortMessage,
};
}