Mirror: 馃帺 A tiny but capable push & pull stream library for TypeScript and Flow
1const Wonka = require('..'); 2const Rx = require('rxjs'); 3const RxOperators = require('rxjs/operators'); 4const most = require('most'); 5 6const input = [1, 2, 3, 4, 5, 6, 7, 8, 9]; 7 8suite('Promisified map, filter, scan, last', () => { 9 benchmark('Wonka', () => { 10 return Wonka.pipe( 11 Wonka.fromArray(input), 12 Wonka.map(x => x * 2), 13 Wonka.filter(x => x > 4), 14 Wonka.scan((acc, x) => acc + x, 0), 15 Wonka.toPromise 16 ); 17 }); 18 19 benchmark('RxJS', () => { 20 return Rx.from(input).pipe( 21 RxOperators.map(x => x * 2), 22 RxOperators.filter(x => x > 4), 23 RxOperators.scan((acc, x) => acc + x, 0) 24 ).toPromise(); 25 }); 26 27 benchmark('most', () => { 28 return most.from(input) 29 .map(x => x * 2) 30 .filter(x => x > 4) 31 .scan((acc, x) => acc + x, 0) 32 .thru(s => s.reduce((_, x) => x)) 33 }); 34});