MCPcopy
hub / github.com/webpack/webpack / splitToNChunks

Function splitToNChunks

test/test262.spectest.js:1145–1157  ·  view source on GitHub ↗

* @template T * @param {T[]} array an array * @param {number} n number of chunks * @returns {T[][]} splitted to n chunks

(array, n)

Source from the content-addressed store, hash-verified

1143 * @returns {T[][]} splitted to n chunks
1144 */
1145function 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
1159const shardedTestFiles = splitToNChunks([...testFiles], shard[1])[shard[0] - 1];
1160

Callers 1

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected