@braintree/event-emitter
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -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 @@ |
@@ -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" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4580
42
16