I would like to merge two maps of the same source guaranteeing the order of the result. Here is a unit test that I would like to pass:
const source = xs.of(1,2,3)
const a = source.map(v=>v*10)
const b = source.map(v=>v*100)
const hist:number[] = []
xs.merge(a,b).addListener({
next: v=>hist.push(v),
})
expect(hist).toEqual([10,100,20,200,30,300])
Currently the result I'm getting is this:
Expected value to equal:
[10, 100, 20, 200, 30, 300]
Received:
[10, 20, 30, 100, 200, 300]
Taking a clue from user3743222's answer, using
periodic
to sequence the list.Changing:
...produces in the console:
ESNextbin demo.
drop(1)
is one way to deal withperiodic
starting with0
. One can alternatively use++v*10
in themap
function.