Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

395 B
Raw Blame
// Idle-time scheduling shared by the classification/backfill passes.

/**
 * Schedule work for the browser's idle time. Main thread only: the entry-point
 * shim guarantees `requestIdleCallback`, but not in worker scope.
 */
export function scheduleIdle(task: () => void): () => void {
  const handle = requestIdleCallback(task, { timeout: 2000 });
  return () => cancelIdleCallback(handle);
}