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

@hackdonalds/emitter

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hackdonalds/emitter - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

8

dist/index.d.ts

@@ -9,3 +9,3 @@ declare type EventHandler = (event?: any) => void;

};
export default class Emitter {
export default class Emitter<EventNames> {
listeners: EventHandlerMap;

@@ -19,3 +19,3 @@ constructor(listeners?: EventHandlerMap);

*/
on(type: string, handler: EventHandler): void;
on(type: string & EventNames, handler: EventHandler): void;
/**

@@ -27,3 +27,3 @@ * Remove an event handler for the given type.

*/
off(type: string, handler: EventHandler): void;
off(type: string & EventNames, handler: EventHandler): void;
/**

@@ -38,5 +38,5 @@ * Invoke this.listeners handlers for the given type.

*/
emit(type: string, evt: any): void;
emit(type: string & EventNames, evt: any): void;
}
export {};
//# sourceMappingURL=index.d.ts.map

@@ -5,3 +5,3 @@ {

"keywords": ["event", "emitter", "isomorphic", "events", "nodejs", "Javascript", "mitt", "eventemitter"],
"version": "0.4.0",
"version": "0.5.0",
"main": "dist/index.js",

@@ -8,0 +8,0 @@ "files": ["dist","README.md","src"],

@@ -13,3 +13,3 @@ type EventHandler = (event?: any) => void;

export default class Emitter {
export default class Emitter<EventNames> {
constructor(public listeners: EventHandlerMap = {}) {

@@ -24,3 +24,3 @@ this.listeners = listeners

*/
on(type: string, handler: EventHandler) {
on(type: string & EventNames, handler: EventHandler) {
this.listeners[type] = this.listeners[type] || []

@@ -36,3 +36,3 @@ this.listeners[type].push(handler);

*/
off(type: string, handler: EventHandler) {
off(type: string & EventNames, handler: EventHandler) {
if (this.listeners[type]) {

@@ -52,3 +52,3 @@ this.listeners[type].splice(this.listeners[type].indexOf(handler) >>> 0, 1);

*/
emit(type: string, evt: any) {
emit(type: string & EventNames, evt: any) {
(this.listeners[type] || []).slice().map((handler) => { handler(evt); });

@@ -55,0 +55,0 @@ (this.listeners['*'] || []).slice().map((handler) => { handler(type, evt); });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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