* Chunks the given array into slices of equal length. * @param {array} array Array to chunk * @param {number} length Length of one chunk * @return {array} Array of slices
(array, length)
| 117 | * @return {array} Array of slices |
| 118 | */ |
| 119 | static chunk (array, length) { |
| 120 | const count = Math.ceil(array.length / length) |
| 121 | const chunks = new Array(count) |
| 122 | for (let i = 0; i < count; i++) { |
| 123 | chunks[i] = array.slice(i * length, (i + 1) * length) |
| 124 | } |
| 125 | return chunks |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Joins the elements of the given array slices to an array, separated by |
no outgoing calls
no test coverage detected