.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / p-try / readme.md
1 # p-try [![Build Status](https://travis-ci.org/sindresorhus/p-try.svg?branch=master)](https://travis-ci.org/sindresorhus/p-try)
2
3 > [`Promise#try()`](https://github.com/ljharb/proposal-promise-try) [ponyfill](https://ponyfill.com) - Starts a promise chain
4
5 [How is it useful?](http://cryto.net/~joepie91/blog/2016/05/11/what-is-promise-try-and-why-does-it-matter/)
6
7
8 ## Install
9
10 ```
11 $ npm install --save p-try
12 ```
13
14
15 ## Usage
16
17 ```js
18 const pTry = require('p-try');
19
20 pTry(() => {
21         return synchronousFunctionThatMightThrow();
22 }).then(value => {
23         console.log(value);
24 }).catch(error => {
25         console.error(error);
26 });
27 ```
28
29
30 ## Related
31
32 - [p-finally](https://github.com/sindresorhus/p-finally) - `Promise#finally()` ponyfill - Invoked when the promise is settled regardless of outcome
33 - [More…](https://github.com/sindresorhus/promise-fun)
34
35
36 ## License
37
38 MIT © [Sindre Sorhus](https://sindresorhus.com)