{"repo":"sindresorhus/emittery","free":true,"listed":false,"github":"https://github.com/sindresorhus/emittery","clone":"git clone https://github.com/sindresorhus/emittery.git","description":"Simple and modern async event emitter","language":"JavaScript","stars":2072,"topics":["event-emitter","event-listener","emitter","async","promise","nodejs","npm-package","javascript"],"license":"MIT","category":"dev-tools","readme_excerpt":"Simple and modern async event emitter It works in Node.js and the browser (using a bundler). Highlights - Async-first — listeners are deferred to the next microtask, keeping your code non-blocking - TypeScript support with strongly typed events - Async iteration and for await...of support - Lifecycle hooks ( init / deinit ) for lazy resource setup and teardown - AbortSignal support for cancellation - Symbol.dispose / Symbol.asyncDispose support for automatic cleanup - Meta events for observing listener changes - Debug mode with customizable logging - Zero dependencies Emitting events asynchronously is important for production code where you want the least amount of synchronous operations. Since JavaScript is single-threaded, no other code can run while doing synchronous operations. For Node.js, that means it will block other requests, defeating the strength of the platform, which is scalability through async. In the browser, a synchronous operation could potentially cause lags and block user interaction. Install Usage API eventName Emittery accepts strings, symbols, and numbers as event names. Symbol event names are preferred given that they can be used to avoid name collisions when your classes are extended, especially for internal events. isDebugEnabled Toggle debug mode for all instances. Default: true if the DEBUG environment variable is set to emittery or , otherwise false . Example: emitter = new Emittery(options?) Create a new instance of Emittery. options? Type: objec","default_branch":null,"files":null,"tree":[],"storefront":"/r/sindresorhus","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/sindresorhus/emittery/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}