UNPKG

@syncfusion/ej2-pdf

Version:

Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.

112 lines (111 loc) 3.49 kB
/** * Case-insensitive lookup table for certificate-related entries. * * @private */ var _PdfCertificateTable = /** @class */ (function () { function _PdfCertificateTable() { this._orig = new Map(); // eslint-disable-line this._orig = new Map(); this._keys = new Map(); } /** * Return all original keys currently stored in the table. * * @private * @returns {string[]} Array of stored keys. */ _PdfCertificateTable.prototype._getKeys = function () { var result = []; this._orig.forEach(function (value, key) { result.push(key); }); return result; }; /** * Clears all stored entries from both the original map and the internal key map. * * @private * @returns {void} nothing. */ _PdfCertificateTable.prototype._clear = function () { this._orig.clear(); this._keys.clear(); }; /** * Remove an entry by key (case-insensitive) and return its value. * * @private * @param {string} key - Key of the entry to remove. * @returns {any} The removed value or null when not found. */ _PdfCertificateTable.prototype._remove = function (key) { var lower = key.toLowerCase(); var actualKey; this._keys.forEach(function (mappedKey, tempKey) { if (tempKey.toLowerCase() === lower) { actualKey = mappedKey; } }); if (!actualKey) { return null; } this._keys.delete(lower); var value = this._orig.get(actualKey); this._orig.delete(actualKey); return value; }; /** * Retrieve a value by key (case-insensitive). * * @private * @param {string} key - Lookup key. * @returns {any} The stored value or null if missing. */ _PdfCertificateTable.prototype._get = function (key) { var lower = key.toLowerCase(); var actualKey; var entries = []; // eslint-disable-line this._keys.forEach(function (value, key) { entries.push([key, value]); }); for (var i = 0; i < entries.length; i++) { var _a = entries[i], tempKey = _a[0], mappedKey = _a[1]; if (tempKey.toLowerCase() === lower) { actualKey = mappedKey; break; } } return actualKey ? this._orig.get(actualKey) : null; }; /** * Set or replace a value for the given key (case-insensitive). * * @private * @param {string} key - The key to set. * @param {any} value - The value to associate with the key. * @returns {void} */ _PdfCertificateTable.prototype._setValue = function (key, value) { var lower = key.toLowerCase(); var existingKey; var entries = []; // eslint-disable-line this._keys.forEach(function (value, key) { entries.push([key, value]); }); for (var i = 0; i < entries.length; i++) { var _a = entries[i], tempKey = _a[0], mappedKey = _a[1]; if (tempKey.toLowerCase() === lower) { existingKey = mappedKey; break; } } if (existingKey) { this._orig.delete(existingKey); } this._keys.set(lower, key); this._orig.set(key, value); }; return _PdfCertificateTable; }()); export { _PdfCertificateTable };