Function partition

  • Creates an array of elements split into two groups, the first of which contains elements predicate returns truthy for, the second of which contains elements predicate returns falsey for.

    Contribution to minified bundle size, when it is the only function imported:

    • Lodash: 16,447 bytes
    • Micro-dash: 333 bytes

    Type Parameters

    • T
    • O

    Parameters

    • array: Nil | T
    • predicate: ValueNarrowingIteratee<ValuesType<T>, O>

    Returns [IfCouldBe<ValuesType<T>, O, Narrow<ValuesType<T>, O>[], []>, Exclude<ValuesType<T>, O> extends never
        ? []
        : Exclude<ValuesType<T>, O>[]]

  • Type Parameters

    • T

    Parameters

    • array: Nil | T
    • predicate: ValueIteratee<ValuesType<T>, any>

    Returns [ValuesType<T>[], ValuesType<T>[]]