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

Function insert

ark/type/deferred.ts:482–488  ·  view source on GitHub ↗
(sorted: string[], term: string)

Source from the content-addressed store, hash-verified

480/** adds a term in order, since a union's say nothing, or false if it's a repeat, whose
481 * union could reduce to what isn't scanned */
482const insert = (sorted: string[], term: string) => {
483 let i = sorted.length
484 while (i && sorted[i - 1] > term) i--
485 if (sorted[i - 1] === term) return false
486 sorted.splice(i, 0, term)
487 return true
488}
489
490const insertAll = (terms: string[], f: Facts) =>
491 f.terms ? f.terms.every(t => insert(terms, t)) : insert(terms, f.key)

Callers 1

insertAllFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected