p-wait-for
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -16,2 +16,11 @@ declare namespace pWaitFor { | ||
readonly timeout?: number; | ||
/** | ||
Whether to run the check immediately rather than starting by waiting `interval` milliseconds. | ||
Useful for when the check, if run immediately, would likely return `false`. In this scenario, set `leadingCheck` to `false`. | ||
@default true | ||
*/ | ||
readonly leadingCheck?: boolean; | ||
} | ||
@@ -18,0 +27,0 @@ } |
@@ -8,2 +8,3 @@ 'use strict'; | ||
timeout: Infinity, | ||
leadingCheck: true, | ||
...options | ||
@@ -33,3 +34,7 @@ }; | ||
check(); | ||
if (options.leadingCheck) { | ||
check(); | ||
} else { | ||
retryTimeout = setTimeout(check, options.interval); | ||
} | ||
}); | ||
@@ -36,0 +41,0 @@ |
{ | ||
"name": "p-wait-for", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Wait for a condition to be true", | ||
"license": "MIT", | ||
"repository": "sindresorhus/p-wait-for", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
@@ -12,0 +13,0 @@ "engines": { |
@@ -1,2 +0,2 @@ | ||
# p-wait-for [![Build Status](https://travis-ci.org/sindresorhus/p-wait-for.svg?branch=master)](https://travis-ci.org/sindresorhus/p-wait-for) | ||
# p-wait-for | ||
@@ -7,3 +7,2 @@ > Wait for a condition to be true | ||
## Install | ||
@@ -15,3 +14,2 @@ | ||
## Usage | ||
@@ -29,6 +27,5 @@ | ||
## API | ||
### pWaitFor(condition, [options]) | ||
### pWaitFor(condition, options?) | ||
@@ -45,7 +42,7 @@ Returns a `Promise` that resolves when `condition` returns `true`. Rejects if `condition` throws or returns a `Promise` that rejects. | ||
Type: `Object` | ||
Type: `object` | ||
##### interval | ||
Type: `number`<br> | ||
Type: `number`\ | ||
Default: `20` | ||
@@ -57,3 +54,3 @@ | ||
Type: `number`<br> | ||
Type: `number`\ | ||
Default: `Infinity` | ||
@@ -63,3 +60,11 @@ | ||
##### leadingCheck | ||
Type: `boolean`\ | ||
Default: `true` | ||
Whether to run the check immediately rather than starting by waiting `interval` milliseconds. | ||
Useful for when the check, if run immediately, would likely return `false`. In this scenario, set `leadingCheck` to `false`. | ||
## Related | ||
@@ -69,6 +74,1 @@ | ||
- [More…](https://github.com/sindresorhus/promise-fun) | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5752
93