// Require simple-async-queue
const SimpleAsyncQueue = require("simple-async-queue")
// Create a new instance
// This queue will have a callback that is called for each item, and a done function for when all items has been processed.
const queue = new SimpleAsyncQueue({
callback: (item, next) => {
console.log(item)
// Call the second parameter next when you are done with the current item to continue with the next.
window.setTimeout(() => next(), 500)
},
done: () => console.log("Done!")
})
// Add items to the queue either one by one or pass in an array.
queue.add("foo")
queue.add("bar")
queue.add(["foo2", "bar2"])
// Start to process queue
queue.run()
simple-async-queue
1.0.8 • Public • PublishedPackage Sidebar
Install
npm i simple-async-queue
Weekly Downloads
1
Version
1.0.8
License
MIT