Coder Social home page Coder Social logo

Use base-x about js-multibase HOT 4 CLOSED

multiformats avatar multiformats commented on July 30, 2024
Use base-x

from js-multibase.

Comments (4)

daviddias avatar daviddias commented on July 30, 2024 1

@theobat thank you for this #7 ❤️

from js-multibase.

theobat avatar theobat commented on July 30, 2024

hi @diasdavid, it seems it can be any of each base's version since it takes the alphabet as an argument :

var BASE58_BITCOIN = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
var BASE58_FLICKR = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
var BASE58_RIPPLE = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'
var bs58btc = require('base-x')(BASE58_BITCOIN)
var bs58flickr = require('base-x')(BASE58_FLICKR)
var bs58ripple = require('base-x')(BASE58_RIPPLE)
// encode-decode with the alphabet you'd like

So I guess we only have to map the alphabets to the constants in Constants.js ?

from js-multibase.

daviddias avatar daviddias commented on July 30, 2024

@theobat awesome! Yeah, seems like that then, constants.js can be the human readable name, the short version and the encoder/decoder instance. Would you like to contribute with PR adding this?

Thank you for checking how to make this work :)

from js-multibase.

theobat avatar theobat commented on July 30, 2024

@diasdavid Sure! I'll try to open a PR today, but I thought it could be nice to use an object-oriented declaration of the Bases such as jbenet mentioned here. It won't be as useful as in Go but I think it would clarify the initialization. What do you think ?

Would be something like :

const constants = {
  base1: Base('1', '1'),
  base2: Base('0', '01'),
  base8: Base('7', '01234567'),
  // ... Base(code, alphabet) ... etc
}

from js-multibase.

Related Issues (20)

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.