* Creates an array of elements split into groups the length of `size`. * If `array` can't be split evenly, the final chunk will be the remaining * elements. * * @static * @memberOf _ * @since 3.0.0 * @category Array * @param {Array} array The array to process.
(array, size, guard)
| 6932 | * // => [['a', 'b', 'c'], ['d']] |
| 6933 | */ |
| 6934 | function chunk(array, size, guard) { |
| 6935 | if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { |
| 6936 | size = 1; |
| 6937 | } else { |
| 6938 | size = nativeMax(toInteger(size), 0); |
| 6939 | } |
| 6940 | var length = array == null ? 0 : array.length; |
| 6941 | if (!length || size < 1) { |
| 6942 | return []; |
| 6943 | } |
| 6944 | var index = 0, |
| 6945 | resIndex = 0, |
| 6946 | result = Array(nativeCeil(length / size)); |
| 6947 | |
| 6948 | while (index < length) { |
| 6949 | result[resIndex++] = baseSlice(array, index, (index += size)); |
| 6950 | } |
| 6951 | return result; |
| 6952 | } |
| 6953 | |
| 6954 | /** |
| 6955 | * Creates an array with all falsey values removed. The values `false`, `null`, |
nothing calls this directly
no test coverage detected