UNPKG

emvco-qr-sdk

Version:

A robust TypeScript SDK for decoding, validating, and processing EMVCo-compliant QR codes used in digital payment systems.

30 lines (29 loc) 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isTlvWithSubTags = isTlvWithSubTags; exports.mapSubTags = mapSubTags; /** * Checks whether a TLV entity contains valid subTags. * * @param tlv - The TLV entity to check. * @returns True if the TLV contains at least one subTag, false otherwise. */ function isTlvWithSubTags(tlv) { return !!(tlv.subTags && tlv.subTags.length > 0); } /** * Maps an array of subTags into a key-value object, using an optional name resolver. * * @param parentTag - The parent TLV tag. * @param subTags - The list of subtag TLV entities. * @param resolveSubtagName - Optional resolver for naming subtags. * @returns An object mapping each subtag to its value. */ function mapSubTags(parentTag, subTags, resolveSubtagName) { const result = {}; for (const sub of subTags) { const key = resolveSubtagName ? resolveSubtagName(parentTag, sub.tag) : sub.tag; result[key] = sub.value; } return result; }