{"version":3,"file":"yieldToMain.cjs","sources":["../src/yieldToMain.js"],"sourcesContent":["/**\n * Yields execution to the main thread, allowing other tasks to be processed.\n * Uses scheduler.yield() if available, falling back to setTimeout.\n *\n * @example\n * // Basic usage\n * await yieldToMain();\n *\n * @example\n * // Use in a loop to prevent blocking\n * async function processItems(items) {\n *   for (const item of items) {\n *     await yieldToMain();\n *     // Process item\n *   }\n * }\n *\n * @example\n * // Use with heavy computation\n * async function heavyTask() {\n *   for (let i = 0; i < 1000000; i++) {\n *     if (i % 1000 === 0) await yieldToMain();\n *     // Compute something\n *   }\n * }\n *\n * @returns {Promise<void>} A promise that resolves after yielding to the main thread\n */\nfunction yieldToMain() {\n  // @ts-ignore\n  const scheduler = globalThis.scheduler;\n  if (scheduler && typeof scheduler.yield === 'function') {\n    return scheduler.yield();\n  }\n  return new Promise((resolve) => {\n    setTimeout(resolve, 0);\n  });\n}\n\nexport default yieldToMain;\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,WAAW,GAAG;AACvB;AACA,EAAE,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC;AACzC,EAAE,IAAI,SAAS,IAAI,OAAO,SAAS,CAAC,KAAK,KAAK,UAAU,EAAE;AAC1D,IAAI,OAAO,SAAS,CAAC,KAAK,EAAE,CAAC;AAC7B,GAAG;AACH,EAAE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK;AAClC,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAC3B,GAAG,CAAC,CAAC;AACL;;;;"}