Conciseee (EE) provides the same interface as Node.js Event Emitter. EE provides an emitter factory through which you can obtain an emitter instance. If you are intending to use it on Node.js you will have to install the package and require and if you are using it on the Browser you have to add the CDN Link and you are good to go. The code below exhauts the use of all the methods defined in EE and is written in Node.js
const ee = require("conciseee");
let em1 = ee();
// Basic
em1.on("one",()=>console.log("one"));
em1.emit("one");
// With values
em1.on("two",v => console.log(v));
em1.emit("two","Hello World!");
// Regex based
em1.on(/one[1-9]/,()=>console.log("1"));
em1
.emit("one1")
.emit("one4")
.emit("one7");
// Removing handlers
let h = ()=>console.log("Remove me!");
em1.on("three",h).emit("three");
em1.off("three",h).emit("three");
// Universal Handlers
// Event name always passed as the first parameter
// Second parameter is a vararg which will get the values which are passed during emitting events
em1.on("*", (e,...v) => console.log(`Event: ${e} Values: ${v}`));
em1.emit("one");
em1.emit("two");
em1.emit("one5");
em1.emit("x",10,20);
em1.emit("y",3,4);
// Async Notification
// Sync
em1.on("test",() => console.log("Executed1"));
// Default Async
// The third parameter for enabling async notification
// which is done through setTimeout(f,0).
// Any non-numeric truthy value will work.
em1.on("test",() => console.log("Executed2"),true);
// Custom Timeout
// You can also pass custom timeout value.
em1.on("test",() => console.log("Executed3"),500);
// Custom Scheduler
// You can also pass a custom scheduler which is executed to schedule
// the handler for execution when the event is emitted.
em1.on("test",() => console.log("Executed4"),f => process.nextTick(f));
em1.emit("test");