MCPcopy Create free account
hub / github.com/TanStack/query / splitTopLevel

Function splitTopLevel

scripts/generate-docs.ts:454–475  ·  view source on GitHub ↗
(type: string, separator: string)

Source from the content-addressed store, hash-verified

452
453// Splits a type expression at a top-level separator, outside `<>`, `()`, `{}`, and `[]`.
454function splitTopLevel(type: string, separator: string) {
455 const parts: Array<string> = []
456 let depth = 0
457 let start = 0
458 for (let index = 0; index < type.length; index++) {
459 const char = type[index]!
460 if ('<({['.includes(char)) {
461 depth++
462 } else if (
463 ')}]'.includes(char) ||
464 (char === '>' && type[index - 1] !== '=')
465 ) {
466 depth--
467 } else if (depth === 0 && type.startsWith(separator, index)) {
468 parts.push(type.slice(start, index))
469 start = index + separator.length
470 index += separator.length - 1
471 }
472 }
473 parts.push(type.slice(start))
474 return parts.map((part) => part.trim()).filter(Boolean)
475}
476
477async function typePage(outputDir: string, name: string) {
478 for (const from of [`interfaces/${name}`, `type-aliases/${name}`]) {

Callers 1

basePagesOfTypeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected