The ECMAScript language types are:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import assert from 'node:assert'; | |
/** | |
* Executes a provided function a specific number of times | |
* @param {Function} fn A function to execute | |
* @param {number} times How many times the function should be executed | |
*/ | |
function executeTimes(fn, times) { | |
if (times < 1 || typeof fn !== 'function') { | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useEffect(() => { | |
const controller = new AbortController(); | |
window.addEventListener('event1', callback1, { signal: controller.signal }); | |
window.addEventListener('event2', callback2, { signal: controller.signal }); | |
return () => { controller.abort(); }; | |
}, []); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const RAND_MAX = 0xffff; // 65535 | |
const next = new Uint32Array([0]); | |
export function srand(seed) { | |
next[0] = seed; | |
} | |
export function rand() { | |
next[0] = next[0] * 1103515245 + 12345; |