UNPKG

fume-fhir-converter

Version:

FHIR-Utilized Mapping Engine - Community

32 lines 1.18 kB
"use strict"; /** * © Copyright Outburn Ltd. 2022-2024 All Rights Reserved * Project name: FUME-COMMUNITY */ Object.defineProperty(exports, "__esModule", { value: true }); exports.findClosingBrackets = void 0; const findClosingBrackets = (line, startPosition, carried) => { // line: a single line to search for closing brackets // startPosition: where to start from. this will be the index of original opening brackets, or 0 // openingCount: the number of opening brackets counted so far (carried from previous lines) // returns (-1 * depth) if not found, or the index of the closing brackets if found // TODO: ignore brackets that are inside quoted strings! let depth = carried; if (line === '') return -1 * depth; for (let i = startPosition; i < line.length; i++) { switch (line[i]) { case '(': depth++; break; case ')': if (--depth === 0) { return i; } break; } } return -1 * depth; }; exports.findClosingBrackets = findClosingBrackets; //# sourceMappingURL=findClosingBrackets.js.map