22 lines
425 B
TypeScript
22 lines
425 B
TypeScript
|
export function safeRun(fn: () => Promise<void>) {
|
||
|
fn().catch((e) => {
|
||
|
console.error(e);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
export function isMacLike() {
|
||
|
return /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
|
||
|
}
|
||
|
|
||
|
export function throttle(func: () => void, limit: number) {
|
||
|
let timer: any = null;
|
||
|
return function () {
|
||
|
if (!timer) {
|
||
|
timer = setTimeout(() => {
|
||
|
func();
|
||
|
timer = null;
|
||
|
}, limit);
|
||
|
}
|
||
|
};
|
||
|
}
|