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

attempts

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

attempts

Try func with different args.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by133.33%
Maintainers
1
Weekly downloads
 
Created
Source

attempts npm-version

Try func with different args.

Methods

  • attempts.sync(values, fn) ⇒ result / undefined
    Invoke fn with values[n] one by one, until get a truthy return value.

  • attempts.async(values, fn) Promise (resolved with result / rejected with undefined)
    Invoke fn with values[n] one by one, until get a truthy return value or resolved Promise.

NOTE: Exceptions within fn will be catched & treated as a falsy return, handy for some Node.js API (fs.accessSync, fs.statSync, etc.) throw errors regularly.

Example

Get availiable config:

const attempts = require('attempts')

const readConfig = filename => require(filename)
const possibleConfigs = [
  './config.json',
  './config.default.json'
]

const config = attempts.sync(possibleConfigs, readConfig)

License

MIT © Amio

Keywords

FAQs

Package last updated on 21 Oct 2016

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