Floby/node-parser — pull request #5 by ertrzyiks (2014-10-25 20:33:37+00:00)
Title: Fixed handling of eof

It is impossible to get final result of parsing when tokenizer does not emit 'end' event. Side effect of this fix is additional token of type 'eof' emitted on the end of parsing (which was original idea anyway).

This is what i need, but doesnt work in current version.

module.exports.parseStream = function (stream, done) {
var p = new MyParser();

p.on('end', function () {
done(null, p.getParsingResult());
});

stream.on('data', function (data) {
p.write(data);
});

stream.on('end', function () {
p.end();
});
};

Note that `done` function can not be called on stream end, because its not end of tokenizing/parsing process.