@febin52/tiny-event-emitter
v1.0.2
Published
Sub-100-byte type-safe pub/sub event emitter for browser and Node.js.
Downloads
471
Maintainers
Readme
📢 @febin52/tiny-event-emitter
Sub-100-byte type-safe pub/sub event emitter and event bus for browsers, React, Vue, and Node.js.
An ultra-lightweight, memory-efficient pub/sub event dispatcher designed to replace heavy event-emitter dependencies.
🚀 Features
- 🪶 Sub-100 Bytes: Extremely small footprint.
- ⚡ Type-Safe: Full TypeScript generics support.
- 🔄 Core API:
on,off,emit, andoncemethods. - 🌐 Universal: Runs in Node.js, Web Workers, Edge runtimes, and modern browsers.
📦 Installation
npm install @febin52/tiny-event-emitter💡 Usage
import { TinyEventEmitter } from '@febin52/tiny-event-emitter';
const emitter = new TinyEventEmitter();
// Subscribe
const onData = (payload) => console.log('Received:', payload);
emitter.on('data', onData);
// Subscribe Once
emitter.once('init', () => console.log('Initialized'));
// Emit
emitter.emit('data', { id: 42, name: 'Antigravity' });
// Unsubscribe
emitter.off('data', onData);🔗 Links
- NPM Package: https://www.npmjs.com/package/@febin52/tiny-event-emitter
- GitHub Repository: https://github.com/febin52/tiny-event-emitter
- Issue Tracker: https://github.com/febin52/tiny-event-emitter/issues
📄 License
MIT © Febin Francis
