-
Notifications
You must be signed in to change notification settings - Fork 1
chunk
Subhajit Sahu edited this page May 17, 2020
·
24 revisions
Breaks iterable into chunks of given size. 🏃 📼 📦 🌔 📒
iterable.chunk(x, [s], [n]);
// x: an iterable
// s: chunk step (1)
// n: chunk size (s)
const iterable = require('extra-iterable');
var x = [1, 2, 3, 4, 5, 6, 7, 8];
[...iterable.chunk(x, 3)];
// [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8 ] ]
[...iterable.chunk(x, 3, 2)];
// [ [ 1, 2 ], [ 4, 5 ], [ 7, 8 ] ]
[...iterable.chunk(x, 3, 4)];
// [ [ 1, 2, 3, 4 ], [ 4, 5, 6, 7 ], [ 7, 8 ] ]