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

as-retryable-promise

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

as-retryable-promise

Wraps a promise so that it can be retried

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Build Status npm version Coverage Status

as-retryable-promise

Wraps a promise so that it can be retried

Usage

const asRetryablePromise = require("as-retryable-promise");
const fs = require("fs");
const fn = () => new Promise((resolve ,reject) => {
  fs.readFile("./my-file.txt", (err, data) => {
    if (err) return reject(err);
    return resolve(data);
  });
});

// Will retry if the file is locked
const options = {
  maxRetries: 5,
  timeout: 1000,
  retryCondition: error => error.code === "EACCES",
};
const retryable = asRetryablePromise(fn, options);

retryable
  .then(data => console.log(data))
  .catch(err => console.error(err)); // Will return the error from the last attempt

Keywords

FAQs

Package last updated on 23 Apr 2019

Did you know?

Socket

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.

Install

Related posts

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