ee-first
Advanced tools
Comparing version 1.0.5 to 1.1.0
16
index.js
@@ -18,3 +18,3 @@ | ||
var event = arr[j] | ||
var fn = listener(event, cleanup) | ||
var fn = listener(event, callback) | ||
@@ -32,4 +32,5 @@ // listen to the event | ||
return function (fn) { | ||
done = fn | ||
function callback() { | ||
cleanup() | ||
done.apply(null, arguments) | ||
} | ||
@@ -43,4 +44,11 @@ | ||
} | ||
done.apply(null, arguments) | ||
} | ||
function thunk(fn) { | ||
done = fn | ||
} | ||
thunk.cancel = cleanup | ||
return thunk | ||
} | ||
@@ -47,0 +55,0 @@ |
{ | ||
"name": "ee-first", | ||
"description": "return the first event in a set of ee/event pairs", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"author": { | ||
@@ -17,3 +17,3 @@ "name": "Jonathan Ong", | ||
"devDependencies": { | ||
"istanbul": "0.3.0", | ||
"istanbul": "0.3.2", | ||
"mocha": "1" | ||
@@ -20,0 +20,0 @@ }, |
@@ -50,2 +50,19 @@ # EE First | ||
#### .cancel() | ||
The group of listeners can be cancelled before being invoked and have all the event | ||
listeners removed from the underlying event emitters. | ||
```js | ||
var thunk = first([ | ||
[ee1, 'close', 'end', 'error'], | ||
[ee2, 'error'] | ||
], function (err, ee, event, args) { | ||
// listener invoked | ||
}) | ||
// cancel and clean up | ||
thunk.cancel() | ||
``` | ||
[npm-image]: https://img.shields.io/npm/v/ee-first.svg?style=flat-square | ||
@@ -52,0 +69,0 @@ [npm-url]: https://npmjs.org/package/ee-first |
Sorry, the diff of this file is not supported yet
6133
53
81