Initial commit
[yaffs-website] / node_modules / currently-unhandled / readme.md
1 # currently-unhandled [![Build Status](https://travis-ci.org/jamestalmage/currently-unhandled.svg?branch=master)](https://travis-ci.org/jamestalmage/currently-unhandled) [![Coverage Status](https://coveralls.io/repos/github/jamestalmage/currently-unhandled/badge.svg?branch=master)](https://coveralls.io/github/jamestalmage/currently-unhandled?branch=master)
2
3 > Track the list of currently unhandled promise rejections.
4
5
6 ## Install
7
8 ```
9 $ npm install --save currently-unhandled
10 ```
11
12
13 ## Usage
14
15 ```js
16 const currentlyUnhandled = require('currently-unhandled')(); // <- note the invocation
17
18 var fooError = new Error('foo');
19 var p = Promise.reject(new Error('foo'));
20
21 // on the next tick - unhandled rejected promise is added to the list:
22 currentlyUnhandled();
23 //=> [{promise: p, reason: fooError}]'
24
25 p.catch(() => {});
26
27 // on the next tick - handled promise is now removed from the list:
28 currentlyUnhandled();
29 //=> [];
30 ```
31
32 ## API
33
34 ### currentlyUnhandled()
35
36 Returns an array of objects with `promise` and `reason` properties representing the rejected promises that currently do not have a rejection handler. The list grows and shrinks as unhandledRejections are published, and later handled.
37
38 ## Browser Support
39
40 This module can be bundled with `browserify`. At time of writing, it will work with native Promises in the Chrome browser only. For best cross-browser support, use `bluebird` instead of native Promise support in browsers.
41
42 ## License
43
44 MIT © [James Talmage](http://github.com/jamestalmage)