Logo white

BJ_web_developers / dyitoc

Sign in
  • Sign in
  • Project
  • Files
  • Commits
  • Network
  • Graphs
  • Milestones
  • Issues 0
  • Merge Requests 0
  • Labels
  • Wiki
  • dyitoc
  • node_modules
  • p-try
  • readme.md
  • add
    aaac7fed
    liuqimichale authored
    2019-01-25 15:48:53 +0800  
    Browse Code »
readme.md 894 Bytes
Edit Raw Blame History Permalink

p-try Build Status

<code>Promise#try()</code> ponyfill - Starts a promise chain

How is it useful?

Install

$ npm install --save p-try

Usage

const pTry = require('p-try');

pTry(() => {
    return synchronousFunctionThatMightThrow();
}).then(value => {
    console.log(value);
}).catch(error => {
    console.error(error);
});

Related

  • p-finally - Promise#finally() ponyfill - Invoked when the promise is settled regardless of outcome
  • More…

License

MIT © Sindre Sorhus