diff --git a/README.md b/README.md index 693e5bb..aacd56f 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ The package is available on [npm](https://npmjs.org/package/async-wait-until): $ npm install --save async-wait-until ``` -It ships with a [UMD](https://github.com/umdjs/umd) bundle by default (which works well as-is on Node.js and web browsers), but bundles for other module systems are also available in the package's `dist/` folder. +It ships with an [UMD](https://github.com/umdjs/umd) bundle by default (which works well as-is on Node.js and web browsers), but bundles for other module systems are also available in the package's `dist/` folder. ```ts import { waitUntil } from 'async-wait-until'; @@ -158,7 +158,7 @@ const doOutThing = async () => { // Yup! Easy right? const divNode = await waitUntil( // Here, we specify a function that will be repeatedly called from time to time - // Let's call this kind of functions a `predicate` + // Let's call this kind of function a `predicate` () => window.document.body.querySelector('div.spooky-spooky-skeleton'), // Here, we can specify a timeout in milliseconds. Once it passes, // we'll stop waiting and throw an exception @@ -171,7 +171,7 @@ const doOutThing = async () => { However, we aren't 100% sure that the `
` will be added within 10 seconds. What will happen if 10 seconds have passed and the `
` node still isn't there? -From the above code, it's clear that our `'predicate'` function (or simply `'preddcate'`) won't return the DOM node. So what `waitUntil` will do in that case is it will throw a `TimeoutException` (also exported from the library so you can handle it). +From the above code, it's clear that our `'predicate'` function (or simply `'predicate'`) won't return the DOM node. So what `waitUntil` will do in that case is it will throw a `TimeoutException` (also exported from the library so you can handle it). ```js import { doTheDivThing } from './a-sneaky-module.js'; @@ -190,10 +190,10 @@ const doOurThing = async () => { } catch (e) { if (e instanceof TimeoutError) { // Unfortunately, 10 seconds have passed but we haven't detected the `
` - // If we had a UI, we could show an error there or allow user to retry + // If we had a UI, we could show an error there or allow the user to retry alert('No
have been detected unfortunately'); } else { - // Some another error, most likely thrown from the predicate function. + // Some other error, most likely thrown from the predicate function. alert('Unknown error occurred'); console.error(e); } @@ -205,7 +205,7 @@ So, summing up the above, the predicate will run again and again within the give ### API -Lets' start with the `waitUntil` function. It takes up to two parameters (**deprecated**: up to three), and returns a Promise that will be resolved with the first non-falsy value returned by the predicate. +Let's start with the `waitUntil` function. It takes up to two parameters (**deprecated**: up to three), and returns a Promise that will be resolved with the first non-falsy value returned by the predicate. Parameter | Type | Required | Default | Description ------------ | ------------- | ------------- | ------------- | ------------- @@ -213,7 +213,7 @@ Parameter | Type | Required | Default | Description `options` | Options object | 🚫 No | 5000 ms | Options for the wait algorithm implemented by `waitUntil`, see its properties on the below table. **Deprecated**: timeout in milliseconds. ~~intervalBetweenAttempts~~ | number | 🚫 No | 50 ms | **Deprecated parameter**: number of milliseconds between retry attempts. Please use options instead. -Above, you could see the options param. Here are the available **options**: +Above, you can see the options param. Here are the available **options**: Parameter | Type | Required | Default | Description ------------ | ------------- | ------------- | ------------- | ------------- @@ -224,7 +224,7 @@ Parameter | Type | Required | Default | Description #### Waiting for something forever -If you aren't sure how long with a process take, you can use `waitUntil.Forever` (which is a shortcut for [Number.POSITIVE_INFINITY](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY)) as the timeout value: +If you aren't sure how long a process will take, you can use `waitUntil.Forever` (which is a shortcut for [Number.POSITIVE_INFINITY](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY)) as the timeout value: ```ts import { waitUntil, WAIT_FOREVER } from 'async-wait-until'; diff --git a/package.json b/package.json index 20b368c..53e9641 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "async-wait-until", - "version": "2.0.7", + "version": "2.0.8", "description": "Waits for a given predicate callback to return a truthy value and resolves", "main": "dist/index.js", "module": "dist/index.esm.js", diff --git a/src/index.ts b/src/index.ts index 907f2a8..3dee86e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -115,7 +115,7 @@ export const WAIT_FOREVER = Number.POSITIVE_INFINITY; * @param intervalBetweenAttempts *(deprecated)* Interval to wait for between attempts, optional, *50 ms* by default * @returns A promise to return the given predicate's result, once it resolves with a truthy value * @template T Result type for the truthy value returned by the predicate - * @throws [[TimeoutError]] An exception throws when the specified timeout interval passes but the predicate doesn't return a truthy value + * @throws [[TimeoutError]] An exception thrown when the specified timeout interval passes but the predicate doesn't return a truthy value * @throws Error * @see [[TruthyValue]] * @see [[FalsyValue]] @@ -245,7 +245,7 @@ type ScheduleFn = (callback: (...args: T[]) => void, interval: number) => Sch */ type CancelScheduledFn = () => void; /** - * A stateful abstraction over Node.js & web browser timers, that cancels the scheduled task + * A stateful abstraction over Node.js & web browser timers that cancels the scheduled task * @private * @category Common Types */ @@ -256,7 +256,7 @@ type ScheduleCanceler = { cancel: CancelScheduledFn; }; /** - * A stateful abstraction over Node.js & web browser timers, that schedules a task + * A stateful abstraction over Node.js & web browser timers that schedules a task * @private * @category Common Types */