Skip to content

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.

4 participants