3 ms·
Great article. I'm still using callbacks >.< The before code should not have Promise: "const fs = Promise.promisifyAll(require('fs'))"
by diegorbaquero 10y ago
Great article. I'm still using callbacks >.<
The before code should not have Promise: "const fs = Promise.promisifyAll(require('fs'))"
- hiphipjorge 10y agoThanks diego! Yes, you're totally right. That line is not needed. I'll go in and fix it. But because of how `promisifyAll` works the code would still work the same way :)
- untog 10y agoOne thing I was surprised to discover is that promisifyAll alters the original object - which is actually great for ES6 imports. So: import fs from 'fs'; Promise.promisifyAll(fs); works great.
- altano 10y agoThat probably won't work when you switch from Babel=>ES5 to Babel=>ES6 (http://www.2ality.com/2015/07/es6-module-exports.html?m=1 http://www.2ality.com/2015/07/es6-module-exports.html?m=1) as ES6 bindings are immutable bindings to the actual values in the module instead of copies.
- romanovcode 10y agoThere is nothing wrong in using callbacks. I actually see many developers over-use promises to the point where code is nearly unreadable.