1.0.0 • Published 4 years ago

debounce-and-batch v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

debounce-and-batch

debounce and batch-process events

Usage

const debounceAndBatch = require('debounce-and-batch')

// say you want to batch process throwing away the trash
const emptyTrash = debounceAndBatch({
  name: 'trash batch-processor',
  interval: 1000,
  concurrency,
  onBatch: async (items) => {
    console.log(`emptying ${items.length} from trash`)
  },
})

eventEmitter.on('trash', emptyTrash)