Created
July 29, 2021 06:40
-
-
Save chengjianhua/9e16df6992f7a2fab683a8944055d299 to your computer and use it in GitHub Desktop.
[Close http server]
This file contains 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
const http = require("http"); | |
const { promisify } = require("util"); | |
const sleep = promisify(setTimeout); | |
const server = http.createServer((req, res) => {}); | |
server.listen(6000, async () => { | |
console.log("listening..."); | |
await sleep(2000); | |
server.close(); | |
process.stdin.resume(); | |
}); | |
// const fs = require("fs"); | |
// const extendedFs = Object.create(fs); | |
// console.log(fs.writeFile === extendedFs.writeFile); | |
// extendedFs.readFileSync = () => { | |
// console.log("mocked readFileSync"); | |
// }; | |
// console.log(extendedFs.readFileSync(""), fs.readFileSync); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment