MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / chunk

Function chunk

lib/web/jshint.js:6021–6036  ·  view source on GitHub ↗

* Creates an array of elements split into groups the length of `size`. * If `collection` can't be split evenly, the final chunk will be the remaining * elements. * * @static * @memberOf _ * @category Array * @param {Array} array The array to process. * @param

(array, size, guard)

Source from the content-addressed store, hash-verified

6019 * // => [['a', 'b', 'c'], ['d']]
6020 */
6021 function chunk(array, size, guard) {
6022 if (guard ? isIterateeCall(array, size, guard) : size == null) {
6023 size = 1;
6024 } else {
6025 size = nativeMax(+size || 1, 1);
6026 }
6027 var index = 0,
6028 length = array ? array.length : 0,
6029 resIndex = -1,
6030 result = Array(ceil(length / size));
6031
6032 while (index < length) {
6033 result[++resIndex] = baseSlice(array, index, (index += size));
6034 }
6035 return result;
6036 }
6037
6038 /**
6039 * Creates an array with all falsey values removed. The values `false`, `null`,

Callers

nothing calls this directly

Calls 2

isIterateeCallFunction · 0.85
baseSliceFunction · 0.85

Tested by

no test coverage detected