Initial commit with translated description

This commit is contained in:
2026-03-29 08:34:04 +08:00
commit 80ef0a90d7
24 changed files with 4556 additions and 0 deletions

15
utils/sleep.js Normal file
View File

@@ -0,0 +1,15 @@
function sleepSync(ms) {
if (ms <= 0) return;
try {
const sab = new SharedArrayBuffer(4);
const int32 = new Int32Array(sab);
Atomics.wait(int32, 0, 0, ms);
} catch (e) {
// Fallback for environments without SharedArrayBuffer (rare in Node 22)
const end = Date.now() + ms;
while (Date.now() < end) {}
}
}
module.exports = { sleepSync };