question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Encode some arrays as indefinite length

See original GitHub issue

Is 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:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
hildjjcommented, Oct 25, 2020

I think I haven’t done a release with encodeIndefinite in it. I’ll get on that in the next day or two.

1reaction
hildjjcommented, Aug 4, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found