Skip to content
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

feat: Add PositionTracker #919

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

feat: Add PositionTracker #919

wants to merge 1 commit into from

Conversation

fb55
Copy link
Owner

@fb55 fb55 commented Aug 23, 2021

I took a stab at implementing a position tracker that works for streams. This is something that's been asked for every once in a while, and it seems easy enough to add.

  • Directly integrate into Parser

@coveralls
Copy link

Pull Request Test Coverage Report for Build 1158889962

  • 34 of 34 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.06%) to 98.286%

Totals Coverage Status
Change from base Build 1158875845: 0.06%
Covered Lines: 975
Relevant Lines: 992

💛 - Coveralls

@fb55
Copy link
Owner Author

fb55 commented Aug 23, 2021

@thewilkybarkid I haven't made up my mind if I want to have this in the module or not. Curious if the parser providing this directly would be a value-add for you.

My current plan is to provide a getPosition(index) method on the parser, which allows you to get a position like this:

const startPos = parser.getPosition(parser.startIndex);

@thewilkybarkid
Copy link

Probably worth not adding it to start with at least (feels a little too specialist).

An aside, but I think this has the same problem that posthtml/posthtml-parser#80 had to work around: needing to be able to backtrack (a bit).

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.

3 participants