@epikodelabs/streamix / aggregates/src/public-api / some
Function: some()
some<
T>(predicate):Operator<T,boolean>
Defined in: projects/libraries/streamix/aggregates/src/lib/operators/some.ts:22
Creates a stream operator that tests if at least one value from the source stream satisfies a predicate.
This operator consumes the source stream and applies the provided predicate function to each value.
- If the
predicatereturns a truthy value for any element, the operator immediately emitstrueand then completes, effectively "short-circuiting" the evaluation. - If the source stream completes without the
predicateever returning a truthy value, the operator emitsfalse.
This is a "pull-based" equivalent of Array.prototype.some and is useful for validating data streams. The operator will emit only a single boolean value before it completes. Streams that never satisfy the predicate emit false (including empty sources).
Type Parameters
T
T = any
The type of the values in the source stream.
Parameters
predicate
(value, index) => MaybePromise<boolean>
The function to test each value. It receives the value and its index. It can be synchronous or asynchronous.
Returns
Operator<T, boolean>
An Operator instance that can be used in a stream's pipe method.