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

Function readBetween

ark/aot/unwrite.ts:366–383  ·  view source on GitHub ↗
(
	code: string,
	start: number,
	end: number,
	tokens: Token[]
)

Source from the content-addressed store, hash-verified

364 /\s+|[\p{ID_Start}$_][\p{ID_Continue}$‌‍]*|\d[\p{ID_Continue}.]*|"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'|./suy
365
366const readBetween = (
367 code: string,
368 start: number,
369 end: number,
370 tokens: Token[]
371): void => {
372 between.lastIndex = start
373 while (between.lastIndex < end) {
374 const at = between.lastIndex
375 let [text] = between.exec(code)!
376 // a word may run past where the next named token starts
377 if (at + text.length > end) {
378 text = text.slice(0, end - at)
379 between.lastIndex = end
380 }
381 if (text.trim()) tokens.push({ start: at, end: at + text.length, text })
382 }
383}
384
385// what differs between two lists of tokens: each run of the base's, and the
386// run of the other's in its place

Callers 1

tokensOfFunction · 0.85

Calls 2

execMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected