knack
v0.0.3
Published
Transparent async queue manager
Downloads
711
Maintainers
Readme
knack
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