This repository has been archived by the owner on Aug 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: more encoding, errors, spec tests (#55)
- 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
- Loading branch information
1 parent
5ea2ce7
commit 613363b
Showing
19 changed files
with
572 additions
and
328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* eslint-disable no-console */ | ||
'use strict' | ||
const Benchmark = require('benchmark') | ||
const multibase = require('./src') | ||
|
||
const names = Object.keys(multibase.names) | ||
const suite = new Benchmark.Suite() | ||
const input = 'Decentralize everything!!' | ||
|
||
for (const enc of names) { | ||
suite.add(enc, () => { | ||
multibase.encode(enc, Buffer.from(input)) | ||
}) | ||
} | ||
|
||
suite | ||
.on('cycle', function (event) { | ||
console.log(String(event.target)) | ||
}) | ||
.on('complete', function () { | ||
console.log('Fastest is ' + this.filter('fastest').map('name')) | ||
}) | ||
.run({ async: true }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.