MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / balancedBody

Function balancedBody

javascript/selenium-webdriver/bidi_schema_diff_test.mjs:87–96  ·  view source on GitHub ↗

Slice the brace-balanced body following the `{` at `from` (exclusive of braces).

(ts, from)

Source from the content-addressed store, hash-verified

85
86/** Slice the brace-balanced body following the `{` at `from` (exclusive of braces). */
87function 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. */
99function stripObjectBodies(s) {

Callers 2

parseCddl2tsFunction · 0.85
expectedUnionFieldsFunction · 0.85

Calls 1

includesMethod · 0.80

Tested by

no test coverage detected