/** * This file contains the Async algebraic data type. Async is a lazy, * asynchronous adt that is useful for encapsulating anything from file reads * and network requests to timers and loops. * * @module Async * @since 2.0.0 */ import "./_dnt.polyfills.js"; import type { Kind, Out } from "./kind.js"; import type { Applicable } from "./applicable.js"; import type { Combinable } from "./combinable.js"; import type { Initializable } from "./initializable.js"; import type { Flatmappable } from "./flatmappable.js"; import type { Mappable } from "./mappable.js"; import type { Sync } from "./sync.js"; import type { Wrappable } from "./wrappable.js"; /** * @since 2.0.0 */ export type Async = Sync>; /** * @since 2.0.0 */ export interface KindAsync extends Kind { readonly kind: Async>; } /** * @since 2.0.0 */ export declare function delay(ms: number): (ma: Async) => Async; /** * @since 2.0.0 */ export declare function fromSync(fa: Sync): Async; /** * @since 2.0.0 */ export declare function tryCatch(fasr: (...as: AS) => A | PromiseLike, onThrow: (e: unknown, as: AS) => A): (...as: AS) => Async; /** * @since 2.0.0 */ export declare function wrap(a: A): Async; /** * @since 2.0.0 */ export declare function map(fai: (a: A) => I): (ta: Async) => Async; /** * @since 2.0.0 */ export declare function apply(ua: Async): (ufai: Async<(a: A) => I>) => Async; /** * @since 2.0.0 */ export declare function applySequential(ua: Async): (ufai: Async<(a: A) => I>) => Async; /** * @since 2.0.0 */ export declare function flatmap(fati: (a: A) => Async): (ta: Async) => Async; /** * @since 2.0.0 */ export declare function getCombinableAsync({ combine }: Combinable): Combinable>; /** * @since 2.0.0 */ export declare function getInitializableAsync(I: Initializable): Initializable>; /** * @since 2.0.0 */ export declare const WrappableAsync: Wrappable; /** * @since 2.0.0 */ export declare const ApplicableAsync: Applicable; /** * @since 2.0.0 */ export declare const MappableAsync: Mappable; /** * @since 2.0.0 */ export declare const FlatmappableAsync: Flatmappable; /** * @since 2.0.0 */ export declare const tap: (fn: (value: A) => void) => (ua: Async) => Async; /** * @since 2.0.0 */ export declare const bind: (name: Exclude, faui: (a: A) => Async) => (ua: Async) => Async<{ readonly [K_1 in N | keyof A]: K_1 extends keyof A ? A[K_1] : I; }>; /** * @since 2.0.0 */ export declare const bindTo: (name: N) => (ua: Async) => Async<{ readonly [K in N]: A; }>;