Skip to content

Instantly share code, notes, and snippets.

@maxdignan
Created April 26, 2016 20:53
Show Gist options
  • Save maxdignan/9528e0c1245788984b0cdcfa794c49ea to your computer and use it in GitHub Desktop.
Save maxdignan/9528e0c1245788984b0cdcfa794c49ea to your computer and use it in GitHub Desktop.
FileStreamingNode
var Iconv = require('Iconv').Iconv;
var fs = require('fs');
var start = Date.now();
function runner(i){
rStream = fs.createReadStream('enwik8');
var iconv = new Iconv('UTF-8', 'UTF-16LE');
wStream = fs.createWriteStream('enwik16');
return rStream.pipe(iconv).pipe(wStream);
}
for (var i = 0; i < 4; i++) {
var stream = runner(i);
if (i === 3) {
stream.on('finish', function() {
console.log((Date.now() - start) / 1000);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment