Add .gitignore to exclude all node packages and lock files

This commit is contained in:
Adolfo Reyna
2026-02-23 21:56:04 -05:00
parent faae96c9ed
commit dcc5c6c044
9747 changed files with 1555105 additions and 2 deletions
@@ -0,0 +1,43 @@
const DEFAULT_THROTTLE_MS = 250;
/**
* Creates a throttled version of a progress callback that ensures it's not called
* more frequently than the specified interval (default: 250ms)
*/
export const createThrottledProgressCallback = (callback, throttleMs = DEFAULT_THROTTLE_MS) => {
if (!callback) {
return null;
}
let lastCallTime = 0;
let pendingUpdate = null;
let timeoutId = null;
const throttled = (progress) => {
const now = Date.now();
const timeSinceLastCall = now - lastCallTime;
// Always store the latest progress
pendingUpdate = progress;
// If enough time has passed, call immediately
if (timeSinceLastCall >= throttleMs) {
lastCallTime = now;
callback(progress);
pendingUpdate = null;
// Clear any pending timeout
if (timeoutId !== null) {
clearTimeout(timeoutId);
timeoutId = null;
}
}
else if (timeoutId === null) {
// Schedule a call for when the throttle period expires
const remainingTime = throttleMs - timeSinceLastCall;
timeoutId = setTimeout(() => {
if (pendingUpdate !== null) {
lastCallTime = Date.now();
callback(pendingUpdate);
pendingUpdate = null;
}
timeoutId = null;
}, remainingTime);
}
};
return throttled;
};