├── debugging_promises.html └── readFilePromisified.js /debugging_promises.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debugging Promises in Chrome 6 | 7 | 8 | 17 | 18 | -------------------------------------------------------------------------------- /readFilePromisified.js: -------------------------------------------------------------------------------- 1 | // This file is meant to be run via babel-node 2 | 3 | import {readFile} from 'fs'; 4 | 5 | function readFilePromisified(filename) { 6 | return new Promise( 7 | function (resolve, reject) { 8 | readFile(filename, { encoding: 'utf8' }, 9 | (error, data) => { 10 | if (error) { 11 | reject(error); 12 | } 13 | resolve(data); 14 | }); 15 | }); 16 | } 17 | 18 | readFilePromisified(process.argv[2]) 19 | .then(text => { 20 | console.log(text); 21 | }) 22 | .catch(error => { 23 | console.log(error); 24 | }); 25 | --------------------------------------------------------------------------------