• Partitions an array of items based on a set of filtering functions. Each item is matched against the filtering functions, and if a match is found, the item is added to the corresponding collection

    If no match is found, the item is added to the orphans collection.

    On conflicts, the key order of the filtering functions in the object is used to determine priority.

    Type Parameters

    • TItems extends any[]

      The type of the input array.

    • TPartitionFunctions extends MapGroupEntries<TItems>

      The type of the filtering functions.

    Parameters

    • items: TItems

      The array of items to be partitioned.

    • fns: TPartitionFunctions

      The filtering functions used for partitioning.

    Returns {
        orphans: TItems;
        result: {
            [K in keyof TPartitionFunctions]: Exclude<ReturnType<TPartitionFunctions[K]>, undefined>[]
        };
    }

    • An object containing the partitioned collections and the orphans collection.
    • orphans: TItems
    • result: {
          [K in keyof TPartitionFunctions]: Exclude<ReturnType<TPartitionFunctions[K]>, undefined>[]
      }

Generated using TypeDoc