Asserts that the target has a length or size property equal to the given number. Works with arrays, strings, Maps, Sets, and any object with a length or size property.
The assert scope.
The expected length or size.
OptionalevalMsg: MsgSource
The message to display if the assertion fails.
import { assert } from "@nevware21/tripwire";
assert([1, 2, 3]).has.lengthOf(3); // Passes - array length is 3
assert("hello").has.lengthOf(5); // Passes - string length is 5
assert(new Map([["a", 1]])).has.lengthOf(1); // Passes - Map size is 1
assert(new Set([1, 2])).has.lengthOf(2); // Passes - Set size is 2
assert([1, 2]).has.lengthOf(3); // Fails - array length is 2, not 3
Export assertion functions