Encode some arrays as indefinite length
See original GitHub issueIs is possible to enforce the encoder to use indefinite-length arrays?
What I want to achieve is for instance:
const a = [[0, 1]]
and after encoding, obtain:
9F # array(*)
82 # array(2)
00 # unsigned(0)
01 # unsigned(1)
FF # primitive(*)
Note that the outer array has indefinite-length while the inner array has a fixed length.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Support definite-length Arrays and Maps in CBOR #1955
This API is strictly requesting Arrays and Maps to be encoded with a definite length, because of / lack of dynamic memory allocation....
Read more >Type 4 – Arrays — libcbor 0.9.0 documentation
CBOR arrays, just like byte strings and strings, can be encoded either as definite, or as indefinite. Definite arrays have a fixed size...
Read more >RFC 7049: Concise Binary Object Representation (CBOR)
Indefinite Lengths for Some Major Types Four CBOR items (arrays, maps, byte strings, and text strings) can be encoded with an indefinite length...
Read more >RFC 8949 - Concise Binary Object Representation (CBOR)
3.2. Indefinite Lengths for Some Major Types. Four CBOR items (arrays, maps, byte strings, and text strings) can be encoded with an indefinite...
Read more >cborg - npm
Objects, arrays, strings and bytes are encoded as fixed-length, encoding as indefinite length is intentionally not supported.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think I haven’t done a release with encodeIndefinite in it. I’ll get on that in the next day or two.
I’ve added
Encoder.encodeIndefinite
with an example in the docs. Should work for Array, Map, String, Buffer, and Objects. I’m going to fix a thing or too more before doing a release, hopefully in a few hours, but take a look at the tests in the above commit for some ideas on how to use it.