npm.io
0.1.0 • Published 7 years ago

@zcong/batcher

Licence
MIT
Version
0.1.0
Deps
0
Size
8 kB
Vulns
0
Weekly
0

batcher

NPM version NPM downloads CircleCI codecov

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