Slice the brace-balanced body following the `{` at `from` (exclusive of braces).
(ts, from)
| 85 | |
| 86 | /** Slice the brace-balanced body following the `{` at `from` (exclusive of braces). */ |
| 87 | function balancedBody(ts, from) { |
| 88 | let depth = 1 |
| 89 | let i = from |
| 90 | while (i < ts.length && depth > 0) { |
| 91 | if (OPEN.includes(ts[i])) depth++ |
| 92 | else if (CLOSE.includes(ts[i])) depth-- |
| 93 | i++ |
| 94 | } |
| 95 | return { body: ts.slice(from, i - 1), end: i } |
| 96 | } |
| 97 | |
| 98 | /** Remove the contents of nested `{...}` blocks, keeping tokens outside them. */ |
| 99 | function stripObjectBodies(s) { |
no test coverage detected