/** @module hareactive/stream */
import { Reactive } from "./frp-common";
import { Behavior } from "./behavior";
/**
* A stream is a list of occurences over time. Each occurence happens
* at a discrete point in time and has an associated value.
* Semantically it is a list `type Stream = [Time, A]`.
*/
export declare abstract class Stream extends Reactive {
constructor();
abstract push(a: any): void;
map(fn: (a: A) => B): Stream;
mapTo(val: B): Stream;
combine(otherStream: Stream): Stream<(A | B)>;
filter(fn: (a: A) => boolean): Stream;
scanS(fn: (a: A, b: B) => B, startingValue: B): Behavior>;
scan(fn: (a: A, b: B) => B, init: B): Behavior>;
delay(ms: number): Stream;
throttle(ms: number): Stream;
debounce(ms: number): Stream;
}
/** @private */
export declare class SinkStream extends Stream {
push(a: A): void;
}
export declare function debounce(ms: number, stream: Stream): Stream;
export declare function throttle(ms: number, stream: Stream): Stream;
export declare function delay(ms: number, stream: Stream): Stream;
export declare function apply(behavior: Behavior<(a: A) => B>, stream: Stream): Stream;
/**
* @param fn A predicate function that returns a boolean for `A`.
* @param stream The stream to filter.
* @returns Stream that only contains the occurences from `stream`
* for which `fn` returns true.
*/
export declare function filter(predicate: (a: A) => boolean, s: Stream): Stream;
export declare function split(predicate: (a: A) => boolean, stream: Stream): [Stream, Stream];
export declare function filterApply(predicate: Behavior<(a: A) => boolean>, stream: Stream): Stream;
export declare function keepWhen(stream: Stream, behavior: Behavior): Stream;
/**
* The returned initially has the initial value, on each
* occurence in `source` the function is applied to the current value
* of the behaviour and the value of the occurence, the returned value
* becomes the next value of the behavior.
*/
export declare function scanS(fn: (a: A, b: B) => B, startingValue: B, stream: Stream): Behavior>;
export declare function snapshot(b: Behavior, s: Stream): Stream;
export declare function snapshotWith(f: (a: A, b: B) => C, b: Behavior, s: Stream): Stream;
export declare function switchStream(b: Behavior>): Stream;
export declare function changes(b: Behavior): Stream;
export declare class PlaceholderStream extends Stream {
private source;
push(a: B): void;
replaceWith(s: Stream): void;
}
export declare function placeholderStream(): PlaceholderStream;
export declare function combineList(ss: Stream[]): Stream;
/**
* @returns A stream that never has any occurrences.
*/
export declare function empty(): Stream;
export declare function subscribe(fn: (a: A) => void, stream: Stream): void;
export declare function combine(a: Stream, b: Stream): Stream<(A | B)>;
export declare function isStream(s: any): s is Stream;