Open
Conversation
This takes an `Event[]` parameter, which can be produced from an `EventParser` using `Array.from()`. `parse` is now defined in terms of `parseFromEvents`. This will help users who need both the parsed content and the event stream. Previously they had to do the parsing twice, once using `parseEvents` and once with `parse` (which itself calls `parseEvents`). This can now be avoided; `parseEvents` can be called once and then `parseFromEvents` can be called using the extracted events. Users of the old `parse` function should not see any changes. Note: it is possible that there could be performance effects due to the reification of the Event array, since the previous version of `parse` consumed Events as they were streamedfrom `parseEvents` rather than taking an array of all the Events as parameter. However, in our own benchmarks we don't see any significant differences. Closes #111.
matklad
approved these changes
May 13, 2025
Contributor
matklad
left a comment
There was a problem hiding this comment.
LGTM! If we worry about performance, we can type events as Iterable<Event>, so that both an array and a parser work, but personally I'd be happier with array as that is simpler.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This takes an
Event[]parameter, which can be produced from anEventParserusingArray.from().parseis now defined in terms ofparseFromEvents.This will help users who need both the parsed content and the event stream. Previously they had to do the parsing twice, once using
parseEventsand once withparse(which itself callsparseEvents). This can now be avoided;parseEventscan be called once and thenparseFromEventscan be called using the extracted events.Users of the old
parsefunction should not see any changes.Note: it is possible that there could be performance effects due to the reification of the Event array, since the previous version of
parseconsumed Events as they were streamedfromparseEventsrather than taking an array of all the Events as parameter. However, in our own benchmarks we don't see any significant differences.Closes #111.