-
Notifications
You must be signed in to change notification settings - Fork 1
intersperse
Subhajit Sahu edited this page May 10, 2020
·
14 revisions
Places values of an iterable between another.
iterable.interleave(x, y, [m], [n]);
// x: an iterable
// y: another iterable
// m: number of values from x (1)
// n: number of values from y (1)
const iterable = require('extra-iterable');
var x = [1, 2, 3];
[...iterable.intersperse(x, 10)];
// [ 1, 10, 2, 10, 3 ]
var x = [1, 2, 3, 4];
[...iterable.intersperse(x, 10)];
// [ 1, 10, 2, 10, 3, 10, 4 ]