ee-first

WebJar for ee-first

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

ee-first
Last Version

Last Version

1.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

ee-first
WebJar for ee-first
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/jonathanong/ee-first

Download ee-first

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/ee-first/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>ee-first</artifactId>
    <version>1.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/ee-first/
implementation 'org.webjars.npm:ee-first:1.1.1'
// https://jarcasting.com/artifacts/org.webjars.npm/ee-first/
implementation ("org.webjars.npm:ee-first:1.1.1")
'org.webjars.npm:ee-first:jar:1.1.1'
<dependency org="org.webjars.npm" name="ee-first" rev="1.1.1">
  <artifact name="ee-first" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='ee-first', version='1.1.1')
)
libraryDependencies += "org.webjars.npm" % "ee-first" % "1.1.1"
[org.webjars.npm/ee-first "1.1.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

ee-first

NPM version Build status Test coverage License Downloads

Get the first event in a set of event emitters and event pairs, then clean up after itself.

Install

$ npm install ee-first

API

var first = require('ee-first')

first(arr, listener)

Invoke listener on the first event from the list specified in arr. arr is an array of arrays, with each array in the format [ee, ...event]. listener will be called only once, the first time any of the given events are emitted. If error is one of the listened events, then if that fires first, the listener will be given the err argument.

The listener is invoked as listener(err, ee, event, args), where err is the first argument emitted from an error event, if applicable; ee is the event emitter that fired; event is the string event name that fired; and args is an array of the arguments that were emitted on the event.

var ee1 = new EventEmitter()
var ee2 = new EventEmitter()

first([
  [ee1, 'close', 'end', 'error'],
  [ee2, 'error']
], function (err, ee, event, args) {
  // listener invoked
})

.cancel()

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()

Versions

Version
1.1.1
1.1.0
1.0.3