Skip to content

Commit

Permalink
✏️ JSDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
astoilkov committed Nov 20, 2023
1 parent 86f4794 commit 47c1701
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/yieldControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>} The promise that will be resolved when the queue
* @returns {Promise<void>} A promise that gets resolved when the work can continue.
*/
export default async function yieldControl(
priority: SchedulingPriority = 'user-visible',
Expand Down
12 changes: 12 additions & 0 deletions src/yieldOrContinue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>} 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(
Expand Down

0 comments on commit 47c1701

Please sign in to comment.