A collection of RxJS utilities.
Filter an array in an Observable.
of([1, 2, 3, 4])
.pipe(mapArrayFilter(x => x % 2 === 0))
.subscribe(console.log);
// [ 2, 4 ]
Map an array in an Observable.
of([1, 2, 3, 4])
.pipe(mapArrayMap(x => x * 2))
.subscribe(console.log);
// [ 2, 4, 6, 8 ]
Reduce an array in an Observable.
of([1, 2, 3, 4])
.pipe(mapArrayReduce((acc, cur) => acc + cur, 0))
.subscribe(console.log);
// 10
Reduce an array in an Observable, right to left.
of(['a', 'b', 'c', 'd'])
.pipe(mapArrayReduceRight((acc, cur) => acc + cur, ''))
.subscribe(console.log);
// 'dcba'
Reverses an array in an Observable.
of([1, 2, 3, 4, 5])
.pipe(mapArrayReverse())
.subscribe(console.log);
// [5, 4, 3, 2, 1]
Sorts an array in an Observable.
of([3, 1, 5, 2, 4])
.pipe(mapArraySort())
.subscribe(console.log);
// [1, 2, 3, 4, 5]
of([3, 1, 5, 2, 4])
.pipe(mapArraySort((a, b) => a > b ? -1 : 1))
.subscribe(console.log);
// [5, 4, 3, 2, 1]