JSPM

@extra-array/chunk

2.9.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 135
  • Score
    100M100P100Q74657F
  • License MIT

Breaks array into chunks of given size.

Package Exports

  • @extra-array/chunk

Readme

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

This is part of package extra-array.

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

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

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

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

references