Skip to main content

Home > @jsplumbtoolkit/core > partition

partition() function

Partitions a list into two lists - one for which the supplied partitioner returns true (the left list), and the other, the right list, for which the supplied partitioner does not return true.

Signature:

export declare function partition<T, A extends T, B extends T>(l: ArrayLike<T>, partitioner: (candidate: T) => boolean): {
left: Array<A>;
right: Array<B>;
};

Parameters

ParameterTypeDescription
lArrayLike<T>List to partition
partitioner(candidate: T) => booleanFunction to use to partition the list.

Returns:

{ left: Array<A>; right: Array<B>; }