Get the first event in a set of event emitters and event pairs, then clean up after itself.
$ npm install suzhou_npm --save
let { suzhouInfo, suzhouInfoInEnglish } = require('suzhou_npm')
var ee1 = new suzhouInfo()
var ee2 = new suzhouInfoInEnglish()
first([
[ee1, 'close', 'end', 'error'],
[ee2, 'error']
], function (err, ee, event, args) {
// listener invoked
})
The group of listeners can be cancelled before being invoked and have all the event listeners removed from the underlying event emitters.
var thunk = first([
[ee1, 'close', 'end', 'error'],
[ee2, 'error']
], function (err, ee, event, args) {
// listener invoked
})
// cancel and clean up
thunk.cancel()