hildjj / node-cbor

Encode and decode CBOR documents, with both easy mode, streaming mode, and SAX-style evented mode.
MIT License
356 stars 73 forks source link

switch to using Uint8Array instead of using buffer #173

Open jimmywarting opened 1 year ago

jimmywarting commented 1 year ago

Bundeling buffer to the web isn't a good thing... could you maybe instead only depend on Uint8Array stuff?

jimmywarting commented 1 year ago

also wondering if you could switch out the stream for something like async iterator instead...

hildjj commented 1 year ago

Eventually, I'll switch out stream for WHATWG streams, which node is starting to support and are supported by all of the browsers now. That should just be relatively mechanical work, but I can't do it until all of the Node versions that I support have it, which is still some ways away. If you'd like to file a separate issue for that, I'd appreciate it, since it needs to be tracked separately.

Buffer is different. I use quite a bit of the features of Buffer that are layered on top of Uint8Array. However, many of those features might be available in DataView. I'd still need base64, concat, and a few other things. The first phase of that work will be in nofilter. Let's use this existing issue (https://github.com/hildjj/nofilter/issues/1) to think about it.

hildjj commented 1 year ago

Once nofilter is fixed, I'm pretty sure that stream-browserify is still going to need buffer, so the size of the resulting bundle isn't going to change.