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
| const fs = require('fs'); | |
| const util = require('util'); | |
| const readFile = util.promisify(fs.readFile); | |
| const readdir = util.promisify(fs.readdir); | |
| async function read1 (file) { | |
| const label = `read1-${file}`; | |
| console.time(label); | |
| const data = await readFile(file, 'utf8'); |
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
| /* === EXAMPLE 1 === */ | |
| // Create a simple Promise wrapper for setTimeout | |
| function wait (ms) { | |
| return new Promise (resolve => setTimeout(resolve, ms)); | |
| } | |
| // Declare an async function | |
| async function hello (name) { | |
| // wait for the specified time |
NewerOlder