@zerothrow/core
Version:
Core ZeroThrow functionality - Rust-style Result<T,E> for TypeScript
27 lines (24 loc) • 783 B
text/typescript
import { a as attempt, t as tryAsync, e as err } from './core-exports-BwHM2IUP.cjs';
export { E as Err, b as ErrorCode, d as ErrorContext, O as Ok, R as Result, c as ZeroThrow } from './core-exports-BwHM2IUP.cjs';
import { Result, ZeroError } from './platform/index.cjs';
/**
* 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 };