Closed achingbrain closed 7 months ago
Been thinking about this, it's a shame that we don't easily expose the Tokenizer
because being able to wrap the existing one in a new one that gates types would be the way to go I think. I think the answer here is to expose more innards to let you do this. Let me experiment.
I want to decode a buffer, but supporting only a subset of CBOR value types - only those that will round-trip to JSON and error out if any non-compliant values are found.
I can control some of this with existing options
allowBigInt
,useMaps
, etc but not everything (Uint8Array
s, for example).Is it possible to override decoding of certain types to throw?
I saw the
tokenizer
option todecode
but looking at the source it seems a bit all-or-nothing, and the defaultTokenizer
needs access tojump
andquick
tables so it's not easily used from outside ofcborg
.I think what I really want is something similar to the
tags
option that lets me supply a decoder for individual data types, or it might be as simple as exporting the defaultTokenizer
for extension and throwing based on the output ofsuper.next()
?