var SingletonFactory = (function(){
function SingletonClass() {
//do stuff
}
var instance;
return {
getInstance: function(){
if (instance == null) {
instance = new SingletonClass();
// Hide the constructor so the returned object can't be new'd...
instance.constructor = null;
}
return instance;
}
};
})();
"use strict";
// require the events and the instance
const Events = require("events");
const events = new Events();
module.exports = events;
// Then require this instance in differnt file
// const events = require("./file-contain-the-singlton-class");