small-queue
v1.1.2
Published
Tool Library
Downloads
390
Readme
Simple queue manipulation tool.
Demo
import { Queue } from 'small-queue';
const q = new Queue();
q.add((next) => {
console.log(1);
setTimeout(() => {
next();
})
})
q.add((next) => {
console.log(2);
})
// Wait for the current queue to finish executing
q.awaitFinish().then(() => {
console.log(4);
// Restart
q.add((next) => {
console.log(1);
next();
})
})
CDN
<!DOCTYPE html>
<html lang="en">
<body>
<script src="https://unpkg.com/small-queue/dist/queue.umd.js"></script>
<script>
const { Queue } = window.SQ;
const q = new Queue();
// ...
</script>
</body>
</html>