Brak opisu

chunk.js 387B

123456789101112131415
  1. var _setup = require('./_setup.js');
  2. // Chunk a single array into multiple arrays, each containing `count` or fewer
  3. // items.
  4. function chunk(array, count) {
  5. if (count == null || count < 1) return [];
  6. var result = [];
  7. var i = 0, length = array.length;
  8. while (i < length) {
  9. result.push(_setup.slice.call(array, i, i += count));
  10. }
  11. return result;
  12. }
  13. module.exports = chunk;