UNPKG

modem-pay-iso

Version:

A javascript library for messaging in iso 8583 messaging format.

35 lines (34 loc) 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tools_1 = require("../tools"); /** * Assembles the Bitmap of fields 0-127 for the ISO 8583 message in the Main class Instance. * @method assembleBitmap * @memberof module:Bitmap-Assemble */ function assembleBitmap() { if (this.checkMTI()) { const upper = this.hasSpecialFields ? 193 : 128; let _map = new Uint8Array(upper); const fields = Object.keys(this.Msg); // Support backward compat if (this.includesSecondaryBitmap || !this.optionalSecondaryBitmap) { _map[0] = 1; } else if (!this.includesSecondaryBitmap) { _map = _map.slice(0, 64); } // construct 128 bit mask for (let i = 0; i < fields.length; i++) { const field = parseInt(fields[i], 10); if (field > 1) { _map[field - 1] = 1; } } this.bitmaps = _map; return _map; } else return tools_1.default.toErrorObject('bitmap error, iso message type undefined or invalid'); } exports.default = assembleBitmap;