Skip to content

Fixed handling of eof #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fixed handling of eof #5

wants to merge 1 commit into from

Conversation

ertrzyiks
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant