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

Function nearestOptionTo

ark/schema/config.ts:155–163  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

153
154// the option a mistyped one is nearest to, within two edits
155const nearestOptionTo = (name: string): string | undefined => {
156 let nearest: string | undefined
157 let fewest = 3
158 for (const option of [...Object.keys(optionNames), ...nodeKinds]) {
159 const edits = editsBetween(name.toLowerCase(), option.toLowerCase())
160 if (edits < fewest) [nearest, fewest] = [option, edits]
161 }
162 return nearest
163}
164
165const undeclaredKeyBehaviors = { reject: 1, delete: 1, ignore: 1 }
166

Callers 1

configureSchemaFunction · 0.85

Calls 1

editsBetweenFunction · 0.90

Tested by

no test coverage detected