Comments (5)
@hugomrdias I'm willing to work on a pull request that removes dependency on buffer in favor of Uint8Array
but I'd like to make sure that changes would be accepted before I invest time into it.
from js-multihashing-async.
IMO, the APIs should accept any binary type or view and just convert to a Buffer
internally if necessary.
I’d love it if we also never returned Buffer
instances, but that would be a much larger breaking change :( The problem is that one of the most common things people do with the multihash buffer is call .toString(‘base64’)
which of course will break if we started returning anything but a Buffer
instance.
from js-multihashing-async.
IMO, the APIs should accept any binary type or view and just convert to a
Buffer
internally if necessary
I actually would like to get rid off Buffer
dependency which is annoying chunk of code in browser.
I'm also reluctant to accept any binary type proposition, it seems like a good idea but in practice it comes with mental overhead (requiring side trips) to know what's being passed around. I'd much rather choose canonical representation and point users to adapters if they happen to need different one.
It is also not obvious to me what the desired behavior is if e.g. Float64Array
instance has being provided. Sure we can just read underlying bytes from the corresponding buffer slice, but in practice I think it's more error prone than helpful.
I’d love it if we also never returned Buffer instances, but that would be a much larger breaking change :( The problem is that one of the most common things people do with the multihash buffer is call .toString(‘base64’) which of course will break if we started returning anything but a Buffer instance.
I actually implied getting rid of Buffer
although I guess that is probably better set aside for next iteration. The way I was thinking to go about is to pull out Buffer
free core into separate package and use this as a wrapper that just wraps returns into Buffer
. Then we could go after each dependency and migrate them to Buffer
free core.
For base64 conversion we could have separate module just like we do for base56
from js-multihashing-async.
I actually implied getting rid of Buffer although I guess that is probably better set aside for next iteration. The way I was thinking to go about is to pull out Buffer free core into separate package and use this as a wrapper that just wraps returns into Buffer. Then we could go after each dependency and migrate them to Buffer free core.
I like this approach, it lets us maintain compatibility while opening up a better option for people that want it. It doesn’t even need to be another module, it could just be something like require(‘multihashing-async/core’)
.
from js-multihashing-async.
It doesn’t even need to be another module, it could just be something like require(‘multihashing-async/core’).
The reason I thought it was better to go with separate package is so we can track how many packages still depending on buffer wrapped version (through npm stats). If it’s same package it would be a lot harder to tell / migrate.
from js-multihashing-async.
Related Issues (18)
- An in-range update of aegir is breaking the build 🚨 HOT 1
- Needs the labels HOT 3
- An in-range update of multihashes is breaking the build 🚨 HOT 1
- Why the requirement on webcrypto? HOT 7
- Multihashing.functions is missing dbl-sha2-256 HOT 3
- Using SPHINCS+ sha256-256f in IPLD Graph Data HOT 1
- SHAKE digest size HOT 4
- Make sha3 an optional dependency
- The npm distribution is not transpiled to es5 HOT 1
- Using import() function for code splitting HOT 1
- feature: validation
- Add support for "identity" algorithm HOT 2
- Possible javascript digest fallbacks for insecure (HTTP) sites HOT 3
- Move from coveralls to codecov HOT 1
- Question? Bug? About `Multihashing` func HOT 1
- An in-range update of aegir is breaking the build 🚨 HOT 1
- add types for blakejs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-multihashing-async.