* @template T * @param {T[]} array an array * @param {number} n number of chunks * @returns {T[][]} splitted to n chunks
(array, n)
| 1143 | * @returns {T[][]} splitted to n chunks |
| 1144 | */ |
| 1145 | function splitToNChunks(array, n) { |
| 1146 | /** @type {T[][]} */ |
| 1147 | const result = []; |
| 1148 | |
| 1149 | for (let i = n; i > 0; i--) { |
| 1150 | result.push( |
| 1151 | /** @type {T[]} */ |
| 1152 | (array.splice(0, Math.ceil(array.length / i))) |
| 1153 | ); |
| 1154 | } |
| 1155 | |
| 1156 | return result; |
| 1157 | } |
| 1158 | |
| 1159 | const shardedTestFiles = splitToNChunks([...testFiles], shard[1])[shard[0] - 1]; |
| 1160 |