Closed mcclure closed 3 years ago
Testing, I fed an ArrayBufferView containing [one CBOR item and then extra bytes] to decodeFirst. I still don't know how to decode an item and then get the index following the decoded item, but it does appear the claim in the decodeFirst docs "This will error if there are more bytes left over at the end" is incorrect. I did not get an error.
I also fixed the docs to make it clear that both decodeFirst
and decodeFirstSync
will throw errors if there is extra data and you haven't specified {extendedResults: true}
.
I'll do a release tomorrow if you agree this fixes your issue.
Example:
cbor.decodeFirstSync('6161f6', {extendedResults: true})
// { value: 'a', bytes: <Buffer 61 61>, length: 2, unused: <Buffer f6> }
this is in 6.0.1
This is great, thank you, I think this is exactly what I needed, I might not have time to test it for a bit tho
The doc for
decodeFirst
says, my emphasis:Several things are confusing me.
Given all this, my questions: