callbag-interleave
v1.0.0
Published
👜Emits the interleaved values of the given iterables
Downloads
2
Readme
callbag-interleave
👜 Callbag source that emits the interleaved values of the given iterables.
npm install callbag-interleave
Examples
Iterables have the same number of items
const interleave = require('callbag-interleave');
const forEach = require('callbag-for-each');
const map = require('callbag-map');
const pipe = require('callbag-pipe');
pipe(
interleave('abc', [1, 2, 3]),
map(([k, v]) => ({ [k]: v })),
forEach((x) => {
console.log(x); // { a: 1 }
// { b: 2 }
}) // { c: 3 } and completes
);
Iterables have a differente number of items
const interleave = require('callbag-interleave');
const forEach = require('callbag-for-each');
const map = require('callbag-map');
const pipe = require('callbag-pipe');
pipe(
interleave('ab', [1, 2, 3]),
map(([k, v]) => ({ [k]: v })),
forEach((x) => {
console.log(x); // { a: 1 }
// { b: 2 } and completes
})
);