events: make eventNames() return only enumerable properties#5817
events: make eventNames() return only enumerable properties#5817lpinca wants to merge 1 commit intonodejs:masterfrom
Conversation
Right now `eventNames()` returns all the symbol properties (enumerable or not) directly found in `_events`. This patch prevents non-enumerable symbol properties from being included in the returned array.
|
What's the point? There is no public way to add non enumerable property anyway |
|
Yes, this is indeed very edge case but we are using |
|
This makes it a tiny bit slower for no additional benefit. There is no public way to add a non enumerable property to If anything, it could be nice to use |
|
What about some madness like this: 'use strict';
const EE = require('events');
const s = Symbol();
Object.defineProperty(Object.prototype, s, {
get: function () {
Object.defineProperty(this, s, { value: 'foo' });
}
});
const ee = new EE();
ee.listeners(s);
ee._events.hasOwnProperty(s); // => `true`
ee._events.propertyIsEnumerable(s); // => `false` |
|
Ofc if you do that you are crazy but that's an example of how a non-enumerable property can go into |
|
If someone |
|
Ok well these were the only reasons behind this change, I close this. |
Pull Request check-list
Please make sure to review and check all of these items:
make -j8 test(UNIX) orvcbuild test nosign(Windows) pass withthis change (including linting)?
test (or a benchmark) included?
existing APIs, or introduces new ones)?
Affected core subsystem(s)
events
Description of change
Right now
eventNames()returns all the symbol properties (enumerable or not) directly found in_events. This patch prevents non-enumerable symbol properties from being included in the returned array.