const sleepBuffer = new SharedArrayBuffer ( 4 ) ; const sleepArray = new Int32Array ( sleepBuffer ) ; param ms export function sleep ( ms ) { if ( typeof ms !== "number" ) throw new TypeError ( "Number expected: ms" ) ; if ( ! isFinite ( ms ) || ms < 0 ) throw new RangeError ( "Out of range: ms" ) ; Atomics . wait ( sleepArray , 0 , 0 , ms ) ; }