UNPKG

sec-edgar-api

Version:

Fetch and parse SEC earnings reports and other filings. Useful for financial analysis.

36 lines (35 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MetaLinksParser = void 0; /** * Parse MetaLinks.json */ var MetaLinksParser = /** @class */ (function () { function MetaLinksParser() { } MetaLinksParser.prototype.parse = function (xml) { if (!xml) return null; try { var numberKeys_1 = new Set(['decimals', 'order']); var booleanKeys_1 = new Set(['xsiNil', 'isDefault']); return JSON.parse(xml.substring(xml.indexOf('{'), xml.lastIndexOf('}') + 1), function (key, value) { if (numberKeys_1.has(key) && !isNaN(value)) { return Number(value); } if (booleanKeys_1.has(key)) { if (value === 'false') return false; if (value === 'true') return true; } return value; }); } catch (_a) { return null; } }; return MetaLinksParser; }()); exports.MetaLinksParser = MetaLinksParser;