callback-registry
Advanced tools
Comparing version 2.3.1 to 2.3.2
@@ -11,3 +11,3 @@ "use strict"; | ||
callbacksForKey.push(callback); | ||
return function () { | ||
return () => { | ||
var allForKey = callbacks[key]; | ||
@@ -17,13 +17,12 @@ if (!allForKey) { | ||
} | ||
allForKey = allForKey.filter(function (item) { | ||
return item !== callback; | ||
}); | ||
allForKey = allForKey.reduce((acc, element, index) => { | ||
if (!(element === callback && acc.length === index)) { | ||
acc.push(element); | ||
} | ||
return acc; | ||
}, []); | ||
callbacks[key] = allForKey; | ||
}; | ||
} | ||
function execute(key) { | ||
var argumentsArr = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
argumentsArr[_i - 1] = arguments[_i]; | ||
} | ||
function execute(key, ...argumentsArr) { | ||
var callbacksForKey = callbacks[key]; | ||
@@ -30,0 +29,0 @@ if (!callbacksForKey || callbacksForKey.length === 0) { |
{ | ||
"name": "callback-registry", | ||
"version": "2.3.1", | ||
"version": "2.3.2", | ||
"description": "Registry for callbacks", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -45,7 +45,7 @@ # Intro | ||
``` | ||
# Change log | ||
* 2.3.2 | ||
* fix case where unsubscribe function removes all subscriptions with the same callback reference | ||
* 2.1.1 | ||
* return empty array as result if no subscribers | ||
* catch errors in user callbacks (returns undefine in the result if error) | ||
* catch errors in user callbacks (returns undefined in the result if error) |
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
5801
82