mirror of
https://gitlab.com/80486DX2-66/gists
synced 2025-05-31 08:31:41 +05:30
16 lines
378 B
JavaScript
16 lines
378 B
JavaScript
/*
|
|
* busy-loop-delay.js
|
|
*
|
|
* Author: Intel A80486DX2-66
|
|
* License: Creative Commons Zero 1.0 Universal or Unlicense
|
|
* SPDX-License-Identifier: CC0-1.0 OR Unlicense
|
|
*/
|
|
|
|
let measureEpoch = () => Number(new Date())
|
|
|
|
function busyLoopDelay(ms) {
|
|
let currentTime = measureEpoch(), nextTime = currentTime + ms
|
|
if (nextTime > currentTime)
|
|
while (measureEpoch() < nextTime);
|
|
}
|