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

Function literalKeyOf

ark/schema/parse.ts:416–430  ·  view source on GitHub ↗
(v: unknown)

Source from the content-addressed store, hash-verified

414
415// objects are compared by reference, except dates, which units compare by value
416const literalKeyOf = (v: unknown): string =>
417 typeof v === "string" ? JSON.stringify(v)
418 : typeof v === "number" ?
419 Object.is(v, -0) ?
420 "-0"
421 : `${v}`
422 : typeof v === "bigint" ? `${v}n`
423 : isDate(v) ? dateKeyOf(v)
424 : (
425 (typeof v === "object" && v !== null) ||
426 typeof v === "function" ||
427 typeof v === "symbol"
428 ) ?
429 `$${nameOf(v)}`
430 : `${v}`
431
432const dateKeyOf = (v: Date): string => {
433 const time = timeOf(v)

Callers 2

nodeKeyOfFunction · 0.85
valueKeyOfFunction · 0.85

Calls 4

isDateFunction · 0.90
nameOfFunction · 0.90
dateKeyOfFunction · 0.85
isMethod · 0.80

Tested by

no test coverage detected