function batch<TValue>(fn, options): (item) => void
function batch<TValue>(fn, options): (item) => void
定义于:batcher.ts:247
创建一个分批处理项目的批处理器
• TValue
(items) => void
BatcherOptions<TValue>
Function
将项目添加到批处理器 如果达到批处理大小、发生超时或 shouldProcess 返回 true,则将处理该批处理
TValue
void
const batchItems = batch<number>({
batchSize: 3,
processBatch: (items) => console.log('正在处理:', items)
});
batchItems(1);
batchItems(2);
batchItems(3); // 触发批处理
const batchItems = batch<number>({
batchSize: 3,
processBatch: (items) => console.log('正在处理:', items)
});
batchItems(1);
batchItems(2);
batchItems(3); // 触发批处理