Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventEmitter.listeners() returns different results in case longlohn is used #59

Open
Flarna opened this issue May 18, 2016 · 0 comments

Comments

@Flarna
Copy link

Flarna commented May 18, 2016

For events registered via once() the listener() API returns different result if longjohn is used or not.

Reproducer:

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

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

function test() {
    var eventEmitter = new EventEmitter();

    eventEmitter.on('TheEvent', onListener);
    eventEmitter.once('TheEvent', onceListener);

    var listeners = eventEmitter.listeners('TheEvent');
    assert.equal(listeners[0], onListener);
    assert.equal(listeners[1].listener, onceListener);
    // the following assert passes for longlohn case
    //assert.equal(listeners[1], onceListener); 
}

test();

require('longjohn');

test();

Looks like the longlohn implementation unwraps one level too much in listen() for once listeners.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant