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

Method atIndex

ark/schema/structure/sequence.ts:344–357  ·  view source on GitHub ↗

the element that checks `data[index]`

(data: array, index: number)

Source from the content-addressed store, hash-verified

342
343 /** the element that checks `data[index]` */
344 protected atIndex(data: array, index: number): SequenceElement {
345 if (index < this.leading.length) return this.tuple[index]
346 const firstPostfixIndex = data.length - this.postLen
347 if (index >= firstPostfixIndex)
348 return { kind: "postfix", node: this.postfix![index - firstPostfixIndex] }
349 return {
350 kind: "variadic",
351 node:
352 this.variadic ??
353 throwInternalError(
354 `Unexpected attempt to access index ${index} on ${this}`
355 )
356 }
357 }
358
359 // minLength/maxLength should be checked by Intersection before either traversal
360 tAllows(data: array, ctx: InternalTraversal | AliasDepth): boolean {

Callers 3

tAllowsMethod · 0.95
tApplyMethod · 0.95
tfElemsMethod · 0.95

Calls 1

throwInternalErrorFunction · 0.90

Tested by

no test coverage detected