An xstream operator that groups consecutive events into N-tuples
function tuplewise<N extends number, T>(n: N): ($: Stream<T>) => Stream<T[] & { length: N }>;
Note that xstream
is a peer dependencies of this library, which need to be installed separately.
Using npm
$ npm install xstream-tuplewise
Using yarn
$ yarn add xstream-tuplewise
---0---1-------2-------3-----------4--------|
tuplewise(0)
[]-[]--[]------[]------[]----------[]-------|
---0---1-------2-------3-----------4--------|
tuplewise(1)
---[0]-[1]-----[2]-----[3]---------[4]------|
---0---1-------2-------3-----------4--------|
tuplewise(2)
-------[0,1]---[1,2]---[2,3]-------[3,4]----|
---0---1-------2-------3-----------4--------|
tuplewise(3)
---------------[0,1,2]-[1,2,3]-----[2,3,4]--|
MIT