For some reason, when I first made my changes to fix bytesRemaining I needed line 181 to have bytesRemaining-- unless it'd fall behind. However, this might have been due to a bad version of node, or something else as now when running it that line must be taken out in order to maintain an accurate bytesRemaining count. Sorry about the confusion.
no longer decrementing bytesRemaining at the top of the parse loop
@crash2burn hey no sweat, i'm gonna see if I can somehow expose this property for testing. As it's rather critical to have it working properly.
On the related note, I have seen a lot of high quality pull requests from you, would you like to have commit access to the repo?
The only decent solution I could come up with is to do function generation:
This allows us to inject code to the parse function based on env variables for example. This way we could add an emit call at the end of the loop that emits the bytes remaining, cursor position etc without adding performance overhead for the normal usage. I don't know if you have any better solutions then this idea, i'm open to suggestions.