Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hypernym/emitter

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hypernym/emitter

A super simple and lightweight event emitter.

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Emitter

A super simple and lightweight event emitter.

Repository | Package | Releases | Discussions

npm i @hypernym/emitter

Features

  • TypeScript friendly
  • Fully tree-shakeable
  • No dependencies

Usage

JS

import { createEmitter } from '@hypernym/emitter'

const emitter = createEmitter()

emitter.on('event-id', (e) => console.log(e.x, e.y))

emitter.emit('event-id', { x: 0, y: 0 })

TS

import { createEmitter, type Emitter } from '@hypernym/emitter'

type Events = {
  'event-id': { x: number; y: number }
  // ...
}

const emitter: Emitter<Events> = createEmitter<Events>()

emitter.on('event-id', (e) => console.log(e.x, e.y))

emitter.emit('event-id', { x: 0, y: 0 })

API

.on()

Registers a specific event.

emitter.on(id: string, callback: (event: any) => void)

.emit()

Emits a specific event.

emitter.emit(id: string, event: any)

.events

Main events map.

Stores all registered events.

emitter.events

.has()

Checks if a specific event by id exists in the map.

emitter.events.has(id: string)

.get()

Gets a specific event by id from the map.

emitter.events.get(id: string)

.delete()

Deletes a specific event by id from the map.

emitter.events.delete(id: string)

.clear()

Removes all events from the map.

emitter.events.clear()

Community

Feel free to use the official discussions for any additional questions.

License

Developed in 🇭🇷 Croatia

Released under the MIT license.

© Hypernym Studio

Keywords

FAQs

Package last updated on 11 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc