Packed CBOR Support
Do you have any plans to support this? https://datatracker.ietf.org/doc/draft-ietf-cbor-packed/
I could be up for contributing this, WDYT?
I have looked at this spec. I was some what skeptical that this would actually be faster or more compact than using standard CBOR with standard compression tools (we use LZ4 for performance, but Brotli has really good compression). However, I would certainly be interested if the packed specification could be competitive in performance and size.
Wondering if this overlaps pretty closely with your cbor-records proposal actually: https://github.com/kriszyp/cbor-records
I have discussed the possible overlap of the records proposal with the CBOR working group. My assertion is that the records proposal actually has a pretty distinct goal of semantics (distinguishing and defining structured objects/records vs maps) and performance, whereas CBOR packed is more about compactness. And I suspected it might be distinctly slower to implement the packed specification with checking for duplicates of every string. But again, maybe I am wrong, and this could be efficient.
Does CBOR-X support compression? I've implemented packing on data using CBOR but the file is not compressed. The ratio is 198KB unpack and 35KB when gziped (I have data with a lot of long strings). The problem is that I can't use web server gzip compression using jsDevlivr (jsdelivr/jsdelivr#18336) because it only supports a handful of file extensions where gzip is enabled by cloudflare.
Having compression in the library would be awesome, even small size reduction will make great impact.
How would including compression in the cbor-x package be different/better than simply compressing the CBOR immediately after serializing it?
require("zip").gzipSync(require('cbor-x').encode(myData))
Or are you asking that I actually finish this ticket so that packed-CBOR is supported? :)
For the browser, simple compression built-in may be smaller than the whole zip library.
Generally with gzip, you compress on the server and specify the compression encoding with the HTTP Content-Encoding header, and then the browser automatically decompresses the gzipped content for you, no JS involved at all. However, if I understand your context, you don't have control over the HTTP delivery (due to edge caches), so you want JS-based compression in CBOR. This is indeed the intent of the packed-cbor format, and yeah, I will work on getting this finished.