Closed mcclure closed 3 years ago
I'm pretty sure it works for the most part in browser, though there are hiccups.
As a heads-up, there are node implementations of WebSockets as well.
OK, I'm finally getting around to this. Would a simple demo using webpack be enough?
If you actively want to replace webpack with something I think people are using "parcel" now more these days, but I think the demo is fine! (I still use webpack.)
I also got browserify+babelify to work pretty easily. I'll give parcel a shot, then provide examples of all three.
OK, that feels like plenty of examples. Moral of the story: you can't just use this library with import
, you need to bundle up polyfills for Buffer, process, util, and stream (at least), along with nofilter and bignumber.js.
The easiest of these to use, BY FAR, was parcel.
Getting offtopic here but is there a specific reason you use bignumber.js instead of ES2020 BigInt? Being able to rely on the browser BigInt implementation instead of including bignumber would significantly lower the browser footprint of the node-cbor library.
Using BigInts is now the default in v6.0.0. BigNumber is still needed for large fractional numbers, at least until https://github.com/tc39/proposal-decimal lands.
@mcclure see #131
Hi, I came across this project for the first time today. I'm trying to incorporate it into a project (targeting web initially and possibly node cli later). The README says:
And the main cbor website seems to suggest node-cbor is for use with node exclusively.
However, other things (like issues talking about websocket) seem to suggest this works with browser.
Because the existing language is potentially misleading, it would be helpful if your landing page made it explicit you work in the browser. And if you don't work in browser, it would be helpful to make that explicit.
(I see there is a separate cbor-js package, but (1) I want to write my own code in such a way it works in both node and browser, and (2) the cbor-js package is five years old and seems to rely on five-year-old technologies such as Bower.)