# @hazae41/plume

> Respondable and extendable events for the web

Latest version **4.0.1** (published 2026-04-29) · 0 weekly downloads

## Install

```sh
npm install @hazae41/plume
pnpm add @hazae41/plume
yarn add @hazae41/plume
bun add @hazae41/plume
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2026-04-29 |
| First published | 2023-03-27 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 8.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | hazae41 |
| Maintainers | hazae41 |
| Keywords | events, async, asynchronous, parallel, sequenced, dispatching, dom, typescript, esmodules, tested, unit-tested |

## Links

- npm: https://www.npmjs.com/package/@hazae41/plume
- Repository: https://github.com/hazae41/plume
- Issues: https://github.com/hazae41/plume/issues
- npm.io page: https://npm.io/package/@hazae41/plume

## Dependencies (1)

- [@hazae41/result-and-option](https://npm.io/package/@hazae41/result-and-option.md) ^2.0.10

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

- 4.0.1 (latest) — 2026-04-29
- 4.0.0 — 2026-04-18
- 3.0.7 — 2025-05-25
- 3.0.6 — 2025-04-01
- 3.0.5 — 2024-09-04
- 3.0.4 — 2024-09-03
- 3.0.3 — 2024-09-03
- 3.0.2 — 2024-09-03
- 3.0.1 — 2024-09-03
- 2.4.5 — 2024-09-02
- 2.4.4 — 2024-09-01
- 2.4.3 — 2024-09-01
- 2.4.2 — 2024-03-27
- 2.4.1 — 2024-03-10
- 2.4.0 — 2024-03-10
- … 31 more at https://npm.io/package/@hazae41/plume/versions

## README

# Plume

Respondable and extendable events for the web

```bash
npm i @hazae41/plume
```

[**NPM 📦**](https://www.npmjs.com/package/@hazae41/plume)

## Features

### Current features
- 100% TypeScript and ESM
- No external dependency
- Web-like patterns

## Usage

Plume provides a few events:
- DataEvent, an Event with some data
- ExtendableEvent, an Event with waitUntil
- RespondableEvent, an ExtendableEvent with respondWith
- DataExtendableEvent, an ExtendableEvent and DataEvent
- DataRespondableEvent, a RespondableEvent and DataEvent

You can create some event target with its own events

```tsx
import { DataRespondableEvent } from "@hazae41/plume" 

export interface MyTargetEventMap {
  close: CloseEvent

  error: ErrorEvent

  request: DataRespondableEvent<Request, Response>,
}

export class MyTarget extends EventTarget {

  close(reason?: string) {
    this.dispatchEvent(new CloseEvent("close", { reason }))
  }

  error(error?: unknown) {
    this.dispatchEvent(new ErrorEvent("error", { error }))
  }

  async request(data: Request): Promise<Response> {
    const event = new DataRespondableEvent<Request, Response>("request", { data })

    this.dispatchEvent(event)

    /**
     * Wait for all extensions
     */
    await event.extension

    /**
     * Wait for the response if any
     */
    if (event.response != null)
      return await event.response

    /**
     * Throw if no response
     */
    throw new Error("Unhandled")
  }

  addEventListener<K extends keyof MyTargetEventMap>(type: K, listener: (e: MyTargetEventMap[K]) => void, options?: AddEventListenerOptions): void

  addEventListener(type: string, callback: (e: Event) => void, options?: AddEventListenerOptions): void

  addEventListener(type: string, callback: (e: Event) => void, options?: AddEventListenerOptions): void {
    return super.addEventListener(type, callback, options)
  }

}
```

And then plug some listeners to it

```tsx
const target = new MyTarget()

target.addEventListener("request", event => {
  /**
   * Wait for 1 second
   */
  event.waitUntil(new Promise(ok => setTimeout(ok, 1000)))
})

target.addEventListener("request", event => {
  /**
   * Respond synchronously
   */
  event.respondWith(new Response("Hello, world!"))
})

const request = new Request("https://example.com/")
const response = await target.request(request)

console.log(await response.text())
```

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