-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathindex.ts
74 lines (70 loc) · 1.85 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { _, $ } from '../fantasy/typeclasses'
import { FunctorInstances } from '../fantasy/typeclasses/functor'
export interface S_<A> { }
export type Stream = keyof S_<any>
export interface FantasySubject<A> {
next<A>(a: A): void
complete<A>(a?: A): void
}
export interface Subscription {
unsubscribe(): void;
}
export type Subject<F extends Stream, A> = $<F, A> & FantasySubject<A>
export type $<F extends Stream, A> = $<F, A>
export class StreamOps<F extends Stream> { }
export interface StreamOps<F extends Stream> {
empty<A>(): $<F, A>
fromPromise<A>(p: Promise<A>): $<F, A>
from<G extends FunctorInstances, A>(fa: $<G, A>): $<F, A>
just<A>(a: A): $<F, A>
merge<A, B>(
a: $<F, A>,
b: $<F, B>
): $<F, A | B>
scan<A, B>(
f: (acc: B, cur: A) => B,
base: B,
fa: $<F, A>
): $<F, B>
map<A, B>(f: (a: A) => B, fa: $<F, A>): $<F, B>
filter<A>(f: (a: A) => boolean, fa: $<F, A>): $<F, A>
flatMap<A, B>(f: (a: A) => $<F, B>, fa: $<F, A>): $<F, B>
subject<A>(): Subject<F, A>
combine<A, B, C>(
f: (a: A, b: B) => C,
fa: $<F, A>,
fb: $<F, B>
): $<F, C>
combine<A, B, C, D>(
f: (a: A, b: B, c: C) => D,
fa: $<F, A>,
fb: $<F, B>,
fc: $<F, C>
): $<F, D>
combine<A, B, C, D, E>(
f: (a: A, b: B, c: C, d: D) => E,
fa: $<F, A>,
fb: $<F, B>,
fc: $<F, C>,
fd: $<F, D>
): $<F, E>
combine<A, B, C, D, E, G>(
f: (a: A, b: B, c: C, d: D, e: E) => G,
fa: $<F, A>,
fb: $<F, B>,
fc: $<F, C>,
fd: $<F, D>,
fe: $<F, E>
): $<F, G>
combine<A, B, C, D, E, G, H>(
f: (a: A, b: B, c: C, d: D, e: E, g: G) => H,
fa: $<F, A>,
fb: $<F, B>,
fc: $<F, C>,
fd: $<F, D>,
fe: $<F, E>,
fg: $<F, G>
): $<F, H>
subscribe<A>(fa: $<F, A>, next: (v: A) => void, complete?: () => void): Subscription
}
export const streamOps: StreamOps<Stream> = new StreamOps