ai-utils.js
Version:
Build AI applications, chatbots, and agents with JavaScript and TypeScript.
16 lines (15 loc) • 421 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.runSafe = void 0;
const runSafe = async (f) => {
try {
return { ok: true, output: await f() };
}
catch (error) {
if (error instanceof Error && error.name === "AbortError") {
return { ok: false, isAborted: true };
}
return { ok: false, error };
}
};
exports.runSafe = runSafe;