How can I restructure this bit of code so that it uses a promise instead of a callback?
This is the code:
var download = function(uri, filename, callback){
request.head(uri, function(err, res, body){
request(uri).pipe(fs.createWriteStream(filename)).on('close', callback);
});
};