UNPKG

@extra-array/split-at

Version:

Breaks iterable considering indices as separator.

17 lines (16 loc) 316 B
'use strict'; function splitAt(x, is) { var a = [], b = [], i = -1; for (var v of x) { if (!is.includes(++i)) b.push(v); else if (b.length) { a.push(b); b = []; } } if (b.length) a.push(b); return a; } module.exports = splitAt;