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

Function serializePrimitive

ark/util/primitive.ts:24–32  ·  view source on GitHub ↗
(
	value: value
)

Source from the content-addressed store, hash-verified

22let lastSerialized: string
23
24export const serializePrimitive = <value extends SerializablePrimitive>(
25 value: value
26): serializePrimitive<value> =>
27 (typeof value === "string" ?
28 value === lastString ?
29 lastSerialized
30 : (lastSerialized = JSON.stringify((lastString = value)))
31 : typeof value === "bigint" ? `${value}n`
32 : `${value}`) as never
33
34export type serializePrimitive<value extends SerializablePrimitive> =
35 value extends string ? `"${value}"`

Callers 8

serializeFunction · 0.90
unitKeyOfFunction · 0.90
defaultValueSerializerFunction · 0.90
compileSerializedValueFunction · 0.90
serializeFunction · 0.90
printableFunction · 0.90
printKindFunction · 0.90
stringifyUnquotedFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected