Created
May 12, 2017 18:13
-
-
Save electerious/37dbf2bf4faf69b0396068b32d23e6eb to your computer and use it in GitHub Desktop.
Execute an array of functions with a delay between each execution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const queue = (query, delay, next) => { | |
if (query.length===0) return next() | |
query[0]() | |
const trimmed = query.slice(1) | |
setTimeout(() => exec(trimmed, delay, next), delay) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: