Garbage collect segments.
This commit is contained in:
@@ -94,4 +94,20 @@ export const isHoverableDevice = (): boolean => window.matchMedia(
|
||||
*/
|
||||
export const formatDateAndTime = (date: Date): string => {
|
||||
return format(date, 'yyyy-MM-dd HH:mm');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a function in idle periods. If idle callbacks are not supported (e.g.
|
||||
* Safari) the callback is run immediately.
|
||||
* @param func The function to call.
|
||||
* @param timeout The maximum number of seconds to wait.
|
||||
*/
|
||||
export const runWhenIdleIfSupported = (func: () => void, timeout?: number): void => {
|
||||
if (window.requestIdleCallback) {
|
||||
window.requestIdleCallback(func, {
|
||||
...(timeout && { timeout: timeout})
|
||||
});
|
||||
} else {
|
||||
func();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user