-
Notifications
You must be signed in to change notification settings - Fork 2
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
Bug with unpack chaining #12
Comments
For context, here's what I mean by "unpack chaining" It's unpacking a series of encoded function calls, and |
Hi! Since you already spend a good amount of time figuring out what might be the problem, would you be okay with submitting a PR with a test that fails? It'd go into |
Possibly. I'm using a fork that uses the |
Writing an encoder that supports nested Basically, it happens when unpacking in a loop and interweaving nested |
The issue is with this line here:
https://github.com/Simonwep/nason/blob/951aa9a4d809fa378d341211fb9951f6b6d1e442/src/convert.ts#L29
It's using
.buffer
which returns the original buffer, but uses the wrong byte offset.I tried changing it to
new Uint8Array(val.buffer, val.byteOffset + 1)
but that still had a bug. For example, if decoding a string, the decoded string would have a leading space for some reason. (eg:"foo"
would be" foo"
).Next, I tried doing
val.slice(1)
instead, and that works as expected. Is usingslice
worse for performance?The text was updated successfully, but these errors were encountered: