Initial commit for OpenECOMP SDN-C OA&M
[sdnc/oam.git] / dgbuilder / dgeflows / node_modules / morgan / node_modules / on-finished / node_modules / ee-first / README.md
1 # EE First\r
2 \r
3 [![NPM version][npm-image]][npm-url]\r
4 [![Build status][travis-image]][travis-url]\r
5 [![Test coverage][coveralls-image]][coveralls-url]\r
6 [![License][license-image]][license-url]\r
7 [![Downloads][downloads-image]][downloads-url]\r
8 [![Gittip][gittip-image]][gittip-url]\r
9 \r
10 Get the first event in a set of event emitters and event pairs,\r
11 then clean up after itself.\r
12 \r
13 ## Install\r
14 \r
15 ```sh\r
16 $ npm install ee-first\r
17 ```\r
18 \r
19 ## API\r
20 \r
21 ```js\r
22 var first = require('ee-first')\r
23 ```\r
24 \r
25 ### first(arr, listener)\r
26 \r
27 Invoke `listener` on the first event from the list specified in `arr`. `arr` is\r
28 an array of arrays, with each array in the format `[ee, ...event]`. `listener`\r
29 will be called only once, the first time any of the given events are emitted. If\r
30 `error` is one of the listened events, then if that fires first, the `listener`\r
31 will be given the `err` argument.\r
32 \r
33 The `listener` is invoked as `listener(err, ee, event, args)`, where `err` is the\r
34 first argument emitted from an `error` event, if applicable; `ee` is the event\r
35 emitter that fired; `event` is the string event name that fired; and `args` is an\r
36 array of the arguments that were emitted on the event.\r
37 \r
38 ```js\r
39 var ee1 = new EventEmitter()\r
40 var ee2 = new EventEmitter()\r
41 \r
42 first([\r
43   [ee1, 'close', 'end', 'error'],\r
44   [ee2, 'error']\r
45 ], function (err, ee, event, args) {\r
46   // listener invoked\r
47 })\r
48 ```\r
49 \r
50 #### .cancel()\r
51 \r
52 The group of listeners can be cancelled before being invoked and have all the event\r
53 listeners removed from the underlying event emitters.\r
54 \r
55 ```js\r
56 var thunk = first([\r
57   [ee1, 'close', 'end', 'error'],\r
58   [ee2, 'error']\r
59 ], function (err, ee, event, args) {\r
60   // listener invoked\r
61 })\r
62 \r
63 // cancel and clean up\r
64 thunk.cancel()\r
65 ```\r
66 \r
67 [npm-image]: https://img.shields.io/npm/v/ee-first.svg?style=flat-square\r
68 [npm-url]: https://npmjs.org/package/ee-first\r
69 [github-tag]: http://img.shields.io/github/tag/jonathanong/ee-first.svg?style=flat-square\r
70 [github-url]: https://github.com/jonathanong/ee-first/tags\r
71 [travis-image]: https://img.shields.io/travis/jonathanong/ee-first.svg?style=flat-square\r
72 [travis-url]: https://travis-ci.org/jonathanong/ee-first\r
73 [coveralls-image]: https://img.shields.io/coveralls/jonathanong/ee-first.svg?style=flat-square\r
74 [coveralls-url]: https://coveralls.io/r/jonathanong/ee-first?branch=master\r
75 [license-image]: http://img.shields.io/npm/l/ee-first.svg?style=flat-square\r
76 [license-url]: LICENSE.md\r
77 [downloads-image]: http://img.shields.io/npm/dm/ee-first.svg?style=flat-square\r
78 [downloads-url]: https://npmjs.org/package/ee-first\r
79 [gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square\r
80 [gittip-url]: https://www.gittip.com/jonathanong/\r