wip improvements but still problematic
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
export const isNumeric = (num: string | number) =>
|
||||
(typeof num === 'number' || (typeof num === 'string' && num.trim() !== '')) &&
|
||||
!isNaN(num as number);
|
||||
|
||||
export const pad = (n: string | number) => {
|
||||
if (n === null || n === undefined) {
|
||||
return '';
|
||||
}
|
||||
return ('0' + n).slice(-2);
|
||||
};
|
||||
|
||||
export function debounce<F extends (...args: unknown[]) => unknown>(
|
||||
func: F,
|
||||
timeout = 100
|
||||
): (this: ThisParameterType<F>, ...args: Parameters<F>) => void {
|
||||
let timer: ReturnType<typeof setTimeout>;
|
||||
return function (this: ThisParameterType<F>, ...args: Parameters<F>) {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => {
|
||||
func.apply(this, args);
|
||||
}, timeout);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user