diff --git a/src/yieldControl.ts b/src/yieldControl.ts index 49f8b32..466ad5e 100644 --- a/src/yieldControl.ts +++ b/src/yieldControl.ts @@ -16,7 +16,7 @@ let promiseEscapeId: number | undefined * @param priority {SchedulingPriority} The priority of the task being run. * `user-visible` priority will always be resolved first. `background` priority will always be * resolved second. - * @returns {Promise} The promise that will be resolved when the queue + * @returns {Promise} A promise that gets resolved when the work can continue. */ export default async function yieldControl( priority: SchedulingPriority = 'user-visible', diff --git a/src/yieldOrContinue.ts b/src/yieldOrContinue.ts index 3153215..93b1d2d 100644 --- a/src/yieldOrContinue.ts +++ b/src/yieldOrContinue.ts @@ -2,6 +2,18 @@ import yieldControl from './yieldControl' import isTimeToYield from './isTimeToYield' import SchedulingPriority from './SchedulingPriority' +/** + * If there is more time left — immediately returns so the task can continue. If no more time left, + * it waits for the browser to become idle again in order to resume work. Calling + * `yieldOrContinue()` multiple times will create a LIFO(last in, first out) queue – the last call + * to `yieldOrContinue()` will get resolved first. + * + * @param priority {SchedulingPriority} The priority of the task being run. + * `user-visible` priority will always be resolved first. `background` priority will always be + * resolved second. + * @returns {Promise} A promise either immediately resolved or when the browser is ready to + * do work again. + */ // disabling ESLint otherwise `requestPromiseEscape()` in `yieldControl()` won't work // eslint-disable-next-line @typescript-eslint/promise-function-async export default function yieldOrContinue(