ee-first
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
EE-First is a Node.js module that is designed to return the first event among a set of event emitters and event pairs. Its primary function is to invoke a listener on the first event from a specific list, and then clean up after itself. This versatile library provides programmatic control over an application's event-driven functionality, allowing developers to focus on the sequence of events.
To use EE-First, you need to install it first via npm (Node Package Manager) by running the command npm install ee-first
. After successful installation, you can import it into your JavaScript file using var first = require('ee-first')
. EE-First accepts two parameters mainly: arr
(an array of arrays, with each array in the format [ee, ...event]
), and listener
(a function that will be called once, the first time any of the given events are emitted). For example:
var ee1 = new EventEmitter()
var ee2 = new EventEmitter()
first([
[ee1, 'close', 'end', 'error'],
[ee2, 'error']
], function (err, ee, event, args) {
// listener invoked
})
You can cancel the set of listeners as well before being invoked and have all the event listeners removed from the underlying event emitters as follows:
var thunk = first([
[ee1, 'close', 'end', 'error'],
[ee2, 'error']
], function (err, ee, event, args) {
// listener invoked
})
// cancel and clean up
thunk.cancel()
The documentation for EE-first is currently embedded within the README.md file in the GitHub repository of the module named ee-first, where you'll find a detailed explanation and examples of its functionalities and usage. You may also find additional insights from comments and closed issues within the repository.