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

Function isSequenceSimulated

ark/schema/node.ts:1773–1793  ·  view source on GitHub ↗
(
	l: Sequence.Node,
	r: Sequence.Node,
	s: SimulationState
)

Source from the content-addressed store, hash-verified

1771}
1772
1773const isSequenceSimulated = (
1774 l: Sequence.Node,
1775 r: Sequence.Node,
1776 s: SimulationState
1777): boolean => {
1778 const minLength = Math.max(l.preLen + l.postLen, r.preLen + r.postLen)
1779 const maxLength = Math.min(
1780 l.maxLength ?? Number.POSITIVE_INFINITY,
1781 r.maxLength ?? Number.POSITIVE_INFINITY,
1782 Math.max(l.leading.length, r.leading.length) +
1783 Math.max(l.postLen, r.postLen) +
1784 1
1785 )
1786 for (let length = minLength; length <= maxLength; length++) {
1787 for (let i = 0; i < length; i++) {
1788 if (!isSimulated(elementAt(l, length, i), elementAt(r, length, i), s))
1789 return false
1790 }
1791 }
1792 return true
1793}
1794
1795const elementAt = (node: Sequence.Node, length: number, i: number): BaseNode =>
1796 i < node.leading.length ? node.leading[i].node

Callers 1

isSimulatedFunction · 0.85

Calls 2

isSimulatedFunction · 0.85
elementAtFunction · 0.85

Tested by

no test coverage detected