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.2.0 to 0.3.0

87

dist/index.js

@@ -1,57 +0,44 @@

(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
export default class Emitter {
constructor(listeners = {}) {
this.listeners = listeners;
this.listeners = listeners;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Emitter {
constructor(listeners = {}) {
this.listeners = listeners;
this.listeners = listeners;
}
/**
* Register an event handler for the given type.
*
* @param {String} type Type of event to listen for, or `"*"` for all events
* @param {Function} handler Function to call in response to given event
*/
on(type, handler) {
this.listeners[type] = this.listeners[type] || [];
this.listeners[type].push(handler);
}
/**
* Remove an event handler for the given type.
/**
* Register an event handler for the given type.
*
* @param {String} type Type of event to unregister `handler` from, or `"*"`
* @param {Function} handler Handler function to remove
* @param {String} type Type of event to listen for, or `"*"` for all events
* @param {Function} handler Function to call in response to given event
*/
off(type, handler) {
if (this.listeners[type]) {
this.listeners[type].splice(this.listeners[type].indexOf(handler) >>> 0, 1);
}
on(type, handler) {
this.listeners[type] = this.listeners[type] || [];
this.listeners[type].push(handler);
}
/**
* Remove an event handler for the given type.
*
* @param {String} type Type of event to unregister `handler` from, or `"*"`
* @param {Function} handler Handler function to remove
*/
off(type, handler) {
if (this.listeners[type]) {
this.listeners[type].splice(this.listeners[type].indexOf(handler) >>> 0, 1);
}
/**
* Invoke this.listeners handlers for the given type.
* If present, `"*"` handlers are invoked after type-matched handlers.
*
* Note: Manually firing "*" handlers is not supported.
*
* @param {String} type The event type to invoke
* @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
*/
emit(type, evt) {
(this.listeners[type] || []).slice().map((handler) => { handler(evt); });
(this.listeners['*'] || []).slice().map((handler) => { handler(type, evt); });
}
}
exports.default = Emitter;
if (typeof window !== "undefined") {
window.HackDonalds = { Emitter };
/**
* Invoke this.listeners handlers for the given type.
* If present, `"*"` handlers are invoked after type-matched handlers.
*
* Note: Manually firing "*" handlers is not supported.
*
* @param {String} type The event type to invoke
* @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
*/
emit(type, evt) {
(this.listeners[type] || []).slice().map((handler) => { handler(evt); });
(this.listeners['*'] || []).slice().map((handler) => { handler(type, evt); });
}
});
}
if (typeof window !== "undefined") {
window.HackDonalds = { Emitter };
}
//# sourceMappingURL=index.js.map

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

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

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

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