Last active
May 11, 2023 12:12
-
-
Save luislobo14rap/c767b3371802828ed8a2538877e07d6a to your computer and use it in GitHub Desktop.
setTimesout.js
This file contains 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
// setTimesout.js v2 | |
function setTimesout(function_ = (time, index) => {}, repeats = [0]) { | |
repeats = repeats.sort((a, b) => { | |
return a - b | |
}) | |
for (let i = 0; i < repeats.length; i++) { | |
setTimeout(() => { | |
function_(time = repeats[i], index = i) | |
}, repeats[i]) | |
} | |
} |
This file contains 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
// setTimesout.min.js v2 | |
function setTimesout(a=function(){},b=[0]){b=b.sort(function(c,a){return c-a});for(let c=0;c<b.length;c++)setTimeout(function(){a(time=b[c],index=c)},b[c])} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment