@wpazderski/js-utils
    Preparing search index...

    Utility class for array operations.

    Index

    Constructors

    Methods

    • Checks if two arrays are equal in terms of their items and order.

      Type Parameters

      • T

      Parameters

      • array1: readonly T[]

        The first array.

      • array2: readonly T[]

        The second array.

      • Optionalcomparator: (a: T, b: T) => boolean

        Optional comparator function to compare items. If not provided, strict equality (===) is used.

      Returns boolean

      True if both arrays are equal, false otherwise.

    • Checks if two arrays are equal in terms of their items, regardless of order. Duplicates are handled, meaning that if an item appears multiple times in one array, it must appear the same number of times in the other array.

      Type Parameters

      • T

      Parameters

      • array1: readonly T[]

        The first array.

      • array2: readonly T[]

        The second array.

      • Optionalcomparator: (a: T, b: T) => boolean

        Optional comparator function to compare items. If not provided, strict equality (===) is used.

      Returns boolean

      True if both arrays are equal, false otherwise.

    • Returns items that are present in both arrays.

      Type Parameters

      • T

      Parameters

      • array1: readonly T[]

        The first array.

      • array2: readonly T[]

        The second array.

      • Optionalcomparator: (a: T, b: T) => boolean

        Optional comparator function to compare items. If not provided, strict equality (===) is used.

      Returns T[]

      An array of items that are present in both arrays.

    • Returns items in the first array that are not present in the second array.

      Type Parameters

      • T

      Parameters

      • array: readonly T[]

        The array to check for extra items.

      • expectedItems: readonly T[]

        The array of expected items.

      • Optionalcomparator: (a: T, b: T) => boolean

        Optional comparator function to compare items. If not provided, strict equality (===) is used.

      Returns T[]

      An array of items that are in the first array but not in the second array.

    • Returns items that are expected but missing from the first array.

      Type Parameters

      • T

      Parameters

      • array: readonly T[]

        The array to check for missing items.

      • expectedItems: readonly T[]

        The array of expected items.

      • Optionalcomparator: (a: T, b: T) => boolean

        Optional comparator function to compare items. If not provided, strict equality (===) is used.

      Returns T[]

      An array of items that are expected but not present in the first array.

    • Returns a new array with unique items from the input array.

      Type Parameters

      • T

      Parameters

      • array: readonly T[]

        The input array.

      • Optionalcomparator: (a: T, b: T) => boolean

        Optional comparator function to compare items. If not provided, strict equality (===) is used.

      Returns T[]

      A new array containing only unique items.