* 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 {Ar
(array, size, guard)
| 17464 | * // => [['a', 'b', 'c'], ['d']] |
| 17465 | */ |
| 17466 | function chunk(array, size, guard) { |
| 17467 | if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { |
| 17468 | size = 1; |
| 17469 | } else { |
| 17470 | size = nativeMax(toInteger(size), 0); |
| 17471 | } |
| 17472 | var length = array == null ? 0 : array.length; |
| 17473 | if (!length || size < 1) { |
| 17474 | return []; |
| 17475 | } |
| 17476 | var index = 0, |
| 17477 | resIndex = 0, |
| 17478 | result = Array(nativeCeil(length / size)); |
| 17479 | |
| 17480 | while (index < length) { |
| 17481 | result[resIndex++] = baseSlice(array, index, (index += size)); |
| 17482 | } |
| 17483 | return result; |
| 17484 | } |
| 17485 | |
| 17486 | /** |
| 17487 | * Creates an array with all falsey values removed. The values `false`, `null`, |
nothing calls this directly
no test coverage detected