Skip to content

Instantly share code, notes, and snippets.

@m5m1th
Created December 5, 2014 21:53
Show Gist options
  • Save m5m1th/a34843e034716cb24af8 to your computer and use it in GitHub Desktop.
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.
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
})
}
@m5m1th
Copy link
Author

m5m1th commented Dec 17, 2014

You're right -- updated to be more specific

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment