Created
December 5, 2014 21:53
-
-
Save m5m1th/a34843e034716cb24af8 to your computer and use it in GitHub Desktop.
Dev Challenge! What are all the issues with this code? Hint: there are several.
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'); | |
var result; | |
module.exports = function downloadUtf8FileIntoString(url, cb) { | |
if (!url) return cb(Error('url is required')); | |
result = ''; | |
hyperquest(url) | |
.pipe(function (chunk, enc, tCb) { | |
result += chunk.toString('utf8'); // binary to utf8 | |
tCb(); | |
}) | |
.on('finish', function () { | |
cb(result); // all done | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're right -- updated to be more specific