Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

promise-assist

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-assist - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

cjs/retry.d.ts

1

cjs/index.d.ts
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

2

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc