Created
June 6, 2023 07:16
-
-
Save KoljaL/bbb8b4cfb55df686757c91e3f13101c9 to your computer and use it in GitHub Desktop.
Collected functions for util.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
// return *positive* remainder of n divided by m. | |
export function mod(n, m) { | |
return ((n % m) + m) % m; | |
} | |
export function sleep(time) { | |
return new Promise((res) => setTimeout(res, time)); | |
} | |
function randInt(a, b) { | |
return a + Math.floor((b - a) * Math.random()); | |
} | |
export function randEl(list) { | |
return list[randInt(0, list.length)]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment