1const Wonka = require('..');
2const Wonka4 = require('wonka-v4');
3const Rx = require('rxjs');
4const RxOperators = require('rxjs/operators');
5const most = require('most');
6
7const input = [1, 2, 3, 4, 5, 6, 7, 8, 9];
8
9suite('Promisified map, filter, scan, last', () => {
10 benchmark('Wonka', () => {
11 return Wonka.pipe(
12 Wonka.fromArray(input),
13 Wonka.map(x => x * 2),
14 Wonka.filter(x => x > 4),
15 Wonka.scan((acc, x) => acc + x, 0),
16 Wonka.toPromise
17 );
18 });
19
20 benchmark('Wonka v4', () => {
21 return Wonka4.pipe(
22 Wonka4.fromArray(input),
23 Wonka4.map(x => x * 2),
24 Wonka4.filter(x => x > 4),
25 Wonka4.scan((acc, x) => acc + x, 0),
26 Wonka4.toPromise
27 );
28 });
29
30 benchmark('RxJS', () => {
31 return Rx.from(input).pipe(
32 RxOperators.map(x => x * 2),
33 RxOperators.filter(x => x > 4),
34 RxOperators.scan((acc, x) => acc + x, 0)
35 ).toPromise();
36 });
37
38 benchmark('most', () => {
39 return most.from(input)
40 .map(x => x * 2)
41 .filter(x => x > 4)
42 .scan((acc, x) => acc + x, 0)
43 .thru(s => s.reduce((_, x) => x))
44 });
45});