UNPKG

@signumjs/core

Version:

Principal package with functions and models for building Signum Network applications.

31 lines 1 kB
"use strict"; /** * Original work Copyright (c) 2021 Signum Network */ Object.defineProperty(exports, "__esModule", { value: true }); exports.tokenizeReedSolomonAddress = void 0; /** * @internal * Tokenizes a Reed-Solomon address * @param address The address in Reed-Solomon format * @return object with prefix, address and eventual extension * @throws Error in case of invalid format * */ const tokenizeReedSolomonAddress = (address) => { const tokens = address.split('-'); const isExtended = tokens.length === 6; if (tokens.length < 5 || tokens.length > 6) { throw new Error(`Invalid Reed-Solomon Address Format: ${address}`); } const prefix = tokens[0]; const extension = isExtended ? tokens[5] : ''; const rs = `${tokens[1]}-${tokens[2]}-${tokens[3]}-${tokens[4]}`; return { prefix, rs, extension }; }; exports.tokenizeReedSolomonAddress = tokenizeReedSolomonAddress; //# sourceMappingURL=tokenizeReedSolomonAddress.js.map