1.0.8 • Published 7 years ago

simple-async-queue v1.0.8

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

simple-async-queue

A simple queue utility for running async tasks one at a time

// 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()
1.0.8

7 years ago

1.0.7

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago