put psuedo-code for streaming in comments

This commit is contained in:
AJ ONeal 2010-11-09 10:44:25 -07:00
부모 86e3d5f76b
커밋 566186f8ba
2개의 변경된 파일19개의 추가작업 그리고 2개의 파일을 삭제

파일 보기

@ -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 = [],