Options
All
  • Public
  • Public/Protected
  • All
Menu

Module array/partition

Index

References

Functions

References

Renames and re-exports partition

Functions

  • partition<T>(fn: ArrPred<T>, list: ArrayLike<T>): [T[], T[]]
  • partition<T>(fn: ArrPred<T>): (list: ArrayLike<T>) => [T[], T[]]
  • Takes a predicate and a array and returns the pair of arrays of the same type of elements which do and do not satisfy, the predicate, respectively.

    example
     partition(includes('s'), ['sss', 'ttt', 'foo', 'bars']);
    //=> [ [ 'sss', 'bars' ], [ 'ttt', 'foo' ] ]

    Type parameters

    • T

    Parameters

    • fn: ArrPred<T>

      A predicate to determine which side the element belongs to.

    • list: ArrayLike<T>

    Returns [T[], T[]]

    An array, containing first the subset of elements that satisfy the predicate, and second the subset of elements that do not satisfy.

  • Takes a predicate and a array and returns the pair of arrays of the same type of elements which do and do not satisfy, the predicate, respectively.

    example
     partition(includes('s'), ['sss', 'ttt', 'foo', 'bars']);
    //=> [ [ 'sss', 'bars' ], [ 'ttt', 'foo' ] ]

    Type parameters

    • T

    Parameters

    • fn: ArrPred<T>

      A predicate to determine which side the element belongs to.

    Returns (list: ArrayLike<T>) => [T[], T[]]

    An array, containing first the subset of elements that satisfy the predicate, and second the subset of elements that do not satisfy.

      • (list: ArrayLike<T>): [T[], T[]]
      • Parameters

        • list: ArrayLike<T>

        Returns [T[], T[]]

Generated using TypeDoc