UNPKG

jspurefix

Version:
51 lines 2.26 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const quick_fix_xml_file_parser_1 = require("../dictionary/parser/quickfix/quick-fix-xml-file-parser"); const repository_xml_parser_1 = require("../dictionary/parser/fix-repository/repository-xml-parser"); const fix_xsd_parser_1 = require("../dictionary/parser/fixml/fix-xsd-parser"); const config_1 = require("../config"); const path = require("path"); const fs = require("fs"); const root = path.join(__dirname, '../../'); function getDictPath(p) { const dictionary = require(path.join(root, 'data/dictionary.json')); return dictionary[p]; } exports.getDictPath = getDictPath; function getDefinitions(path, getLogger = config_1.makeEmptyLogger) { return __awaiter(this, void 0, void 0, function* () { let parser; const dp = getDictPath(path); if (dp) { path = dp.dict; } path = norm(path); if (fs.lstatSync(path).isDirectory() && path.indexOf('fixml') >= 0) { parser = new fix_xsd_parser_1.FixXsdParser(path, getLogger); } else if (fs.lstatSync(path).isDirectory()) { parser = new repository_xml_parser_1.RepositoryXmlParser(path, getLogger); } else { parser = new quick_fix_xml_file_parser_1.QuickFixXmlFileParser(path, getLogger); } return parser.parse(); }); } exports.getDefinitions = getDefinitions; function norm(p) { let f = p; if (!path.isAbsolute(p)) { f = path.join(root, f); } return f; } //# sourceMappingURL=dictionary-definitions.js.map