Give encode/decode functions more descriptive names

- `encode()`: Renamed to `int_to_base58()`.
- `decode()`: Renamed to `base58_to_int()`.
- Maintain aliases of old function names for backwards compatibility.
This commit is contained in:
2018-11-18 22:17:56 +00:00
parent 35dd6f57a1
commit 8eaae0b86a
3 changed files with 25 additions and 15 deletions

View File

@@ -31,7 +31,7 @@ function assertBase58Character(character) {
}
}
exports.encode = function(num) {
exports.int_to_base58 = exports.encode = function(num) {
let str = "";
let modulus;
@@ -48,7 +48,7 @@ exports.encode = function(num) {
return alphabet[num] + str;
};
exports.decode = function(str) {
exports.base58_to_int = exports.decode = function(str) {
assertString(str);
return [...str].reverse().reduce((num, character, index) => {