Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F4458062
test_eventemitter_function_call.cjs
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
763 B
Referenced Files
None
Subscribers
None
test_eventemitter_function_call.cjs
View Options
const { EventEmitter } = require('events');
function fail(message) {
console.log(`FAIL: ${message}`);
process.exit(1);
}
function Program() {
EventEmitter.call(this);
}
Program.prototype = {};
Program.prototype.__proto__ = EventEmitter.prototype;
Program.prototype.constructor = Program;
const program = new Program();
if (!(program instanceof Program)) {
fail('program should be an instance of Program');
}
let seen = 0;
program.on('tick', () => {
seen++;
});
program.emit('tick');
if (seen !== 1) {
fail('EventEmitter.call(this) should initialize event methods on custom receivers');
}
const ee = EventEmitter.call({});
if (typeof ee !== 'object') {
fail('EventEmitter.call({}) should return the receiver object');
}
console.log('PASS');
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Sat, May 2, 3:44 PM (1 d, 22 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
543765
Default Alt Text
test_eventemitter_function_call.cjs (763 B)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment