Skip to content
wolfram77 edited this page Mar 27, 2020 · 24 revisions

Splits iterable into chunks of given size.

iterable.chunk(x, [n]);
// x: an iterable
// n: chunk size (1)
// --> chunks
const iterable = require('extra-iterable');

var x = [1, 2, 3, 4, 5];
iterable.chunk(x, 2);
// [ [ 1, 2 ], [ 3, 4 ], [ 5 ] ]

iterable.chunk(x, 3);
// [ [ 1, 2, 3 ], [ 4, 5 ] ]

references

Clone this wiki locally