UNPKG

ai-utils.js

Version:

Build AI applications, chatbots, and agents with JavaScript and TypeScript.

12 lines (11 loc) 298 B
export 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 }; } };