UNPKG

@jovian/type-tools

Version:

TypeTools is a Typescript library for providing extensible tooling runtime validations and type helpers.

39 lines 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.base58Decode = exports.base58Encode = void 0; var charSet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'; var to_b58 = function (B, A) { var d = [], s = "", i, j, c, n; for (i in B) { j = 0, c = B[i]; s += c || s.length ^ i ? "" : 1; while (j in d || c) { n = d[j]; n = n ? n * 256 + c : c; c = n / 58 | 0; d[j] = n % 58; j++; } } while (j--) s += A[d[j]]; return s; }; var from_b58 = function (S, A) { var d = [], b = [], i, j, c, n; for (i in S) { j = 0, c = A.indexOf(S[i]); if (c < 0) return undefined; c || b.length ^ i ? i : b.push(0); while (j in d || c) { n = d[j]; n = n ? n * 58 + c : c; c = n >> 8; d[j] = n % 256; j++; } } while (j--) b.push(d[j]); return new Uint8Array(b); }; function base58Encode(data) { return to_b58(data, charSet); } exports.base58Encode = base58Encode; function base58Decode(data) { return from_b58(data, charSet); } exports.base58Decode = base58Decode; //# sourceMappingURL=base58.util.js.map