UNPKG

fp-ts-std

Version:

The missing pseudo-standard library for fp-ts.

69 lines 1.78 kB
/** * Utility functions to accommodate `fp-ts/TaskOption`. * * @since 0.15.0 */ import * as TO from "fp-ts/TaskOption"; type TaskOption<A> = TO.TaskOption<A>; /** * Unwrap the promise from within a `TaskOption`, rejecting if `None`. * * @example * import { unsafeUnwrap } from 'fp-ts-std/TaskOption' * import * as TO from 'fp-ts/TaskOption' * * unsafeUnwrap(TO.of(5)).then((x) => { * assert.strictEqual(x, 5) * }) * * @category 3 Functions * @since 0.15.0 */ export declare const unsafeUnwrap: <A>(x: TaskOption<A>) => Promise<A>; /** * Unwrap the promise from within a `TaskOption`, rejecting with `msg` if * `None`. * * @example * import { unsafeExpect } from 'fp-ts-std/TaskOption' * import * as TO from 'fp-ts/TaskOption' * * assert.rejects( * unsafeExpect('foo')(TO.none), * Error('Unwrapped `None`'), * ) * * @category 3 Functions * @since 0.16.0 */ export declare const unsafeExpect: (msg: string) => <A>(x: TaskOption<A>) => Promise<A>; /** * Convenient alias for `TO.of(undefined)`. * * @example * import { flow, pipe, constant } from 'fp-ts/function' * import * as Fn from 'fp-ts-std/Function' * import * as O from 'fp-ts/Option' * import Option = O.Option * import * as TO from 'fp-ts/TaskOption' * import TaskOption = TO.TaskOption * import { pass } from 'fp-ts-std/TaskOption' * import { log } from 'fp-ts/Console' * * const mcount: Option<number> = O.some(123) * const tryAsyncLog: <A>(x: A) => TaskOption<void> = flow(log, TO.fromIO) * * const logCount: TaskOption<void> = pipe( * mcount, * O.match( * constant(pass), * tryAsyncLog, * ), * ) * * @category 2 Typeclass Methods * @since 0.17.0 */ export declare const pass: TaskOption<void>; export {}; //# sourceMappingURL=TaskOption.d.ts.map