• Groups the elements into two arrays, depending on the provided function's truthiness for each element

    Example

    const users = [
    { user: 'barney', age: 36, active: false }, { user: 'fred', age: 40, active: true }
    ];
    partition(users, o => o.active); // [
    [{ 'user': 'fred', 'age': 40, 'active': true }],
    [{ 'user': 'barney', 'age': 36, 'active': false }]
    ]

    Type Parameters

    • T

    Parameters

    • arr: T[]
    • fn: ((value: T, index: number, array: T[]) => boolean)
        • (value: T, index: number, array: T[]): boolean
        • Parameters

          • value: T
          • index: number
          • array: T[]

          Returns boolean

    Returns [T[], T[]]

Generated using TypeDoc