import { Observable , of , interval } from 'rxjs' ; import { filter , map , reduce , scan , take } from 'rxjs/operators' ; param toTake const takeMaybe = ( toTake ? ) => < T > ( o ) => toTake ? o . pipe ( take ( toTake ) ) : o ; param toTake export const oddDoublerOp = ( toTake = 10 ) => ( o ) => o . pipe ( takeMaybe ( toTake ) , filter ( i => i % 2 === 1 ) , map ( i => i * 2 ) , reduce ( ( acc , curr ) => acc + curr , 0 ) ) ; export function play ( ... args ) { const ticker$ = interval ( 50 ) ; /**
     * To double the odd integers emitted by interval and sum them ...
     * pipe with RxJS array-like operators
     */ const result$ = ticker$ . pipe ( oddDoublerOp ( 10 ) ) ; return result$ ; }