What tools do people use for working with binary in JS across Node.js and the browser that avoids a full Buffer polyfill in the browser? I have not found a good solution yet.
Webpack for browser code. Which packages a polyfill for you. I’d pull my hair out if I had to work with DataViews and TypedArrays directly, but this solution allows me to forget about it.
Was thinking about it to when working on client side code for @NEARProtocol. We seriously lack JS packaging tools that can operate on method level. Of course language is dynamic, but you should be able to configure exclusion pattern, etc.
What about TextEncoder/TextDecoder APIs? Also I’m meaning to, but never got around, make a lib that exposes all the Buffer.prototype methods as static functions that take Uint8Array’s so only things that need to encode/decode use it but keep API web compatible
That's what i have been thinking about with @lidelOrg but textenconder doesn't cover all the use cases but helps a lot. The bigger problem is the ergonomics of a interface that supports node buffer and a web wrapper arraybuffer thing like this.