1
0
şunun yansıması https://github.com/coolaj86/fizzbuzz.git eşitlendi 2024-11-16 17:29:04 +00:00

put psuedo-code for streaming in comments

Bu işleme şunda yer alıyor:
AJ ONeal 2010-11-09 10:44:25 -07:00
ebeveyn 86e3d5f76b
işleme 566186f8ba
2 değiştirilmiş dosya ile 19 ekleme ve 2 silme

Dosyayı Görüntüle

Dosyayı Görüntüle

@ -1,4 +1,4 @@
// TODO parse streaming // TODO beef up AHR to allow streamed parsing
"use strict"; "use strict";
(function (undefined) { (function (undefined) {
var fs = require('fs'), var fs = require('fs'),
@ -86,7 +86,7 @@
stream, stream,
data = new Buffer(''); data = new Buffer('');
stream = fs.createReadStream(file, { flags: 'r' }); stream = fs.createReadStream(file, { flags: 'r', encoding: 'utf8' });
stream.on('error', function (err) { stream.on('error', function (err) {
promise.fulfill(err, stream, data); promise.fulfill(err, stream, data);
}); });
@ -150,6 +150,23 @@
console.log("Average height of male dependent of brown-haired male Heads of Household: " + (heights / count)); console.log("Average height of male dependent of brown-haired male Heads of Household: " + (heights / count));
} }
function parseChunk(chunk) {
/*
// TODO be more memory efficient
// by seeking into the buffer
data += chunk
while (true) {
index = data.indexOf('\n')
if (-1 === index) {
break;
}
line = data.substr(0, index);
data = data.substr(index + 1);
parseLine(line);
}
*/
}
function parseData(err, x, data) { function parseData(err, x, data) {
var lines = data.split('\n'), var lines = data.split('\n'),
heads = [], heads = [],