So when you require libraries, you can do so like:
const fs = Promise.promisifyAll(require('fs')) // ... later const fileContents = await fs.readFileAsync('filename.txt')
const fs = require("fs"); fs.exists(`${ __dirname }/1`, (exists1) => { fs.exists(`${ __dirname }/2`, (exists2) => { console.log(JSON.stringify([exists1, exists2])); }); });
const fs = require("mz/fs"); Promise.all([ fs.exists(`${ __dirname }/1`), fs.exists(`${ __dirname }/2`), ]) .then((existers) => { console.log(JSON.stringify(existers)); });
const fs = require("mz/fs"); (async () => { console.log(JSON.stringify(await Promise.all([ fs.exists(`${ __dirname }/1`), fs.exists(`${ __dirname }/2`), ]))); })();
So when you require libraries, you can do so like:
Basically it just adds "Async" after all functions that use node style callbacks.