promise-assist
Advanced tools
Comparing version 1.0.1 to 1.1.0
export * from './deferred'; | ||
export * from './retry'; | ||
export * from './sleep'; | ||
export * from './timeout'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -7,4 +7,5 @@ "use strict"; | ||
__export(require("./deferred")); | ||
__export(require("./retry")); | ||
__export(require("./sleep")); | ||
__export(require("./timeout")); | ||
//# sourceMappingURL=index.js.map |
export * from './deferred'; | ||
export * from './retry'; | ||
export * from './sleep'; | ||
export * from './timeout'; | ||
//# sourceMappingURL=index.d.ts.map |
export * from './deferred'; | ||
export * from './retry'; | ||
export * from './sleep'; | ||
export * from './timeout'; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "promise-assist", | ||
"description": "Several helper functions when working with native promises", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"main": "./cjs/index.js", | ||
@@ -6,0 +6,0 @@ "module": "./esm/index.js", |
@@ -47,3 +47,3 @@ # promise-assist | ||
Generally bad practice, but there are use-cases where one mixes callback-based API with Promise API and this is helpful. | ||
Generally a bad practice, but there are use-cases, such as mixing callback-based and Promise-based APIs, where this is helpful. | ||
```ts | ||
@@ -60,4 +60,34 @@ import { deferred } from 'promise-assist' | ||
### retry | ||
Executes provided `action` (sync or async) and returns its value. | ||
If `action` throws or rejects, it will retry execution several times before failing. | ||
Defaults are: | ||
- 3 retries | ||
- no delay between retries | ||
- no timeout to stop trying | ||
These can be customized via a second optional `options` parameter. | ||
```ts | ||
import { retry } from 'promise-assist' | ||
retry(() => fetch('http://some-url/asset.json')) | ||
.then(value => value.json()) | ||
.then(console.log) | ||
.catch(e => console.error(e)) | ||
retry(() => fetch('http://some-url/asset.json'), { | ||
retries: -1, // infinite number of retries | ||
delay: 10 * 1000, // 10 seconds delay between retries | ||
timeout: 2 * 60 * 1000 // 2 minutes timeout to stop trying | ||
}) | ||
.then(value => value.json()) | ||
.then(console.log) | ||
.catch(e => console.error(e)) | ||
``` | ||
## License | ||
MIT |
export * from './deferred' | ||
export * from './retry' | ||
export * from './sleep' | ||
export * from './timeout' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
38723
49
616
92