You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The way how longjohn wraps EventEmitter is incompatible with other modules doing a similar/same wrapping.
I tested by creating a clone of longjohn (incl. modifiny the 'longjohn' property of on()) and used it together with unmodified longjohn in following script:
require('longjohn');varassert=require('assert');varEventEmitter=require('events').EventEmitter;functiononListener(){}functiononceListener(){}functiontest(){varemitter=newEventEmitter;emitter.on('xxx',onListener);emitter.once('xxx',onceListener);assert.equal(emitter.listenerCount('xxx'),2);emitter.removeListener('xxx',onListener);// fails on second call as onListener was not removedassert.equal(emitter.listenerCount('xxx'),1);emitter.removeListener('xxx',onceListener);assert.equal(emitter.listenerCount('xxx'),0);}test();require('longjohn-clone');test();
The text was updated successfully, but these errors were encountered:
Above sample passes now since #67 but following sample fails:
require('longjohn');
var assert = require('assert');
var EventEmitter = require('events').EventEmitter;
function onListener() {}
function onceListener() {}
function test() {
var emitter = new EventEmitter;
emitter.on('xxx', onListener);
assert.equal(emitter.listenerCount('xxx'), 1);
emitter.emit("xxx");
// fails on second call as onListener was removed
assert.equal(emitter.listenerCount('xxx'), 1);
}
test();
require('longjohn-clone');
test();
Reason is that second on() call sees the listener property and installs the function as once handler.
The way how longjohn wraps EventEmitter is incompatible with other modules doing a similar/same wrapping.
I tested by creating a clone of longjohn (incl. modifiny the 'longjohn' property of on()) and used it together with unmodified longjohn in following script:
The text was updated successfully, but these errors were encountered: