Skip to content
This repository has been archived by the owner on Aug 24, 2021. It is now read-only.

Export the names and codes as object (instead of array) #49

Closed
KrishnaPG opened this issue Dec 1, 2019 · 0 comments · Fixed by #55
Closed

Export the names and codes as object (instead of array) #49

KrishnaPG opened this issue Dec 1, 2019 · 0 comments · Fixed by #55

Comments

@KrishnaPG
Copy link

Currently constants.names and constants.codes are exported as Arrays, which means looking-up if a particular name or code exists requires scanning the whole array.

exports.names = Object.freeze(Object.keys(constants.names))
exports.codes = Object.freeze(Object.keys(constants.codes))

Please export those name and codes as objects directly so that callers can lookup directly, and also get the name from the code, and vice-versa (since the object structure has rich info on relations between them, which is lost when Object.keys is performed).

Something like below:

 exports.names = Object.freeze(constants.names)
 exports.codes = Object.freeze(constants.codes)
hugomrdias added a commit that referenced this issue Jun 9, 2020
- adds support for all the encodings in https://github.com/multiformats/multibase/blob/master/multibase.csv
-  better errors showing the invalid chars and inputs
- `names` and `codes` exports the full object that maps names/codes to base instances
  - you can use these to get the unprefixed base encoder/decoder
- two new methods exported, `encoding` and `encodingFromData`
  - you can use these to get the unprefixed base encoder/decoder
- adds all the spec tests https://github.com/multiformats/multibase/tree/master/tests
- its also faster check benchmarks below

This module now only uses 2 base encoding implementations, 1 generalised rfc4648 and 1 generalised btc like.

closes #49 
closes #38 
closes #46
closes #53
closes #26 

BREAKING CHANGE: `names` and `codes` export the full object that maps names/codes to base instances instead of just the keys
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant