How to Package Events

  node.js, question

Only then did I contact node, knowing that Eventemitter can add an event with the on method, and then trigger the event with Emit.
Now I want to write a module by myself, which can provide the method of adding events to the outside, and then these events can be executed during the module execution.

import MyFunc from './myfunc';
 let my = new MyFunc();
 my.on('start', function() {
 Log ('start');
 });
 my.on('end', function() {
 Log ('end');
 })

The effect I want to achieve is similar to the above. functions can be added to certain events outside the module.
Should EventEmitter be used inside the module? How to expose the on method? It is best to give an example, thank you!

Inherit EventEmiter
ES5

var EventEmitter = require("events").EventEmitter;
 
 function MyClass() {
 EventEmitter.call(this);
 bracket
 
 MyClass.prototype = Object.create(EventEmitter.prototype);
 
 MyClass.prototype.doSomething = function(data) {
 this.emit("doSomething", data);
 bracket

ES6

var EventEmitter = require("events").EventEmitter;
 class MyClass extends EventEmitter
 bracket
 constructor(){
 super();
 bracket
 
 doSomething(data){
 this.emit("doSomething", data);
 bracket
 bracket