mirror of
https://gitlab.com/80486DX2-66/gists
synced 2024-11-09 21:32:02 +05:30
15 lines
316 B
JavaScript
15 lines
316 B
JavaScript
/*
|
|
* busy-loop-delay.js
|
|
*
|
|
* Author: Intel A80486DX2-66
|
|
* License: Creative Commons Zero 1.0 Universal
|
|
*/
|
|
|
|
let measureEpoch = () => Number(new Date())
|
|
|
|
function busyLoopDelay(ms) {
|
|
let currentTime = measureEpoch(), nextTime = currentTime + ms
|
|
if (nextTime > currentTime)
|
|
while (measureEpoch() < nextTime);
|
|
}
|