'use strict'; var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); // src/util.ts function anyToError(obj) { if (obj instanceof Error) { return obj; } if (typeof obj === "string") { return new Error(obj); } if (typeof obj === "object") { return new Error(JSON.stringify(obj)); } return new Error(String(obj)); } __name(anyToError, "anyToError"); // src/func.ts function ok(value) { return [value, null]; } __name(ok, "ok"); function error(err) { return [null, err]; } __name(error, "error"); async function forceSafe(fn) { try { const result = await fn(); return ok(result); } catch (e) { return error(anyToError(e)); } } __name(forceSafe, "forceSafe"); function multiple(...results) { for (const result of results) { const [, err] = result; if (err !== null) { return error(err); } } const [lastValue, lastErr] = results[results.length - 1]; if (lastErr !== null) { return error(lastErr); } return ok(lastValue); } __name(multiple, "multiple"); exports.anyToError = anyToError; exports.error = error; exports.forceSafe = forceSafe; exports.multiple = multiple; exports.ok = ok; //# sourceMappingURL=index.cjs.map //# sourceMappingURL=index.cjs.map