Converts a Node.js-style callback function into a function that returns a Promise.
A function that expects a callback as its last argument (err, result).
(err, result)
A function that returns a Promise resolving with the result or rejecting with the error.
const fs = require("fs");const readFileAsync = promisify(fs.readFile);readFileAsync("path/to/file.txt", "utf-8").then(console.log); Copy
const fs = require("fs");const readFileAsync = promisify(fs.readFile);readFileAsync("path/to/file.txt", "utf-8").then(console.log);
1.1.0
Converts a Node.js-style callback function into a function that returns a Promise.