batcher
A simple batch wrapper for JS
Example
import { Batcher } from '@zcong/batcher'
const bs = new Batcher<string>(
1000,
10000,
(batch: string[]) => {
console.log(batch.length)
},
(str: string) => str.length
)
Array(100)
.fill('nasjxkajsnxkjanskxnksanxkjsnakxs')
.forEach(s => bs.dispatch(s))
setTimeout(() => bs.stop(), 9000)
// 31
// 31
// 31
// 7
License
MIT © zcong1993