(operator: string, selector: string, from: number)
| 21 | value.replace(/\s+/g, " ").trim(); |
| 22 | |
| 23 | function findOperator(operator: string, selector: string, from: number) { |
| 24 | const start = selector.indexOf(operator, from); |
| 25 | |
| 26 | if (start < 0) { |
| 27 | return null; |
| 28 | } |
| 29 | |
| 30 | let index = start + operator.length; |
| 31 | |
| 32 | while (whitespaceRegex.test(selector[index] ?? "")) { |
| 33 | index += 1; |
| 34 | } |
| 35 | |
| 36 | const unmatchedOrMissingParenthesis: OperatorMatch = { |
| 37 | start, |
| 38 | end: index, |
| 39 | value: undefined, |
| 40 | }; |
| 41 | |
| 42 | if (selector[index] !== "(") { |
| 43 | return unmatchedOrMissingParenthesis; |
| 44 | } |
| 45 | |
| 46 | let depth = 1; |
| 47 | let cursor = index + 1; |
| 48 | |
| 49 | while (cursor < selector.length && depth > 0) { |
| 50 | if (selector[cursor] === "(") { |
| 51 | depth += 1; |
| 52 | } else if (selector[cursor] === ")") { |
| 53 | depth -= 1; |
| 54 | } |
| 55 | |
| 56 | cursor += 1; |
| 57 | } |
| 58 | |
| 59 | if (depth !== 0) { |
| 60 | return unmatchedOrMissingParenthesis; |
| 61 | } |
| 62 | |
| 63 | return { |
| 64 | start, |
| 65 | end: cursor, |
| 66 | value: selector.slice(index + 1, cursor - 1), |
| 67 | }; |
| 68 | } |
| 69 | |
| 70 | function extractOperators(operator: string, style: string) { |
| 71 | const selectors: string[] = []; |
no outgoing calls
no test coverage detected