Skip to content

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