Restructure project as Worldshaper

This commit is contained in:
Andraxion 2026-06-26 20:30:30 -04:00
parent ab891a315c
commit b4dbd4ee8e
583 changed files with 279 additions and 189269 deletions

View file

@ -1,47 +0,0 @@
export function createDebouncedCallback<T extends unknown[]>(
callback: (...args: T) => void,
delayMs = 120,
) {
let timerId = 0;
let lastArgs: T | null = null;
const run = () => {
timerId = 0;
if (!lastArgs) {
return;
}
const args = lastArgs;
lastArgs = null;
callback(...args);
};
const debounced = (...args: T) => {
lastArgs = args;
if (timerId) {
window.clearTimeout(timerId);
}
timerId = window.setTimeout(run, Math.max(0, Number(delayMs) || 0));
};
debounced.flush = () => {
if (timerId) {
window.clearTimeout(timerId);
run();
return true;
}
return false;
};
debounced.cancel = () => {
if (!timerId) {
lastArgs = null;
return false;
}
window.clearTimeout(timerId);
timerId = 0;
lastArgs = null;
return true;
};
return debounced;
}