Skip to content

Instantly share code, notes, and snippets.

@chengjianhua
Created July 29, 2021 06:40
Show Gist options
  • Save chengjianhua/9e16df6992f7a2fab683a8944055d299 to your computer and use it in GitHub Desktop.
Save chengjianhua/9e16df6992f7a2fab683a8944055d299 to your computer and use it in GitHub Desktop.
[Close http server]
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