diff -Nru node-eventemitter2-6.4.3/CHANGELOG.md node-eventemitter2-6.4.5/CHANGELOG.md --- node-eventemitter2-6.4.3/CHANGELOG.md 2020-06-22 22:33:37.000000000 +0000 +++ node-eventemitter2-6.4.5/CHANGELOG.md 2021-10-03 18:58:35.000000000 +0000 @@ -6,6 +6,19 @@ For changes before version 2.2.0, please see the commit history +# [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 + +### Added +- `ETIMEDOUT` code property to timeout errors @HalleyAssist + +### Fixed +- prepending listeners to wildcard emitters @Ilrilan + # [6.4.3] - 2020-06-18 ### Fixed diff -Nru node-eventemitter2-6.4.3/debian/changelog node-eventemitter2-6.4.5/debian/changelog --- node-eventemitter2-6.4.3/debian/changelog 2021-01-18 08:34:58.000000000 +0000 +++ node-eventemitter2-6.4.5/debian/changelog 2021-11-15 07:13:40.000000000 +0000 @@ -1,3 +1,14 @@ +node-eventemitter2 (6.4.5-1) unstable; urgency=medium + + * Team upload + * Fix GitHub tags regex + * Update standards version to 4.6.0, no changes needed. + * New upstream version 6.4.5 + * Drop test patch + * Update test + + -- Yadd Mon, 15 Nov 2021 08:13:40 +0100 + node-eventemitter2 (6.4.3-2) unstable; urgency=medium * Team upload diff -Nru node-eventemitter2-6.4.3/debian/control node-eventemitter2-6.4.5/debian/control --- node-eventemitter2-6.4.3/debian/control 2021-01-18 08:32:48.000000000 +0000 +++ node-eventemitter2-6.4.5/debian/control 2021-11-15 07:11:54.000000000 +0000 @@ -6,10 +6,11 @@ Jérémy Lal Build-Depends: debhelper-compat (= 13) , dh-sequence-nodejs + , mocha , node-bluebird - , uglifyjs , nodeunit -Standards-Version: 4.5.1 + , uglifyjs +Standards-Version: 4.6.0 Vcs-Browser: https://salsa.debian.org/js-team/node-eventemitter2 Vcs-Git: https://salsa.debian.org/js-team/node-eventemitter2.git Homepage: https://github.com/hij1nx/EventEmitter2 diff -Nru node-eventemitter2-6.4.3/debian/copyright node-eventemitter2-6.4.5/debian/copyright --- node-eventemitter2-6.4.3/debian/copyright 2021-01-18 08:32:31.000000000 +0000 +++ node-eventemitter2-6.4.5/debian/copyright 2021-11-14 07:12:17.000000000 +0000 @@ -10,7 +10,7 @@ Files: debian/* Copyright: 2014 Matthew Pideil - 2020 Xavier Guimard + 2020 Yadd License: GPL-2+ Files: test/common.js diff -Nru node-eventemitter2-6.4.3/debian/patches/fix-test.diff node-eventemitter2-6.4.5/debian/patches/fix-test.diff --- node-eventemitter2-6.4.3/debian/patches/fix-test.diff 2020-10-26 05:04:05.000000000 +0000 +++ node-eventemitter2-6.4.5/debian/patches/fix-test.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,364 +0,0 @@ -Description: fix tests -Author: Xavier Guimard -Forwarded: no -Last-Update: 2020-10-26 - ---- a/test/simple/addListener.js -+++ b/test/simple/addListener.js -@@ -221,7 +221,7 @@ - - }, - -- '12. should support wrapping handler to an async listener': function (done) { -+ '12. should support wrapping handler to an async listener': function (test) { - var ee= new EventEmitter2(); - var counter= 0; - var f= function(x){ -@@ -236,11 +236,11 @@ - assert.equal(counter, 1); - ee.off('test', f); - assert.equal(ee.listenerCount(), 0); -- done(); -+ test.done(); - }, 10); - }, - -- '13. should support wrapping handler to a promised listener using setImmediate': function (done) { -+ '13. should support wrapping handler to a promised listener using setImmediate': function (test) { - var ee= new EventEmitter2(); - var counter= 0; - var f= function(x){ -@@ -254,13 +254,13 @@ - ee.emitAsync('test', 123).then(function(arg){ - assert.equal(counter, 1); - assert.equal(arg, 124); -- done(); -- }, done); -+ test.done(); -+ }, test.done); - - assert.equal(counter, 0,'the event was emitted synchronously'); - }, - -- '13. should support wrapping handler to an async listener using nextTick': function (done) { -+ '13. should support wrapping handler to an async listener using nextTick': function (test) { - var ee= new EventEmitter2(); - var counter= 0; - var f= function(x){ -@@ -275,11 +275,11 @@ - assert.equal(counter, 1); - ee.off('test', f); - assert.equal(ee.listenerCount(), 0); -- done(); -+ test.done(); - }); - }, - -- '14. should support wrapping once listener to an async listener': function (done) { -+ '14. should support wrapping once listener to an async listener': function (test) { - var ee = new EventEmitter2(); - var counter = 0; - var f = function (x) { -@@ -294,11 +294,11 @@ - assert.equal(counter, 1); - ee.off('test', f); - assert.equal(ee.listenerCount(), 0); -- done(); -+ test.done(); - }, 10); - }, - -- '15. should support returning a listener object if the objectify options is set': function () { -+ '15. should support returning a listener object if the objectify options is set': function (test) { - var ee = new EventEmitter2(); - var counter = 0; - var handler = function (x) { -@@ -326,9 +326,10 @@ - - ee.emit('test', 123); - assert.equal(counter, 1); -+ test.done(); - }, - -- '16. should support returning a listener object using the `once` method if the objectify options is set': function () { -+ '16. should support returning a listener object using the `once` method if the objectify options is set': function (test) { - var ee = new EventEmitter2(); - var counter = 0; - var handler = function (x) { -@@ -354,5 +355,6 @@ - ee.emit('test', 123); - - assert.equal(counter, 0); -+ test.done(); - } - }); ---- a/test/simple/listenTo.js -+++ b/test/simple/listenTo.js -@@ -10,7 +10,7 @@ - } - - module.exports = { -- '1. should listen events': function () { -+ '1. should listen events': function (test) { - var isEmitted= false; - var ee = new EventEmitter(); - var ee2 = new EventEmitter2(); -@@ -24,9 +24,10 @@ - ee.emit('test'); - - assert.equal(isEmitted, true); -+ test.done(); - }, - -- '2. should attach listeners to the target object on demand if newListener & removeListener options activated': function () { -+ '2. should attach listeners to the target object on demand if newListener & removeListener options activated': function (test) { - var isEmitted= false; - var ee = new EventEmitter(); - var ee2 = new EventEmitter2({ -@@ -50,9 +51,10 @@ - - - assert.equal(isEmitted, true); -+ test.done(); - }, - -- '3. should handle listener data': function () { -+ '3. should handle listener data': function (test) { - var isEmitted= false; - var ee = new EventEmitter(); - var ee2 = new EventEmitter2(); -@@ -71,9 +73,10 @@ - ee.emit('test', 1, 2, 3); - - assert.equal(isEmitted, true); -+ test.done(); - }, - -- '4. should support stopListeningTo method': function () { -+ '4. should support stopListeningTo method': function (test) { - var counter= 0; - var ee = new EventEmitter(); - var ee2 = new EventEmitter2(); -@@ -95,9 +98,10 @@ - - assert.equal(counter, 2); - assert.equal(ee.listenerCount('test'), 0); -+ test.done(); - }, - -- '5. should support listening of multiple events': function () { -+ '5. should support listening of multiple events': function (test) { - var emitted1= false; - var emitted2= false; - var ee = new EventEmitter(); -@@ -121,9 +125,10 @@ - - assert.equal(emitted1, true); - assert.equal(emitted2, true); -+ test.done(); - }, - -- '6. should support events mapping': function () { -+ '6. should support events mapping': function (test) { - var emitted1= false; - var emitted2= false; - var ee = new EventEmitter(); -@@ -152,9 +157,10 @@ - - assert.equal(emitted1, true); - assert.equal(emitted2, true); -+ test.done(); - }, - -- '7. should support event reducer': function () { -+ '7. should support event reducer': function (test) { - var counter1= 0; - var counter2= 0; - var ee = new EventEmitter(); -@@ -194,9 +200,10 @@ - - assert.equal(counter1, 1); - assert.equal(counter2, 2); -+ test.done(); - }, - -- '8. should support a single reducer for multiple events': function () { -+ '8. should support a single reducer for multiple events': function (test) { - var counter1= 0; - var ee = new EventEmitter(); - var ee2 = new EventEmitter2(); -@@ -214,9 +221,10 @@ - ee.emit('test2'); - - assert.equal(counter1, 2); -+ test.done(); - }, - -- '9. should detach the listener from the target when the last listener was removed from the emitter': function () { -+ '9. should detach the listener from the target when the last listener was removed from the emitter': function (test) { - var ee = new EventEmitter(); - var ee2 = new EventEmitter2({ - newListener: true, -@@ -238,5 +246,6 @@ - ee2.off('bar', handler); - - assert.equal(ee.listenerCount('foo'), 0); -+ test.done(); - } - }; ---- a/test/simple/symbol.js -+++ b/test/simple/symbol.js -@@ -11,7 +11,7 @@ - } - - module.exports= { -- 'should support symbol keys for plain events': function(){ -+ 'should support symbol keys for plain events': function(test){ - var counter= 0; - var ee= new EventEmitter2(); - var event= Symbol('event'); -@@ -26,9 +26,10 @@ - ee.emit(event); - assert.equal(counter, 1); - assert.equal(ee.listenerCount(), 0); -+ test.done(); - }, - -- 'should support symbol namespace for wildcard events': function(){ -+ 'should support symbol namespace for wildcard events': function(test){ - var counter= 0; - var symbol= Symbol('test'); - var ee= new EventEmitter2({ -@@ -40,5 +41,6 @@ - }); - ee.emit(['event', symbol], 123); - assert.equal(counter, 1); -+ test.done(); - } - }; ---- a/test/wildcardEvents/addListener.js -+++ b/test/wildcardEvents/addListener.js -@@ -310,7 +310,7 @@ - emitter.emit('**.test.**'); // 8 - //emitter.emit('*.**.test.**.a'); // 0 - -- test.expect(58); -+ //test.expect(58); - test.done(); - }, - ---- a/test/wildcardEvents/customDelimiter.js -+++ b/test/wildcardEvents/customDelimiter.js -@@ -243,7 +243,7 @@ - emitter.emit('foo::test'); // 3 - emitter.emit('**'); // 3 - -- test.expect(9); -+ //test.expect(9); - test.done(); - } - ---- a/test/wildcardEvents/eventsNames.js -+++ b/test/wildcardEvents/eventsNames.js -@@ -9,7 +9,7 @@ - } - - module.exports = { -- '1. should return wildcard events namespaces': function () { -+ '1. should return wildcard events namespaces': function (test) { - var symbol= Symbol('test'); - - var ee= new EventEmitter2({ -@@ -28,9 +28,10 @@ - ee.off('a.b.d', listener); - - assert.deepEqual(ee.eventNames(), [ 'z.*', [ 'a', 'b', symbol ], 'a.b.c' ]); -+ test.done(); - }, - -- '2. should return wildcard events namespaces as array if asArray option was set': function () { -+ '2. should return wildcard events namespaces as array if asArray option was set': function (test) { - var symbol= Symbol('test'); - - var ee= new EventEmitter2({ -@@ -49,5 +50,6 @@ - ee.off('a.b.d', listener); - - assert.deepEqual(ee.eventNames(true), [ ['z','*'], [ 'a', 'b', symbol ], ['a','b','c']]); -+ test.done(); - } - }; ---- a/test/wildcardEvents/normalizeEvent.js -+++ b/test/wildcardEvents/normalizeEvent.js -@@ -11,7 +11,7 @@ - } - - module.exports= { -- 'should normalize event name when emitting an event': function(){ -+ 'should normalize event name when emitting an event': function (test) { - var ee= new EventEmitter2({ - wildcard: true - }); -@@ -27,9 +27,10 @@ - ee.emit('event.test'); - ee.emit(['event', 'test']); - assert.equal(counter, 2, 'event not fired'); -+ test.done(); - }, - -- 'should normalize event name when emitting an event in async mode': function(){ -+ 'should normalize event name when emitting an event in async mode': function (test) { - var ee= new EventEmitter2({ - wildcard: true - }); -@@ -47,10 +48,11 @@ - ee.emitAsync(['event', 'test']) - ]).then(function(){ - assert.equal(counter, 2, 'event not fired'); -+ test.done(); - }); - }, - -- 'should not convert ns to a string if ns is an array and contains a symbol': function(){ -+ 'should not convert ns to a string if ns is an array and contains a symbol': function (test) { - var ee= new EventEmitter2({ - wildcard: true - }); -@@ -65,9 +67,10 @@ - - ee.emit(['event', symbol]); - assert.equal(counter, 1, 'event not fired'); -+ test.done(); - }, - -- 'should not convert ns to a string if ns is an array and contains a symbol while emitting in async mode': function(){ -+ 'should not convert ns to a string if ns is an array and contains a symbol while emitting in async mode': function (test) { - var ee= new EventEmitter2({ - wildcard: true - }); -@@ -84,6 +87,7 @@ - ee.emit(['event', symbol]) - ]).then(function(){ - assert.equal(counter, 1, 'event not fired'); -+ test.done(); - }); - } - }; ---- a/test/wildcardEvents/removeAllListeners.js -+++ b/test/wildcardEvents/removeAllListeners.js -@@ -11,7 +11,7 @@ - } - - module.exports= { -- 'should remove all wildcard events': function(){ -+ 'should remove all wildcard events': function(test){ - var counter=0; - - var ee= new EventEmitter2({ -@@ -30,5 +30,6 @@ - ee.removeAllListeners(); - - assert.equal(ee.listenerCount('test.*'), 0); -+ test.done(); - } - }; diff -Nru node-eventemitter2-6.4.3/debian/patches/series node-eventemitter2-6.4.5/debian/patches/series --- node-eventemitter2-6.4.3/debian/patches/series 2020-10-26 05:03:44.000000000 +0000 +++ node-eventemitter2-6.4.5/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -fix-test.diff diff -Nru node-eventemitter2-6.4.3/debian/tests/pkg-js/test node-eventemitter2-6.4.5/debian/tests/pkg-js/test --- node-eventemitter2-6.4.3/debian/tests/pkg-js/test 2020-10-26 05:05:36.000000000 +0000 +++ node-eventemitter2-6.4.5/debian/tests/pkg-js/test 2021-11-15 07:11:40.000000000 +0000 @@ -1 +1 @@ -nodeunit test/simple/ test/wildcardEvents/ +mocha diff -Nru node-eventemitter2-6.4.3/debian/watch node-eventemitter2-6.4.5/debian/watch --- node-eventemitter2-6.4.3/debian/watch 2020-10-26 05:14:24.000000000 +0000 +++ node-eventemitter2-6.4.5/debian/watch 2021-04-14 19:21:08.000000000 +0000 @@ -1,2 +1,2 @@ version=4 -https://github.com/hij1nx/EventEmitter2/tags .*/archive/v?(\d[\d\.]+).tar.gz +https://github.com/hij1nx/EventEmitter2/tags .*/archive/.*/v?(\d[\d\.]+).tar.gz diff -Nru node-eventemitter2-6.4.3/lib/eventemitter2.js node-eventemitter2-6.4.5/lib/eventemitter2.js --- node-eventemitter2-6.4.3/lib/eventemitter2.js 2020-06-22 22:33:37.000000000 +0000 +++ node-eventemitter2-6.4.5/lib/eventemitter2.js 2021-10-03 18:58:35.000000000 +0000 @@ -397,6 +397,7 @@ if (options.timeout > 0) { timer= setTimeout(function(){ var reason= Error('timeout'); + reason.code = 'ETIMEDOUT' timer= 0; promise.cancel(reason); reject(reason); @@ -472,83 +473,87 @@ var listeners= null, branch, xTree, xxTree, isolatedBranch, endReached, currentType = type[i], nextType = type[i + 1], branches, _listeners; - if (i === typeLength && tree._listeners) { + if (i === typeLength) { // // If at the end of the event(s) list and the tree has listeners // invoke those 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); - } - - 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; + 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; + } } } + _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); } xTree = tree['*']; @@ -598,7 +603,7 @@ return listeners; } - function growListenerTree(type, listener) { + function growListenerTree(type, listener, prepend) { var len = 0, j = 0, i, delimiter = this.delimiter, dl= delimiter.length, ns; if(typeof type==='string') { @@ -647,7 +652,11 @@ tree._listeners = [tree._listeners]; } - tree._listeners.push(listener); + if (prepend) { + tree._listeners.unshift(listener); + } else { + tree._listeners.push(listener); + } if ( !tree._listeners.warned && @@ -1228,7 +1237,7 @@ } if (this.wildcard) { - growListenerTree.call(this, type, listener); + growListenerTree.call(this, type, listener, prepend); return returnValue; } diff -Nru node-eventemitter2-6.4.3/package.json node-eventemitter2-6.4.5/package.json --- node-eventemitter2-6.4.3/package.json 2020-06-22 22:33:37.000000000 +0000 +++ node-eventemitter2-6.4.5/package.json 2021-10-03 18:58:35.000000000 +0000 @@ -1,6 +1,6 @@ { "name": "eventemitter2", - "version": "6.4.3", + "version": "6.4.5", "description": "A feature-rich Node.js event emitter implementation with namespaces, wildcards, TTL, async listeners and browser/worker support.", "keywords": [ "event", diff -Nru node-eventemitter2-6.4.3/test/wildcardEvents/fix.js node-eventemitter2-6.4.5/test/wildcardEvents/fix.js --- node-eventemitter2-6.4.3/test/wildcardEvents/fix.js 1970-01-01 00:00:00.000000000 +0000 +++ node-eventemitter2-6.4.5/test/wildcardEvents/fix.js 2021-10-03 18:58:35.000000000 +0000 @@ -0,0 +1,38 @@ +var simpleEvents = require('nodeunit').testCase; +var file = '../../lib/eventemitter2'; +var EventEmitter2; +var assert= require('assert'); + +if (typeof require !== 'undefined') { + EventEmitter2 = require(file).EventEmitter2; +} else { + EventEmitter2 = window.EventEmitter2; +} + +module.exports = simpleEvents({ + 'listeners': { + 'should be invoked when also matching exact listener (#278)': function () { + const ee = new EventEmitter2({ wildcard: true }); + + const stack= []; + + const spy= (id)=> (...args)=> stack.push({id, args}); + + ee.on('A', spy('A')); + ee.on('B.**', spy('B')); + ee.on('C', spy('C1')); + ee.on('C.**', spy('C2')); + + ee.emit('A', 'A'); // Logs "A" once + ee.emit('B', 'B'); // Logs "B" once + ee.emit('C', 'C'); // Logs "C" only once, not matching wildcard C.** + + assert.deepStrictEqual(stack, [ + {id: 'A', args: ['A']}, + {id: 'B', args: ['B']}, + {id: 'C1', args: ['C']}, + {id: 'C2', args: ['C']}, + ]); + } + } +}); diff -Nru node-eventemitter2-6.4.3/test/wildcardEvents/prependListener.js node-eventemitter2-6.4.5/test/wildcardEvents/prependListener.js --- node-eventemitter2-6.4.3/test/wildcardEvents/prependListener.js 1970-01-01 00:00:00.000000000 +0000 +++ node-eventemitter2-6.4.5/test/wildcardEvents/prependListener.js 2021-10-03 18:58:35.000000000 +0000 @@ -0,0 +1,26 @@ +var assert= require('assert'); + +var file = '../../lib/eventemitter2'; +var EventEmitter2; + +if(typeof require !== 'undefined') { + EventEmitter2 = require(file).EventEmitter2; +} +else { + EventEmitter2 = window.EventEmitter2; +} + +module.exports= { + 'use prepend on wildcards mode': function(){ + var ee = new EventEmitter2({ + wildcard: true + }); + var type = ['some', 'listener', 'bar']; + const function1 = function () {} + const function2 = function () {} + + ee.on(type, function2); + ee.prependListener(type, function1); + assert.deepStrictEqual(ee.listeners(type), [function1, function2]) + } +};