Created
June 15, 2021 08:09
-
-
Save aidan-harding/5e590ba6b6d04e723603e0c98ac7a2a4 to your computer and use it in GitHub Desktop.
A sleep sort, as per https://kevlinhenney.medium.com/need-something-sorted-sleep-on-it-11fdf8453914
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
function sleeper(value) { | |
return new Promise(resolve => setTimeout(() => resolve(value), value * 100)); | |
} | |
[5, 4, 3, 6, 1].forEach((value) => sleeper(value).then((value) => console.log(value))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment