knack

0.0.3 • Public • Published

knack

NPM version Unix Build Status Windows Build Status Coveralls Status Dependency Status

Knack transparently manages the execution of the asynchronous functions as a queue with a predetermined width

Knack simply wraps any promise-returning function and returns function, executed in a queue

Install

npm install --save knack

Usage

import Knack from 'knack'
 
function asyncFunc(param) {
  return Promise.resolve(param)
}
 
// All fields are optional
const knack = Knack({
  concurrency: 10,
  interval: 100,
  onDone: () => console.log('all tasks are done')
})
 
// Make wrapped function
const asyncQueued = knack(asyncFunc)
asyncQueued('ok')
// => Promise<'ok'>
 
// Or just make queue task executor
const task = knack.once()
task(asyncFunc, 'ok')
// => Promise<'ok'>

License

MIT © Zero Bias

Package Sidebar

Install

npm i knack

Weekly Downloads

30

Version

0.0.3

License

MIT

Last publish

Collaborators

  • drelliot