Skip to content

Instantly share code, notes, and snippets.

@a-eid a-eid/...js
Created Oct 27, 2018

Embed
What would you like to do?
import EventEmitter from "events"
import fs from "fs"
class WithTime extends EventEmitter {
execute(asyncFunc, ...args) {
console.time("execute")
asyncFund(...args, (err, data) => {
if (err) return this.emit("error", err)
this.emit("data", data)
console.timeEnd("execute")
this.emit("end")
})
}
}
const withTime = new WithTime()
withTime.on("begin", () => {})
withTime.on("end", () => {})
withTime.execute(fs.readFile, __filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.