performChunk()
function performChunk<T>(array, consumer): void;
Defined in: @browser/perform-chunk.ts:14
分片执行任务 只能在浏览器环境中执行 把一个大任务分片执行,每次执行一小部分任务,然后让出主线程,等待下一次执行
Type Parameters
| Type Parameter | Description |
|---|---|
T | 数组元素类型 |
Parameters
| Parameter | Type | Description |
|---|---|---|
array | T[] | 要执行的数据组 |
consumer | (data, index) => void | 消费者函数 |
Returns
void
Example
performChunk([1, 2, 3, 4, 5], (item, index) => {
console.log(`Processing item ${item} at index ${index}`);
});