-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
47 lines (35 loc) · 998 Bytes
/
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
import {Mote, map, filter, reduce, merge, take, combine, interval, delay, throttleTime} from './mote'
const m1 = new Mote<number>()
const m2 = map<number, number>(m1, x => 2*x)
const m3 = map<number, number>(m2, x => x +1)
const isEven = x => x % 2 === 0
const isOdd = x => x % 2 === 1
const m4 = filter<number>(m3, isEven)
const m5 = filter<number>(m3, isOdd)
const m6 = reduce(m1, (acc, v) => acc + v, 0)
m1.push(5)
m1.push(6)
const m7 = new Mote<number>()
const m8 = new Mote<number>()
const m9 = merge([m7, m8, m3])
m7.push(1)
m8.push(2)
m7.push(3)
m1.push(7)
const m10 = new Mote<number>()
const m11 = take(m10, 3)
m10.push(101);
m10.push(102);
m10.push(103);
m10.push(104);
m10.push(105);
const m12 = new Mote<number>()
m12.push(3)
const m13 = new Mote<number>()
m13.push(4)
const m14 = combine([m12, m13], (a, b) => a + b)
m12.push(4)
const m15 = interval(1000, 5)
const m16 = reduce(m15, (acc, v) => acc + v, 0)
const m17 = delay(m15, 900)
const m18 = throttleTime(m15, 2000)