Big update!Announcing Socket for GitHub 1.0. Learn more
Socket
BlogLoveFAQ
Install
Log in

p-try

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Issues
File Explorer

Advanced tools

p-try

`Start a promise chain

    3.0.0latest

Version published
Maintainers
1
Weekly downloads
49,484,545
decreased by-5.26%

Weekly downloads

Changelog

Source

Breaking
  • Require Node.js 12.20 11c4a52
  • This package is now pure ESM. Please read this.

https://github.com/sindresorhus/p-try/compare/v2.2.0...v3.0.0

Readme

Source

p-try

Start a promise chain

How is it useful?

Install

npm install p-try

Usage

import pTry from 'p-try'; try { const value = await pTry(() => { return synchronousFunctionThatMightThrow(); }); console.log(value); } catch (error) { console.error(error); }

API

pTry(fn, ...arguments)

Returns a Promise resolved with the value of calling fn(...arguments). If the function throws an error, the returned Promise will be rejected with that error.

Support for passing arguments on to the fn is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a lot of functions.

fn

The function to run to start the promise chain.

arguments

Arguments to pass to fn.


Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Keywords

FAQs

What is p-try?

`Start a promise chain

Is p-try popular?

The npm package p-try receives a total of 40,025,211 weekly downloads. As such, p-try popularity was classified as popular.

Is p-try well maintained?

We found that p-try demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 1 open source maintainer collaborating on the project.

Last updated on 04 Oct 2021
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc