mirror of https://github.com/coolaj86/fizzbuzz.git
put psuedo-code for streaming in comments
This commit is contained in:
parent
86e3d5f76b
commit
566186f8ba
|
@ -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 = [],
|
||||||
|
|
Loading…
Reference in New Issue