# @pirxpilot/events

> Simple dom event management.

Latest version **3.0.0** (published 2025-04-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install @pirxpilot/events
pnpm add @pirxpilot/events
yarn add @pirxpilot/events
bun add @pirxpilot/events
```

## Health

**Score 40/100 (D)** — status: stable.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2025-04-27 |
| First published | 2017-12-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Damian Krzeminski |
| Maintainers | pirxpilot |
| Keywords | browser, event, dom |

## Links

- npm: https://www.npmjs.com/package/@pirxpilot/events
- Repository: https://github.com/pirxpilot/events
- Homepage: https://github.com/pirxpilot/events#readme
- Issues: https://github.com/pirxpilot/events/issues
- npm.io page: https://npm.io/package/@pirxpilot/events

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2025-04-27
- 2.0.0 — 2024-02-21
- 1.0.1 — 2017-12-13
- 1.0.0 — 2017-12-12

## README

[![NPM version][npm-image]][npm-url]
[![Build Status][build-image]][build-url]
[![Dependency Status][deps-image]][deps-url]

# events

Bare-bones dom event management. Heavily inspired by [component/events].
Use when multiple event listeners are naturally part of the same object.

## Install

```sh
$ npm install --save @pirxpilot/events
```

## Usage

```js
var events = require('@pirxpilot/events');
var el = document.querySelector('button.ok');
var handlers = {
  click: function() {
    // do something on click
  },
  onblur: function() {
    // do something on blur
  }
};

var e = events(el, obj);
e.bind('click');

// add handlers
e.bind('mouseenter');
e.bind('blur', 'onblur');

e.unbind();
```

## API

### events(el, obj)

create events for dom element `el` and handlers object `obj`

### bind(event, [method])

add event listener and bind it to `obj` - if `method` is not specified use method that has the same name as event ie. use `mouseup` method for `mouseup` event

### Events.unbind([event])

remove event listener for specific `event`, if `event` is not specified remove all registered listeners

## License

MIT © [Damian Krzeminski](https://pirxpilot.me)

[npm-image]: https://img.shields.io/npm/v/@pirxpilot/events
[npm-url]: https://npmjs.org/package/@pirxpilot/events

[build-url]: https://github.com/pirxpilot/events/actions/workflows/check.yaml
[build-image]: https://img.shields.io/github/actions/workflow/status/pirxpilot/events/check.yaml?branch=main

[deps-image]: https://img.shields.io/librariesio/release/npm/@pirxpilot/events
[deps-url]: https://libraries.io/npm/@pirxpilot%2Fevents

[component/events]: https://github.com/component/events

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