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

@braintree/event-emitter

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@braintree/event-emitter - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

5

CHANGELOG.md

@@ -0,1 +1,6 @@

# 0.3.0
* Fix issue where `off` would throw an error if no events existed for named event
* Add `hasListener` method
# 0.2.0

@@ -2,0 +7,0 @@

28

event-emitter.js

@@ -17,4 +17,10 @@ 'use strict';

var eventCallbacks = this._events[event];
var indexOfCallback = eventCallbacks.indexOf(callback);
var indexOfCallback;
if (!eventCallbacks) {
return;
}
indexOfCallback = eventCallbacks.indexOf(callback);
eventCallbacks.splice(indexOfCallback, 1);

@@ -24,12 +30,22 @@ };

EventEmitter.prototype._emit = function (event) {
var i, args;
var callbacks = this._events[event];
var args;
var eventCallbacks = this._events[event];
if (!callbacks) { return; }
if (!eventCallbacks) { return; }
args = Array.prototype.slice.call(arguments, 1);
for (i = 0; i < callbacks.length; i++) {
callbacks[i].apply(null, args);
eventCallbacks.forEach(function (callback) {
callback.apply(null, args);
});
};
EventEmitter.prototype.hasListener = function (event) {
var eventCallbacks = this._events[event];
if (!eventCallbacks) {
return false;
}
return eventCallbacks.length > 0;
};

@@ -36,0 +52,0 @@

{
"name": "@braintree/event-emitter",
"version": "0.2.0",
"version": "0.3.0",
"description": "A simple event emitter.",

@@ -26,18 +26,19 @@ "main": "event-emitter.js",

"devDependencies": {
"browserify": "^16.2.3",
"browserify": "^16.5.0",
"chai": "^4.2.0",
"eslint": "^5.16.0",
"eslint-config-braintree": "^2.0.0",
"karma": "^4.1.0",
"karma-browserify": "^6.0.0",
"es6-shim": "^0.35.5",
"eslint": "^6.2.2",
"eslint-config-braintree": "^4.0.0",
"karma": "^4.3.0",
"karma-browserify": "^6.1.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-phantomjs-launcher": "^1.0.4",
"mocha": "^6.1.4",
"puppeteer": "^1.17.0",
"sinon": "^7.3.2",
"mocha": "^6.2.0",
"puppeteer": "^1.19.0",
"sinon": "^7.4.1",
"watchify": "^3.11.1"
}
}
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