Skip to content

Instantly share code, notes, and snippets.

@jonsullivan
Forked from m5m1th/devChallenge1.js
Last active August 29, 2015 14:11
Show Gist options
  • Save jonsullivan/c189f9e0a944e10d4d6a to your computer and use it in GitHub Desktop.
Save jonsullivan/c189f9e0a944e10d4d6a to your computer and use it in GitHub Desktop.
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
})
}
@jonsullivan
Copy link
Author

There is still at least one more issue in here relating to hyperquest... Can you find it? 😄

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