# ev

> Fast event emitter - compatible with node's EventEmitter but faster!

Latest version **0.0.7** (published 2012-06-25) · 0 weekly downloads

## Install

```sh
npm install ev
pnpm add ev
yarn add ev
bun add ev
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2012-06-25 |
| First published | 2012-02-09 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.6 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Pierre Curto |
| Maintainers | pierrec |
| Keywords | event, emitter, listener |

## Links

- npm: https://www.npmjs.com/package/ev
- Repository: https://github.com/pierrec/node-ev
- Homepage: http://github.com/pierrec/node-ev
- Issues: http://github.com/pierrec/node-ev/issues
- npm.io page: https://npm.io/package/ev

## Dependencies (1)

- [fnutils](https://npm.io/package/fnutils.md) latest

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 0.0.7 (latest) — 2012-06-25
- 0.0.6 — 2012-03-09
- 0.0.5 — 2012-03-07
- 0.0.4 — 2012-02-26
- 0.0.3 — 2012-02-11
- 0.0.2 — 2012-02-10
- 0.0.1 — 2012-02-09

## README

# README

## Synopsis

This is yet another event emitter implementation for [node.js](http://nodejs.org). It is fully compatible (as of version 0.0.5) with the nodejs' _EventEmitter_ API, with some additions (cf. the Differences section below). The main purpose of node-ev is to provide very fast event emission when dealing with a relatively low number of listeners: below 20 listeners, it is faster than EventEmitter, after that, both average out.

## Differences with node's _EventEmitter_

* New methods
	* `off(event[, listener])`: alias to `removeListener()`
	* `addEventListener(event, listener)`: alias to `addListener()`
	* `emit_myevent([ arg1... ])`: alias for `emit('myevent'[, arg1... ])`
* New member
	* `ev_dedupListener`: does not add a listener if already defined for a given event


## API

```javascript
var EV = require('ev')
var ev = new EV({ match: 1 })

function test (a) {
	console.log('received', a)
}

ev.on('match', test)
ev.emit('match', 'standard emit') // received standard emit
ev.emit_match('shortcut emit!') // received shortcut emit!
```


### Constructor

`EV(events, flag`
* `events` (_Object_): events object listing the possible events to be emitted and their corresponding number of arguments. Note that EV *will* emit events even though they may not have been set by the constructor but performance will be affected in highly demanding situations.
* `flag` (_Boolean_): indicates whether warnings should be triggered (default=true)


```javascript
{
	data: 3
,	end: 1
, drain: 0
}
```

There are 3 events defined by default:

* `error(Error)`: if emitted while no listener attached to it, it will throw as per _EventEmitter_'s behavior
* `newListener(event, listener)`: emitted when a listener is attached to an event
* `oldListener(event, listener)`: emitted when a listener is removed from an event


### Members

* `version` (_String_): EV version
* `ev_dedupListener` (_Boolean_): will not add a listener more than once to the same event if true


### Methods

* `on(event, listener)` (_String_, _Function_): add a listener for [event]
* `once(event, listener)` (_String_, _Function_): add a listener for [event] and remove it once triggered
* `off(event, listener)` (_String_, _Function_): remove the listener for [event]
* `off(event)` (_String_): remove all listeners for [event]
* `removeAllListeners(event)` (_String_): remove all listeners for [event]
* `removeAllListeners()`: remove all listeners for all events
* `emit(event[, arguments])` (_String_[, _Any_]): emit [event] with a list of arguments
* `setMaxListeners(max)` (_Integer_): set the maximum number of listeners after which a warning is issued, but the listeners are still added
* `listeners([event])` (_String_): get the list of listeners for [event] or all listeners for all events

---
_Source: https://npm.io/package/ev · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
