Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F7538724
test_eventemitter_max_listeners.cjs
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
test_eventemitter_max_listeners.cjs
View Options
const assert = require('node:assert');
const events = require('node:events');
const { EventEmitter } = events;
const { PassThrough } = require('node:stream');
const ee = new EventEmitter();
assert.equal(typeof ee.once, 'function');
assert.equal(typeof ee.prependListener, 'function');
assert.equal(typeof ee.prependOnceListener, 'function');
assert.equal(typeof ee.listenerCount, 'function');
assert.equal(typeof ee.setMaxListeners, 'function');
assert.equal(typeof ee.getMaxListeners, 'function');
assert.equal(typeof ee.rawListeners, 'function');
assert.equal(ee.getMaxListeners(), 10);
assert.equal(ee.setMaxListeners(3), ee);
assert.equal(ee.getMaxListeners(), 3);
function a() {}
function b() {}
ee.on('x', a);
ee.prependOnceListener('x', b);
assert.equal(ee.listenerCount('x'), 2);
const raw = ee.rawListeners('x');
assert.equal(raw.length, 2);
assert.notEqual(raw[0], b);
assert.equal(raw[0].listener, b);
assert.equal(raw[1], a);
const pt = new PassThrough();
assert.equal(typeof pt.setMaxListeners, 'function');
assert.equal(typeof pt.getMaxListeners, 'function');
assert.equal(typeof pt.once, 'function');
assert.equal(typeof pt.prependListener, 'function');
assert.equal(typeof pt.prependOnceListener, 'function');
assert.equal(typeof pt.listenerCount, 'function');
assert.equal(typeof pt.rawListeners, 'function');
pt.setMaxListeners(30);
assert.equal(pt.getMaxListeners(), 30);
assert.equal(events.getMaxListeners(pt), 30);
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Wed, Jun 17, 1:04 PM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
572495
Default Alt Text
test_eventemitter_max_listeners.cjs (1 KB)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment