earthstar-project / stone-soup

A specification and Javascript library for building online tools you can truly call your own.
https://earthstar-project.org
GNU Lesser General Public License v3.0
4 stars 2 forks source link

Split `bytes.ts` into `bytes.ts` and `buffers.ts` #10

Closed cinnamon-bun closed 2 years ago

cinnamon-bun commented 3 years ago

What's the problem you want solved?

We want to isolate the Buffer-using code as much as possible

Is there a solution you'd like to recommend?

Move all the functions that mention Buffer into a separate file, buffers.ts, so we're less likely to end up with the Buffer polyfill included in our bundles.

bytes.ts will still have helper functions for using UInt8Arrays.

cinnamon-bun commented 3 years ago

This is mostly done now, but there are still 2 functions in bytes.ts that use Buffers:

https://github.com/earthstar-project/stone-soup/blob/6182077c6eb5cc9b4abda35d933be6d18faccbb6/src/util/bytes.ts#L60-L69

We need to reimplement these without Buffers, in a platform-neutral way (no atob or btoa either)... that's still efficient. Hmmm.