UNPKG

alinea

Version:
25 lines (23 loc) 608 B
import "../chunks/chunk-NZLE2WMY.js"; // src/core/Outcome.ts function outcome(run) { try { if (typeof run === "function") { const result = run(); if (isPromiseLike(result)) return outcome(result); return [result]; } if (isPromiseLike(run)) return run.then((v) => [v]).catch((err) => [void 0, err]); return [run]; } catch (error) { if (!(error instanceof Error)) return [void 0, new Error(String(error))]; return [void 0, error]; } } function isPromiseLike(value) { return value && typeof value === "object" && "then" in value; } export { outcome };