export declare type Awaitable<T> = T | PromiseLike<T>;
export declare type Mapper<T, U> = (t: T) => Awaitable<U>;
export declare type Filter<T> = (t: T) => Awaitable<boolean>;
export declare type Reducer<T, U> = (acc: U, t: T) => Awaitable<U>;
export declare type NamedEventuals<T> = {
    [k: string]: Eventual<any>;
} & {
    [K in keyof T]: T[K];
};
export declare type Join<T> = Eventual<{
    [key in keyof T]: T[key] extends Eventual<infer U> ? U : any;
}>;
export interface TryMapOptions {
    onError: (err: any) => void;
}
export declare type Subscriber<T> = (value: T) => void;
export interface Eventual<T> {
    readonly valueReady: boolean;
    value(): Promise<T>;
    subscribe(subscriber: Subscriber<T>): void;
    map<U>(f: Mapper<T, U>): Eventual<U>;
    tryMap<U>(f: Mapper<T, U>, options: TryMapOptions): Eventual<U>;
    filter(f: Filter<T>): Eventual<T>;
    pipe(f: (t: T) => Awaitable<void>): void;
    throttle(interval: number): Eventual<T>;
    reduce<U>(f: Reducer<T, U>, initial: U): Eventual<U>;
    values(): AsyncGenerator<T, never, void>;
}
export interface WritableEventual<T> extends Eventual<T> {
    push(value: T): void;
}
export declare class EventualValue<T> implements WritableEventual<T> {
    inner: T | undefined;
    promise: Promise<T> | undefined;
    resolvePromise?: (value: T) => void;
    subscribers: Subscriber<T>[];
    constructor(initial?: T);
    get valueReady(): boolean;
    value(): Promise<T>;
    subscribe(subscriber: Subscriber<T>): void;
    push(value: T): void;
    map<U>(f: Mapper<T, U>): Eventual<U>;
    tryMap<U>(f: Mapper<T, U>, options: TryMapOptions): Eventual<U>;
    filter(f: Filter<T>): Eventual<T>;
    pipe(f: (t: T) => Awaitable<void>): void;
    throttle(interval: number): Eventual<T>;
    reduce<U>(f: Reducer<T, U>, initial: U): Eventual<U>;
    values(): AsyncGenerator<T, never, void>;
}
export declare function mutable<T>(initial?: T): WritableEventual<T>;
export declare function map<T, U>(source: Eventual<T>, mapper: (t: T) => Awaitable<U>): Eventual<U>;
export declare function tryMap<T, U>(source: Eventual<T>, mapper: (t: T) => Awaitable<U>, { onError }: TryMapOptions): Eventual<U>;
export declare function filter<T>(source: Eventual<T>, f: Filter<T>): Eventual<T>;
export declare function pipe<T>(source: Eventual<T>, fn: (t: T) => Awaitable<void>): void;
export declare function throttle<T>(source: Eventual<T>, interval: number): Eventual<T>;
export declare function timer(milliseconds: number): Eventual<number>;
export declare function reduce<T, U>(source: Eventual<T>, reducer: (acc: U, t: T) => Awaitable<U>, initial: U): Eventual<U>;
export declare function join<T>(sources: NamedEventuals<T>): Join<T>;
