1
0
mirror of https://gitlab.com/80486DX2-66/gists synced 2024-11-08 18:02:23 +05:30
gists/js-programming/busy-loop-delay.js

15 lines
316 B
JavaScript
Raw Permalink Normal View History

2024-02-01 02:16:48 +05:30
/*
* 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);
}