@ts-utilkit/event
v0.2.0
Published
Event handling utilities including EventEmitter, debounce, throttle, event bus, and delegation
Downloads
31
Maintainers
Readme
@ts-utilkit/event
event Functions - TypeScript utility functions for event operations.
Installation
npm install @ts-utilkit/eventFeatures
- 🚀 TypeScript-first with complete type definitions
- ✅ Comprehensive test coverage (>95%)
- 📦 Tree-shakeable ESM and CommonJS support
- 🔒 Type-safe with strict TypeScript configuration
- 📖 Extensive JSDoc documentation
Available Functions (7)
EventEmitter- Custom event emitter class with on, off, emit, once methodsdebounceEvent- Debounces event handlers to delay executionthrottleEvent- Throttles event handlers to limit execution ratecreateEventBus- Creates a publish-subscribe event bus for loose couplingdelegateEvent- Event delegation for handling events on dynamic contentwaitForEvent- Returns a Promise that resolves when an event is emittedonceEvent- Wraps an event handler to execute only once
Quick Example
import { EventEmitter, createEventBus, waitForEvent } from '@ts-utilkit/event';
// Event emitter
const emitter = new EventEmitter();
emitter.on('data', (payload) => console.log(payload));
emitter.emit('data', { message: 'Hello' });
// Event bus
const bus = createEventBus();
bus.subscribe('event', handler);
bus.publish('event', data);License
MIT © Mykyta Forofontov
