Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
@jsier/retrier
Advanced tools
Promise based retry logic
A simple, efficient and lightweight package without external dependencies which helps quickly implement JavaScript promise based retry logic. Retrier class is built with TypeScript (preserves full compatibility with pure JavaScript) and exposes intuitive and easy-to-use API.
Supports:
$ npm install @jsier/retrier --save
Retrier constructor as a first argument expects function which returns a promise. Second argument is optional and expects retry options object.
import { Retrier } from '@jsier/retrier';
const options = { limit: 5, delay: 2000 };
const retrier = new Retrier(options);
retrier
.resolve(attempt => new Promise((resolve, reject) => reject('Rejected!')))
.then(
result => console.log(result),
error => console.error(error) // After 5 attempts logs: "Rejected!"
);
By default, the retrier will retry until provided promise resolves successfully or until retry limit is reached. To override the defaults please see retry options below:
Property | Description | Type | Default |
---|---|---|---|
limit | Number of attempts. | number | 1 |
delay | Delay between attempts in milliseconds. | number | 0 |
firstAttemptDelay | Delay first attempt. | number | 0 |
keepRetryingIf | Treat resolved value as invalid and keep retrying - if provided function returns truthy value. Example: keepRetryingIf: (response, attempt) => response.status === 202; | Function | undefined |
stopRetryingIf | Stop retrying (reject) if specific error - (provided function returns truthy value). Example: stopRetryingIf: (error, attempt) => error.status === 500; | Function | undefined |
All suggestions and improvements are welcomed and appreciated.
The MIT License.
FAQs
Promise based retry logic.
The npm package @jsier/retrier receives a total of 1,428 weekly downloads. As such, @jsier/retrier popularity was classified as popular.
We found that @jsier/retrier demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.