Asserts that the target starts with the expected members in order (consecutive from the beginning). Uses strict equality (===) for comparison. Both the target and expected values must conform to ArrayLikeOrSizedIterable but can be different concrete types.
The assert scope.
The expected starting sequence (must be an ArrayLikeOrSizedIterable).
OptionalevalMsg: MsgSource
The message to display if the assertion fails.
import { assert } from "@nevware21/tripwire";
assert([1, 2, 3, 4]).has.startsWithMembers([1, 2]); // Passes - starts with [1, 2]
assert([1, 2, 3, 4]).has.startsWithMembers([1, 2, 3]); // Passes - starts with [1, 2, 3]
assert([1, 2, 3, 4]).has.startsWithMembers([2, 3]); // Fails - doesn't start with [2, 3]
assert([1, 2, 3, 4]).has.startsWithMembers([1, 3]); // Fails - not consecutive from start
assert(new Set([1, 2, 3, 4])).has.startsWithMembers([1, 2]); // Passes - different types
Export assertion functions