-
Notifications
You must be signed in to change notification settings - Fork 1
cutAt
Subhajit Sahu edited this page Feb 3, 2021
·
9 revisions
Breaks iterable at given indices. 🏃 📼 📦 🌔 📒
Alternatives: cut, cutRight, cutAt, cutAtRight.
Similar: cut, split, group.
iterable.cutAt(x, is);
// x: an iterable
// is: split indices (sorted)
const iterable = require("extra-iterable");
var x = [1, 2, 3, 4, 5];
[...iterable.cutAt(x, [1, 3])];
// [ [ 1 ], [ 2, 3 ], [ 4, 5 ] ]
[...iterable.cutAt(x, [0, 4])];
// [ [], [ 1, 2, 3, 4 ], [ 5 ] ]