Skip to content

Documentation / @eventkit/base / partition

Function: partition()

Call Signature

ts
function partition<T, S>(predicate): PartitionOperatorFunction<T, S>

Returns an array with two observables that act as a split of the source observable; one with values that satisfy the predicate, and another with values that don't satisfy the predicate.

Type Parameters

Type Parameter
T
S

Parameters

ParameterTypeDescription
predicate(value, index) => value is SA function that evaluates each value emitted by the source observable. If it returns true, the value is emitted on the first observable in the returned array, if false the value is emitted on the second observable in the array. The index parameter is the number i for the i-th source emission that has happened since the subscription, starting from 0.

Returns

PartitionOperatorFunction<T, S>

Call Signature

ts
function partition<T>(predicate): PartitionOperatorFunction<T>

Returns an array with two observables that act as a split of the source observable; one with values that satisfy the predicate, and another with values that don't satisfy the predicate.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
predicate(value, index) => booleanA function that evaluates each value emitted by the source observable. If it returns true, the value is emitted on the first observable in the returned array, if false the value is emitted on the second observable in the array. The index parameter is the number i for the i-th source emission that has happened since the subscription, starting from 0.

Returns

PartitionOperatorFunction<T>

Call Signature

ts
function partition<T>(predicate): PartitionOperatorFunction<T, TruthyTypesOf<T>>

Returns an array with two observables that act as a split of the source observable; one with values that satisfy the predicate, and another with values that don't satisfy the predicate.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
predicateBooleanConstructorA function that evaluates each value emitted by the source observable. If it returns true, the value is emitted on the first observable in the returned array, if false the value is emitted on the second observable in the array. The index parameter is the number i for the i-th source emission that has happened since the subscription, starting from 0.

Returns

PartitionOperatorFunction<T, TruthyTypesOf<T>>

Released under the MIT License.