Giter VIP home page Giter VIP logo

Comments (5)

Gozala avatar Gozala commented on July 30, 2024 1

@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.

mikeal avatar mikeal commented on July 30, 2024

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.

Gozala avatar Gozala commented on July 30, 2024

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.

mikeal avatar mikeal commented on July 30, 2024

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.

Gozala avatar Gozala commented on July 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.