@nevware21/tripwire - v0.1.8
    Preparing search index...

    Function lengthFunc

    Export assertion functions

    • 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.

      Type Parameters

      • R

      Parameters

      • this: IAssertScope

        The assert scope.

      • length: number

        The expected length or size.

      • OptionalevalMsg: MsgSource

        The message to display if the assertion fails.

      Returns R

      • The assert scope.

      0.1.5

      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