* Find the position after the matching close delimiter for an opening delimiter. * Assumes `content[openPos]` is the opening char (e.g. `{` or `[`). * Returns the index one past the matching close char, or -1 if unbalanced.
(
content: string,
openPos: number,
openChar = '{',
closeChar = '}'
)
| 171 | * Returns the index one past the matching close char, or -1 if unbalanced. |
| 172 | */ |
| 173 | function findMatchingClose( |
| 174 | content: string, |
| 175 | openPos: number, |
| 176 | openChar = '{', |
| 177 | closeChar = '}' |
| 178 | ): number { |
| 179 | let count = 1 |
| 180 | let pos = openPos + 1 |
| 181 | while (pos < content.length && count > 0) { |
| 182 | if (content[pos] === openChar) count++ |
| 183 | else if (content[pos] === closeChar) count-- |
| 184 | pos++ |
| 185 | } |
| 186 | return count === 0 ? pos : -1 |
| 187 | } |
| 188 | |
| 189 | interface TriggerInfo { |
| 190 | id: string |
no outgoing calls
no test coverage detected