Skip to content

Commit 7bee61e

Browse files
fix docstrings
Signed-off-by: nkomonen-amazon <[email protected]>
1 parent 94a3602 commit 7bee61e

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

packages/core/src/shared/utilities/timeoutUtils.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ interface WaitUntilOptions {
222222
/** A backoff multiplier for how long the next interval will be (default: None, i.e 1) */
223223
readonly backoff?: number
224224
/**
225-
* Only retries when an error is thrown, otherwise returning the result regardless of truthiness.
226-
* - Ignores 'truthy' arg
227-
* - If the timeout is reached it will throw the last error
225+
* Only retries when an error is thrown, otherwise returning the immediate result.
226+
* - 'truthy' arg is ignored
227+
* - If the timeout is reached it throws the last error
228228
* - default: false
229229
*/
230230
readonly retryOnFail?: boolean
@@ -234,14 +234,13 @@ export const waitUntilDefaultTimeout = 2000
234234
export const waitUntilDefaultInterval = 500
235235

236236
/**
237-
* Invokes `fn()` until it returns a truthy value (or non-undefined if `truthy:false`).
238-
*
239-
* Also look at {@link withRetries} to be able to retry on failures.
237+
* Invokes `fn()` on an interval based on the given arguments. This can be used for retries, or until
238+
* an expected result is given. Read {@link WaitUntilOptions} carefully.
240239
*
241240
* @param fn Function whose result is checked
242241
* @param options See {@link WaitUntilOptions}
243242
*
244-
* @returns Result of `fn()`, or `undefined` if timeout was reached.
243+
* @returns Result of `fn()`, or possibly `undefined` depending on the arguments.
245244
*/
246245
export async function waitUntil<T>(fn: () => Promise<T>, options: WaitUntilOptions & { retryOnFail: true }): Promise<T>
247246
export async function waitUntil<T>(
@@ -308,7 +307,7 @@ export async function waitUntil<T>(fn: () => Promise<T>, options: WaitUntilOptio
308307
throw lastError
309308
}
310309

311-
// when testing, this saves the need to progress the stubbed clock
310+
// when testing, this avoids the need to progress the stubbed clock
312311
if (interval > 0) {
313312
await sleep(interval)
314313
}

packages/core/src/test/shared/utilities/timeoutUtils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ export const timeoutUtilsDescribe = describe('timeoutUtils', async function () {
388388
})
389389

390390
describe('waitUntil w/ retries', function () {
391-
let fn: SinonStub
391+
let fn: SinonStub<[], Promise<string | boolean>>
392392

393393
beforeEach(function () {
394394
fn = sandbox.stub()

0 commit comments

Comments
 (0)