-
Notifications
You must be signed in to change notification settings - Fork 1
intersperse
Subhajit Sahu edited this page May 11, 2020
·
14 revisions
Places a separator between every value. 🏃 📼 📦 🌔 📒
Similar: interleave, intersperse.
iterable.intersperse(x, v);
// x: an iterable
// v: separator
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 ]