Skip to content

longjohn is not compatible to other modules using a similar wrapping of EventEmitter #60

@Flarna

Description

@Flarna

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');

var assert = require('assert');
var EventEmitter = require('events').EventEmitter;

function onListener() {}
function onceListener() {}

function test() {
    var emitter = new EventEmitter;
    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 removed
    assert.equal(emitter.listenerCount('xxx'), 1);

    emitter.removeListener('xxx', onceListener);
    assert.equal(emitter.listenerCount('xxx'), 0);
}

test();

require('longjohn-clone');

test();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions