Replace the Vue frontend with Svelte

This commit is contained in:
Keavon Chambers
2023-03-10 03:54:39 -08:00
parent e539e43483
commit 6e20ea538b
83 changed files with 10013 additions and 19687 deletions
@@ -0,0 +1,31 @@
export type Debouncer = ReturnType<typeof debouncer>;
export type DebouncerOptions = {
debounceTime: number;
};
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export function debouncer<T>(callFn: (value: T) => unknown, { debounceTime = 60 }: Partial<DebouncerOptions> = {}) {
let currentValue: T | undefined;
const emitValue = (): void => {
if (currentValue === undefined) {
throw new Error("Tried to emit undefined value from debouncer. This should never be possible");
}
const emittingValue = currentValue;
currentValue = undefined;
callFn(emittingValue);
};
const updateValue = (newValue: T): void => {
if (currentValue !== undefined) {
currentValue = newValue;
return;
}
currentValue = newValue;
setTimeout(emitValue, debounceTime);
};
return { updateValue };
}