// @flow import type { Stream, Sink, Scheduler, Task, Disposable, Time, Period, Delay } from '@most/types' export type SeedValue = { seed: S, value: A } declare export function runEffects (s: Stream, scheduler: Scheduler): Promise declare export function runEffects (s: Stream): (scheduler: Scheduler) => Promise declare export function run (sink: Sink, scheduler: Scheduler, s: Stream): Disposable declare export function run (sink: Sink): (scheduler: Scheduler, s: Stream) => Disposable declare export function run (sink: Sink, scheduler: Scheduler): (s: Stream) => Disposable declare export function run (sink: Sink): (scheduler: Scheduler) => (s: Stream) => Disposable declare export function empty (): Stream declare export function never (): Stream declare export function now (a: A): Stream declare export function at (t: Time, a: A): Stream declare export function at (t: Time): (a: A) => Stream export type RunStream = (sink: Sink, scheduler: Scheduler) => Disposable declare export function newStream (run: RunStream): Stream declare export function startWith (a: A, s: Stream): Stream declare export function startWith (a: A): (s: Stream) => Stream declare export function periodic (period: Period): Stream declare export function map (f: (A) => B, s: Stream): Stream declare export function map (f: (A) => B): (s: Stream) => Stream declare export function constant (a: A, s: Stream): Stream declare export function constant (a: A): (s: Stream) => Stream declare export function tap (f: (A) => any, s: Stream): Stream declare export function tap (f: (A) => any): (s: Stream) => Stream declare export function scan (f: (B, A) => B, b: B, s: Stream): Stream declare export function scan (f: (B, A) => B): (b: B, s: Stream) => Stream declare export function scan (f: (B, A) => B, b: B): (s: Stream) => Stream declare export function scan (f: (B, A) => B): (b: B) => (s: Stream) => Stream declare export function loop (f: (S, A) => SeedValue, seed: S, s: Stream): Stream declare export function loop (f: (S, A) => SeedValue): (seed: S, s: Stream) => Stream declare export function loop (f: (S, A) => SeedValue, seed: S): (s: Stream) => Stream declare export function loop (f: (S, A) => SeedValue): (seed: S) => (s: Stream) => Stream declare export function ap (fs: Stream<(A) => B>, s: Stream): Stream declare export function ap (fs: Stream<(A) => B>): (s: Stream) => Stream declare export function chain (f: (A) => Stream, s: Stream): Stream declare export function chain (f: (A) => Stream): (s: Stream) => Stream declare export function join (s: Stream>): Stream declare export function concatMap (f: (A) => Stream, s: Stream): Stream declare export function concatMap (f: (A) => Stream): (s: Stream) => Stream declare export function mergeConcurrently (concurrency: number, s: Stream>): Stream declare export function mergeConcurrently (concurrency: number): (s: Stream>) => Stream declare export function mergeMapConcurrently (f: (A) => Stream, concurrency: number, s: Stream): Stream declare export function mergeMapConcurrently (f: (A) => Stream, concurrency: number): (s: Stream) => Stream declare export function mergeMapConcurrently (f: (A) => Stream): { (concurrency: number, s: Stream): Stream, (concurrency: number): (s: Stream) => Stream } declare export function continueWith (f: (any) => Stream, s: Stream): Stream declare export function continueWith (f: (any) => Stream): (s: Stream) => Stream declare export function switchLatest (s: Stream>): Stream declare export function merge (s1: Stream, s2: Stream): Stream declare export function merge (s1: Stream): (s2: Stream) => Stream type MergeArray = ($ReadOnlyArray>) => Stream declare export function mergeArray (ss: S): $Call declare export function sample (values: Stream, sampler: Stream): Stream declare export function sample (values: Stream): (sampler: Stream) => Stream declare export function snapshot (f: (A, B) => C, values: Stream, sampler: Stream): Stream declare export function snapshot (f: (A, B) => C): (values: Stream, sampler: Stream) => Stream declare export function snapshot (f: (A, B) => C, values: Stream): (sampler: Stream) => Stream declare export function snapshot (f: (A, B) => C): (values: Stream) => (sampler: Stream) => Stream declare export function combine (f: (A, B) => Z, sa: Stream, sb: Stream): Stream declare export function combine (f: (A, B) => Z): (sa: Stream, sb: Stream) => Stream declare export function combine (f: (A, B) => Z, sa: Stream): (sb: Stream) => Stream declare export function combine (f: (A, B) => Z): (sa: Stream) => (sb: Stream) => Stream declare export function combineArray (f: (A, B) => Z, ss: [Stream, Stream]): Stream declare export function combineArray (f: (A, B) => Z): (ss: [Stream, Stream]) => Stream declare export function combineArray (f: (A, B, C) => Z, ss: [Stream, Stream, Stream]): Stream declare export function combineArray (f: (A, B, C) => Z): (ss: [Stream, Stream, Stream]) => Stream declare export function combineArray (f: (A, B, C, D) => Z, ss: [Stream, Stream, Stream, Stream]): Stream declare export function combineArray (f: (A, B, C, D) => Z): (ss: [Stream, Stream, Stream, Stream]) => Stream declare export function combineArray (f: (A, B, C, D, E) => Z, ss: [Stream, Stream, Stream, Stream, Stream]): Stream declare export function combineArray (f: (A, B, C, D, E) => Z): (ss: [Stream, Stream, Stream, Stream, Stream]) => Stream declare export function combineArray (f: (A, B, C, D, E, F) => Z, ss: [Stream, Stream, Stream, Stream, Stream, Stream]): Stream declare export function combineArray (f: (A, B, C, D, E, F) => Z): (ss: [Stream, Stream, Stream, Stream, Stream, Stream]) => Stream // Catch-all combineArray declare export function combineArray (f: (...rest: Array) => Z, ss: Array>): Stream declare export function combineArray (f: (...rest: Array) => Z): (ss: Array>) => Stream declare export function zip (f: (A, B) => Z, sa: Stream, sb: Stream): Stream declare export function zip (f: (A, B) => Z): (sa: Stream, sb: Stream) => Stream declare export function zip (f: (A, B) => Z, sa: Stream): (sb: Stream) => Stream declare export function zip (f: (A, B) => Z): (sa: Stream) => (sb: Stream) => Stream declare export function zipArray (f: (A, B) => Z, ss: [Stream, Stream]): Stream declare export function zipArray (f: (A, B) => Z): (ss: [Stream, Stream]) => Stream declare export function zipArray (f: (A, B, C) => Z, ss: [Stream, Stream, Stream]): Stream declare export function zipArray (f: (A, B, C) => Z): (ss: [Stream, Stream, Stream]) => Stream declare export function zipArray (f: (A, B, C, D) => Z, ss: [Stream, Stream, Stream, Stream]): Stream declare export function zipArray (f: (A, B, C, D) => Z): (ss: [Stream, Stream, Stream, Stream]) => Stream declare export function zipArray (f: (A, B, C, D, E) => Z, ss: [Stream, Stream, Stream, Stream, Stream]): Stream declare export function zipArray (f: (A, B, C, D, E) => Z): (ss: [Stream, Stream, Stream, Stream, Stream]) => Stream declare export function zipArray (f: (A, B, C, D, E, F) => Z, ss: [Stream, Stream, Stream, Stream, Stream, Stream]): Stream declare export function zipArray (f: (A, B, C, D, E, F) => Z): (ss: [Stream, Stream, Stream, Stream, Stream, Stream]) => Stream // Catch-all zipArray declare export function zipArray (f: (...rest: Array) => Z, ss: Array>): Stream declare export function zipArray (f: (...rest: Array) => Z): (ss: Array>) => Stream declare export function withItems (a: Array, s: Stream): Stream declare export function withItems (a: Array): (s: Stream) => Stream declare export function zipItems (f: (A, B) => C, a: Array, s: Stream): Stream declare export function zipItems (f: (A, B) => C): (a: Array, s: Stream) => Stream declare export function zipItems (f: (A, B) => C, a: Array): (s: Stream) => Stream declare export function zipItems (f: (A, B) => C): (a: Array) => (s: Stream) => Stream declare export function filter (p: (A) => boolean, s: Stream): Stream declare export function filter (p: (A) => boolean): (s: Stream) => Stream declare export function skipRepeats (s: Stream): Stream declare export function skipRepeatsWith (equals: (a1: A, a2: A) => boolean, s: Stream): Stream declare export function skipRepeatsWith (equals: (a1: A, a2: A) => boolean): (s: Stream) => Stream declare export function take (n: number, s: Stream): Stream declare export function take (n: number): (s: Stream) => Stream declare export function skip (n: number, s: Stream): Stream declare export function skip (n: number): (s: Stream) => Stream declare export function slice (start: number, end: number, s: Stream): Stream declare export function slice (start: number): (end: number, s: Stream) => Stream declare export function slice (start: number, end: number): (s: Stream) => Stream declare export function slice (start: number): (end: number) => (s: Stream) => Stream declare export function takeWhile (p: (A) => boolean, s: Stream): Stream declare export function takeWhile (p: (A) => boolean): (s: Stream) => Stream declare export function skipWhile (p: (A) => boolean, s: Stream): Stream declare export function skipWhile (p: (A) => boolean): (s: Stream) => Stream declare export function skipAfter (p: (A) => boolean, s: Stream): Stream declare export function skipAfter (p: (A) => boolean): (s: Stream) => Stream declare export function until (until: Stream, s: Stream): Stream declare export function until (until: Stream): (s: Stream) => Stream declare export function since (since: Stream, s: Stream): Stream declare export function since (since: Stream): (s: Stream) => Stream declare export function during (since: Stream>, s: Stream): Stream declare export function withLocalTime (origin: Time, s: Stream): Stream declare export function withLocalTime (origin: Time): (s: Stream) => Stream declare export function delay (delay: Delay, s: Stream): Stream declare export function delay (delay: Delay): (s: Stream) => Stream declare export function throttle (period: Period, s: Stream): Stream declare export function throttle (period: Period): (s: Stream) => Stream declare export function debounce (period: Period, s: Stream): Stream declare export function debounce (period: Period): (s: Stream) => Stream declare export function fromPromise (pa: Promise): Stream declare export function awaitPromises (spa: Stream>): Stream declare export function recoverWith (f: (E) => Stream, s: Stream): Stream declare export function recoverWith (f: (E) => Stream): (s: Stream) => Stream declare export function throwError (e: Error): Stream declare export function multicast (s: Stream): Stream declare export class MulticastSource { source: Stream; sinks: Array>; disposable: Disposable; constructor(Stream): MulticastSource; run(Sink, Scheduler): Disposable; event(Time, A): void; error(Time, Error): void; end(Time): void; add(Sink): number; remove(Sink): number; dispose(): void; } export type PropagateTask = Task & { value: A, sink: Sink, active: boolean } export type PropagateTaskRun = (time: Time, value: A, sink: Sink) => any declare export function propagateTask (run: PropagateTaskRun, value: A, sink: Sink): PropagateTask declare export function propagateEventTask (value: A, sink: Sink): PropagateTask declare export function propagateErrorTask (e: E, sink: Sink): PropagateTask declare export function propagateEndTask (sink: Sink): PropagateTask