GITLAB

Nattapon Wongpaet / Hospital

Sign in
  • Sign in
  • Project
  • Files
  • Commits
  • Network
  • Graphs
  • Issues 0
  • Merge Requests 0
  • Wiki
  • hospital
  • node_modules
  • p-try
  • readme.md
  • 33ead877   first code Browse Code »
    Nattapon Wongpaet
    2018-10-12 18:33:32 +0700  
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