🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis
Socket
Book a DemoInstallSign in
Socket

@yaro.page/nano-events

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yaro.page/nano-events

Cross platform event emitter

latest
npmnpm
Version
1.0.0
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

📚 Events documentation

nano-events is a minimal implementation for event handling that can be used in any environment.

📦 EventEmitter Core

The EventEmitter class is a minimal implementation for event handling.

  • .on(event, listener) registers a listener.
  • .off(event, listener) removes a listener.
  • .emit(event, data) notifies all listeners.

🌐 BrowserEventEmitter

BrowserEventEmitter extends EventEmitter to dispatch events using window or any EventTarget.

  • on(event, listener) binds to native event with CustomEvent.detail.
  • emit(event, data) dispatches CustomEvent with detail.
  • off(event, listener) removes event binding.

🧪 Example Usage

import { BrowserEventEmitter } from '@yaro.page/nano-events'
const bus = new BrowserEventEmitter()
bus.on('hello', (data) => console.log(data))
bus.emit('hello', { msg: 'Hi 👋' })

Use with the node.js EventEmitter

import { EventEmitter as NodeEventEmitter } from 'node:events'
import { NanoEvent } from '@yaro.page/nano-events'
class NanoEventWithEmitter extends NanoEvent {
	createEmitter() {
		return new NodeEventEmitter()
	}
}
const bus = new NanoEventWithEmitter()
let processed = false
bus.on('hello', (data) => {
	processed = data
})
bus.emit('hello', { msg: 'Hi 👋' })
console.log(processed) // { msg: 'Hi 👋' }

📜 License

ISC License

Keywords

nano

FAQs

Package last updated on 08 Jun 2025

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