feat: Add PositionTracker
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
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 | |
|---|---|
| Change from base Build 1158875845: | 0.06% |
| Covered Lines: | 975 |
| Relevant Lines: | 992 |
💛 - Coveralls
@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);
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 https://github.com/posthtml/posthtml-parser/pull/80 had to work around: needing to be able to backtrack (a bit).