-
-
Save jonsullivan/c189f9e0a944e10d4d6a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hyperquest = require('hyperquest'); | |
module.exports = function downloadUtf8FileIntoString(url, cb) { | |
if (!url) return cb(new Error('url is required')); | |
var result = ''; // fixed scope | |
hyperquest(url) | |
.pipe(function (chunk, enc, tCb) { | |
result += chunk.toString('utf8'); // binary to utf8 | |
tCb(); | |
}) | |
.on('finish', function () { | |
cb(null, result); // fixed | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is still at least one more issue in here relating to hyperquest... Can you find it? 😄