pull/16197/head
Rich Harris 8 months ago
parent 5d9bd7f1ef
commit ed50a6bb3f

@ -7,7 +7,7 @@ const request_idle_callback =
: requestIdleCallback; : requestIdleCallback;
/** @type {Array<() => void>} */ /** @type {Array<() => void>} */
let queued_boundary_microtasks = []; let boundary_micro_tasks = [];
/** @type {Array<() => void>} */ /** @type {Array<() => void>} */
let micro_tasks = []; let micro_tasks = [];
@ -16,13 +16,13 @@ let micro_tasks = [];
let idle_tasks = []; let idle_tasks = [];
export function flush_boundary_micro_tasks() { export function flush_boundary_micro_tasks() {
const tasks = queued_boundary_microtasks.slice(); var tasks = boundary_micro_tasks;
queued_boundary_microtasks = []; boundary_micro_tasks = [];
run_all(tasks); run_all(tasks);
} }
export function flush_post_micro_tasks() { export function flush_post_micro_tasks() {
const tasks = micro_tasks.slice(); var tasks = micro_tasks;
micro_tasks = []; micro_tasks = [];
run_all(tasks); run_all(tasks);
} }
@ -42,18 +42,18 @@ function run_micro_tasks() {
* @param {() => void} fn * @param {() => void} fn
*/ */
export function queue_boundary_micro_task(fn) { export function queue_boundary_micro_task(fn) {
if (queued_boundary_microtasks.length === 0 && micro_tasks.length === 0) { if (boundary_micro_tasks.length === 0 && micro_tasks.length === 0) {
queueMicrotask(run_micro_tasks); queueMicrotask(run_micro_tasks);
} }
queued_boundary_microtasks.push(fn); boundary_micro_tasks.push(fn);
} }
/** /**
* @param {() => void} fn * @param {() => void} fn
*/ */
export function queue_micro_task(fn) { export function queue_micro_task(fn) {
if (queued_boundary_microtasks.length === 0 && micro_tasks.length === 0) { if (boundary_micro_tasks.length === 0 && micro_tasks.length === 0) {
queueMicrotask(run_micro_tasks); queueMicrotask(run_micro_tasks);
} }

Loading…
Cancel
Save