put psuedo-code for streaming in comments

This commit is contained in:
AJ ONeal 2010-11-09 10:44:25 -07:00
parent 86e3d5f76b
commit 566186f8ba
2 changed files with 19 additions and 2 deletions

View File

@ -1,4 +1,4 @@
// TODO parse streaming
// TODO beef up AHR to allow streamed parsing
"use strict";
(function (undefined) {
var fs = require('fs'),
@ -86,7 +86,7 @@
stream,
data = new Buffer('');
stream = fs.createReadStream(file, { flags: 'r' });
stream = fs.createReadStream(file, { flags: 'r', encoding: 'utf8' });
stream.on('error', function (err) {
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));
}
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) {
var lines = data.split('\n'),
heads = [],