MCPcopy Create free account
hub / github.com/arktypeio/arktype / parseGenericParamName

Function parseGenericParamName

ark/type/generic.ts:366–383  ·  view source on GitHub ↗
(
	sc: Scanner,
	result: GenericParamDef[],
	ctx: BaseParseContext
)

Source from the content-addressed store, hash-verified

364type ParamsTerminator = WhitespaceChar | ","
365
366export const parseGenericParamName = (
367 sc: Scanner,
368 result: GenericParamDef[],
369 ctx: BaseParseContext
370): GenericParamDef[] => {
371 sc.skipSpace()
372 const name = shiftUntilTerminator(sc)
373 if (name === "") {
374 // if we've reached the end of the string and have parsed at least one
375 // param, return the valid result
376 if (sc.peek === "" && result.length) return result
377 return throwParseError(emptyGenericParameterMessage)
378 }
379
380 sc.skipSpace()
381
382 return _parseOptionalConstraint(sc, name, result, ctx)
383}
384
385type parseName<
386 unscanned extends string,

Callers 2

parseGenericParamsMethod · 0.90
_parseOptionalConstraintFunction · 0.85

Calls 4

shiftUntilTerminatorFunction · 0.90
throwParseErrorFunction · 0.90
_parseOptionalConstraintFunction · 0.85
skipSpaceMethod · 0.80

Tested by

no test coverage detected