API · Select

reject()

Drop values for which a synchronous predicate returns a truthy result.

Signature

reject(fn: (value: T, context: C) => unknown): Exstream<T, C>

Example

const active = exstream(accounts).reject((account) => account.disabled)

Parameters

fn

Type (value, context) => unknownRequired

Called once per successful value. Truthy means drop; falsy means emit. It is not awaited.

Behavior

reject(fn) is the inverse selection rule of filter(fn). It is synchronous, stable, one-to-zero-or-one, adds no queue, and propagates downstream pressure upstream. Retained values keep their record context. Existing record errors pass through without calling fn.

Errors

A thrown callback error becomes a contextual record error. A returned promise is truthy and therefore drops the value immediately; use asyncFilter() with an inverted predicate for asynchronous decisions.

Forms

stream.reject(predicate)
exstream.pipeline().reject(predicate)
exstream.reject(predicate, stream)
stream.through(exstream.reject(predicate))

filter(), compact(), asyncFilter()