emvco-qr-sdk
Version:
A robust TypeScript SDK for decoding, validating, and processing EMVCo-compliant QR codes used in digital payment systems.
28 lines (27 loc) • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RawObjectMapperService = void 0;
const tlv_mapping_util_1 = require("../utils/mappers/tlv-mapping.util");
/**
* Service to map TLV entities into raw key/value objects using original tag codes.
* No naming strategy is applied.
*/
class RawObjectMapperService {
/**
* Converts a list of TLV entities into a plain object using raw tag values as keys.
*
* If subTags are found, it builds a nested object with raw subtag values as keys.
*
* @param tlvs - The TLV entities to convert.
* @returns A plain object representing the raw structure of the TLVs.
*/
static map(tlvs) {
const result = {};
for (const tlv of tlvs) {
const key = tlv.tag;
result[key] = (0, tlv_mapping_util_1.isTlvWithSubTags)(tlv) ? (0, tlv_mapping_util_1.mapSubTags)(tlv.tag, tlv.subTags) : tlv.value;
}
return result;
}
}
exports.RawObjectMapperService = RawObjectMapperService;