Skip to content
wolfram77 edited this page Apr 13, 2020 · 22 revisions

Breaks array into chunks of given size. 🏃 📼 📦 🌔

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

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

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

references

Clone this wiki locally