Created
October 27, 2018 17:27
-
-
Save a-eid/d5a6e420d1c68151e00c6bf3a84f85eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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