Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

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
38,902,719
decreased by-11.29%

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 29,978,832 weekly downloads. As such, p-try popularity was classified as popular.

Is p-try well maintained?

We found that p-try 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.

Last updated on 04 Oct 2021

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
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