eventemitter2
Advanced tools
Comparing version 6.4.4 to 6.4.5
@@ -9,2 +9,7 @@ # Change Log | ||
# [6.4.5] - 2021-10-03 | ||
### Fixed | ||
- invoking a wildcard listener when there is also a matching exact listener (#278) @DigitalBrainJS | ||
# [6.4.4] - 2021-02-23 | ||
@@ -11,0 +16,0 @@ |
@@ -476,3 +476,3 @@ /*! | ||
if (i === typeLength && tree._listeners) { | ||
if (i === typeLength) { | ||
// | ||
@@ -482,74 +482,78 @@ // If at the end of the event(s) list and the tree has listeners | ||
// | ||
if (typeof tree._listeners === 'function') { | ||
handlers && handlers.push(tree._listeners); | ||
return [tree]; | ||
} else { | ||
handlers && handlers.push.apply(handlers, tree._listeners); | ||
return [tree]; | ||
if(tree._listeners) { | ||
if (typeof tree._listeners === 'function') { | ||
handlers && handlers.push(tree._listeners); | ||
listeners = [tree]; | ||
} else { | ||
handlers && handlers.push.apply(handlers, tree._listeners); | ||
listeners = [tree]; | ||
} | ||
} | ||
} | ||
} else { | ||
if (currentType === '*') { | ||
// | ||
// If the event emitted is '*' at this part | ||
// or there is a concrete match at this patch | ||
// | ||
branches= ownKeys(tree); | ||
n= branches.length; | ||
while(n-->0){ | ||
branch= branches[n]; | ||
if (branch !== '_listeners') { | ||
_listeners = searchListenerTree(handlers, type, tree[branch], i + 1, typeLength); | ||
if(_listeners){ | ||
if(listeners){ | ||
listeners.push.apply(listeners, _listeners); | ||
}else{ | ||
listeners = _listeners; | ||
if (currentType === '*') { | ||
// | ||
// If the event emitted is '*' at this part | ||
// or there is a concrete match at this patch | ||
// | ||
branches = ownKeys(tree); | ||
n = branches.length; | ||
while (n-- > 0) { | ||
branch = branches[n]; | ||
if (branch !== '_listeners') { | ||
_listeners = searchListenerTree(handlers, type, tree[branch], i + 1, typeLength); | ||
if (_listeners) { | ||
if (listeners) { | ||
listeners.push.apply(listeners, _listeners); | ||
} else { | ||
listeners = _listeners; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return listeners; | ||
} else if (currentType === '**') { | ||
endReached = (i + 1 === typeLength || (i + 2 === typeLength && nextType === '*')); | ||
if (endReached && tree._listeners) { | ||
// The next element has a _listeners, add it to the handlers. | ||
listeners = searchListenerTree(handlers, type, tree, typeLength, typeLength); | ||
} | ||
return listeners; | ||
} else if (currentType === '**') { | ||
endReached = (i + 1 === typeLength || (i + 2 === typeLength && nextType === '*')); | ||
if (endReached && tree._listeners) { | ||
// The next element has a _listeners, add it to the handlers. | ||
listeners = searchListenerTree(handlers, type, tree, typeLength, typeLength); | ||
} | ||
branches= ownKeys(tree); | ||
n= branches.length; | ||
while(n-->0){ | ||
branch= branches[n]; | ||
if (branch !== '_listeners') { | ||
if (branch === '*' || branch === '**') { | ||
if (tree[branch]._listeners && !endReached) { | ||
_listeners = searchListenerTree(handlers, type, tree[branch], typeLength, typeLength); | ||
if(_listeners){ | ||
if(listeners){ | ||
listeners.push.apply(listeners, _listeners); | ||
}else{ | ||
listeners = _listeners; | ||
branches = ownKeys(tree); | ||
n = branches.length; | ||
while (n-- > 0) { | ||
branch = branches[n]; | ||
if (branch !== '_listeners') { | ||
if (branch === '*' || branch === '**') { | ||
if (tree[branch]._listeners && !endReached) { | ||
_listeners = searchListenerTree(handlers, type, tree[branch], typeLength, typeLength); | ||
if (_listeners) { | ||
if (listeners) { | ||
listeners.push.apply(listeners, _listeners); | ||
} else { | ||
listeners = _listeners; | ||
} | ||
} | ||
} | ||
_listeners = searchListenerTree(handlers, type, tree[branch], i, typeLength); | ||
} else if (branch === nextType) { | ||
_listeners = searchListenerTree(handlers, type, tree[branch], i + 2, typeLength); | ||
} else { | ||
// No match on this one, shift into the tree but not in the type array. | ||
_listeners = searchListenerTree(handlers, type, tree[branch], i, typeLength); | ||
} | ||
_listeners = searchListenerTree(handlers, type, tree[branch], i, typeLength); | ||
} else if (branch === nextType) { | ||
_listeners = searchListenerTree(handlers, type, tree[branch], i + 2, typeLength); | ||
} else { | ||
// No match on this one, shift into the tree but not in the type array. | ||
_listeners = searchListenerTree(handlers, type, tree[branch], i, typeLength); | ||
} | ||
if(_listeners){ | ||
if(listeners){ | ||
listeners.push.apply(listeners, _listeners); | ||
}else{ | ||
listeners = _listeners; | ||
if (_listeners) { | ||
if (listeners) { | ||
listeners.push.apply(listeners, _listeners); | ||
} else { | ||
listeners = _listeners; | ||
} | ||
} | ||
} | ||
} | ||
return listeners; | ||
} else if (tree[currentType]) { | ||
listeners = searchListenerTree(handlers, type, tree[currentType], i + 1, typeLength); | ||
} | ||
return listeners; | ||
}else if (tree[currentType]) { | ||
listeners= searchListenerTree(handlers, type, tree[currentType], i + 1, typeLength); | ||
} | ||
@@ -556,0 +560,0 @@ |
{ | ||
"name": "eventemitter2", | ||
"version": "6.4.4", | ||
"version": "6.4.5", | ||
"description": "A feature-rich Node.js event emitter implementation with namespaces, wildcards, TTL, async listeners and browser/worker support.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
84804
1540