Last active
November 23, 2018 16:10
-
-
Save kitze/6291dab229c909aefabb5b3141000f37 to your computer and use it in GitHub Desktop.
Solution
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
/* | |
* If the loop bumps into an function, it returns true, and moves on, | |
* but if it bumps into a number, it waits x milliseconds, | |
* it stops the _.every loop by returning false, and recursively | |
* calls the sequence function with the rest of the array. | |
* Nifty, huh? ๐๐ | |
*/ | |
const sequence = b => b.every((a, i) => !(a.call ? a() : setTimeout(() => sequence(b.slice(++i)), a))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment