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

Function checkedMember

ark/aot/shadow.ts:358–380  ·  view source on GitHub ↗
(
	pair: Pair,
	target: object,
	k: PropertyKey,
	observation = `reading ${String(k)}`
)

Source from the content-addressed store, hash-verified

356}
357
358const checkedMember = (
359 pair: Pair,
360 target: object,
361 k: PropertyKey,
362 observation = `reading ${String(k)}`
363): unknown => {
364 const value = inArktype(() => Reflect.get(target, k, target))
365 const read = outcomeOf(() =>
366 isUnbaked(pair.counterpart, k) ? undefined : (
367 (pair.counterpart as Record<PropertyKey, unknown>)[k]
368 )
369 )
370 if (value !== undefined && ("thrown" in read || read.value === undefined)) {
371 fail(
372 pair,
373 observation,
374 printable(typeof value),
375 "thrown" in read ? `throws ${thrownOf(read.thrown)}` : "undefined",
376 "since its validator lacks it"
377 )
378 }
379 return value
380}
381
382const hasOf =
383 (pair: Pair) =>

Callers 3

memberOfFunction · 0.85
hasOfFunction · 0.85
heldHandlerOfFunction · 0.85

Calls 8

printableFunction · 0.90
StringInterface · 0.85
inArktypeFunction · 0.85
thrownOfFunction · 0.85
outcomeOfFunction · 0.70
isUnbakedFunction · 0.70
failFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected