Documents for @litert/utils-array
    Preparing search index...

    Interface IDeduplicateFn

    • Quickly deduplicate an array and return the result.

      If the elements in the array are all basic types, the function will process them with simple === comparison.

      If the elements in the array are complex types, the function will not compare them with === by default. Instead, a makeKey function must be provided to map the elements to values that can be compared with ===. In this case, if you ensure that the elements are actually comparable with ===, you can set the makeKey function to null to use the default. For example, there are multiple references to the same object in the array, and you want to deduplicate them, you can set the makeKey function to null to use the default === simply.

      Type Parameters

      • T extends IBasicType

      Parameters

      • items: readonly T[]

        The array to be deduplicated

      • OptionalmakeKey: (v: T) => any

        The function to map items to a unique value for deduplication.

      Returns T[]

    • Quickly deduplicate an array and return the result.

      If the elements in the array are all basic types, the function will process them with simple === comparison.

      If the elements in the array are complex types, the function will not compare them with === by default. Instead, a makeKey function must be provided to map the elements to values that can be compared with ===. In this case, if you ensure that the elements are actually comparable with ===, you can set the makeKey function to null to use the default. For example, there are multiple references to the same object in the array, and you want to deduplicate them, you can set the makeKey function to null to use the default === simply.

      Type Parameters

      • T extends IAdvancedType

      Parameters

      • items: readonly T[]

        The array to be deduplicated

      • makeKey: null | ((v: T) => any)

        The function to map items to a unique value for deduplication.

      Returns T[]