This question already has an answer here:
I started to use bluebird instead of Q
Currently the code which I use is like following
runProcess = function(path) {
var result = Promise.defer();
fs.readFileAsync(path)
.then(function (Content) {
var parser = new parseFile(Content);
var adpt = parser.update();
result.resolve(adpt);
}, function(error) {
result.reject(error);
});
return result.promise;
}
My Question if there a better way to write it ?
p = new Promise(function(resolve, reject) {...});
– jfriend00 Jan 28 '16 at 8:40runProcess = path => fs.readFileAsync(path).then(content => (new parseFile(content)).update());
- perfectly readable - maybe not – Jaromanda X Jan 28 '16 at 8:42