UNPKG

@zerothrow/core

Version:

Core ZeroThrow functionality - Rust-style Result<T,E> for TypeScript

27 lines (24 loc) 780 B
import { a as attempt, t as tryAsync, e as err } from './core-exports-CTfLzI5Z.js'; export { E as Err, b as ErrorCode, d as ErrorContext, O as Ok, R as Result, c as ZeroThrow } from './core-exports-CTfLzI5Z.js'; import { Result, ZeroError } from './platform/index.js'; /** * ZT - The pocket knife for daily ZeroThrow use * * @example * ```typescript * import { ZT } from '@zerothrow/zerothrow'; * * const result = ZT.try(() => JSON.parse(input)); * if (!result.ok) { * return ZT.err(new Error('Invalid JSON')); * } * return ZT.ok(result.value); * ``` */ declare const ZT: { readonly try: typeof attempt; readonly tryAsync: typeof tryAsync; readonly ok: <T>(value: T) => Result<T, ZeroError>; readonly err: typeof err; }; export { ZT, ZeroError };