p-try

  • Version 3.0.0
  • Published
  • 4.13 kB
  • No dependencies
  • MIT license

Install

npm i p-try
yarn add p-try
pnpm add p-try

Overview

`Start a promise chain

Index

Functions

Functions

function default

default: <ValueType, ArgumentsType extends unknown[]>(
function_: (...arguments: ArgumentsType) => PromiseLike<ValueType> | ValueType,
...arguments: ArgumentsType
) => Promise<ValueType>;
  • Start a promise chain.

    Parameter function_

    The function to run to start the promise chain.

    Parameter arguments

    Arguments to pass to function_.

    Returns

    The value of calling function_(...arguments). If the function throws an error, the returned Promise will be rejected with that error.

    Example 1

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

Package Files (1)

Dependencies (0)

No dependencies.

Dev Dependencies (3)

Peer Dependencies (0)

No peer dependencies.

Badge

To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/p-try.

  • Markdown
    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/p-try)
  • HTML
    <a href="https://www.jsdocs.io/package/p-try"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>