# listeners

> Manage collections of listener functions/callbacks

Latest version **1.0.4** (published 2016-09-12) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2016-09-12 |
| First published | 2014-09-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Jason Frame |
| Maintainers | jaz303 |
| Keywords | callback, listener, collection, events |

## Links

- npm: https://www.npmjs.com/package/listeners
- Repository: https://github.com/jaz303/listeners
- Issues: https://github.com/jaz303/listeners/issues
- npm.io page: https://npm.io/package/listeners

## 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

- 1.0.4 (latest) — 2016-09-12
- 1.0.3 — 2016-09-12
- 1.0.2 — 2014-09-07
- 1.0.1 — 2014-09-06
- 1.0.0 — 2014-09-06

## README

# listeners

Represents a collection of registered listener functions, with methods for adding, removing and calling all functions.

## Installation

### npm

Get it:

```shell
npm install --save listeners
```

Require it:

```javascript
var Listeners = require('listeners');
```

## API

#### `var listeners = new Listeners([onError])`

#### `listeners.add(fn, [ctx])`

#### `listeners.remove(fn, [ctx])`

#### `listeners.clear()`

#### `listeners.fire(args...)`

#### `listeners.fireArray(args)`

#### `Listeners.onError(errorHandler)`

Set the default error handler for new instances.

## Error Handling

Should a listener function throw an error, the default behaviour is to log it and continue firing any remaining listeners. This behaviour can be overridden by passing an error handling to the `Listeners` constructor, or by setting a default error handler. An error handler can return `false` to indicate that no further listener functions should be triggered for this event, or alternatively you can rethrow the exception and it will be propagated to as usual.

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