Thunk queue for uncertainty tasks evaluation.
const thunkQueue = require('thunk-queue')
const queueT = thunkQueue()
queueT(function(err, res) {
// It is will be run after all thunkable task finished in queue.
console.log(err, res)
})
queueT.push(1) // push a primitive value to queue
queueT.push(Promise.resolve(1)) // push a promise to queue
// queueT.push(...), support all thunkable value, such as primitive value, thunk function, promise, generator object, generator function...
queueT.end() // end the queue.
npm install thunk-queue
const thunkQueue = require('thunk-queue')
Return a thunk function with a closure queue.
const queueT = thunkQueue()
Push thunkable task to the thunk
's queue, thunkable task will be eager evaluated, return the queueT
;
End the thunk
's queue. the thunk
will be evaluated after all tasks finished in queue. return the queueT
;