API · Transform

pluck()

Replace each input object with the value found at one property or nested field path.

Signature

pluck<K extends keyof T>(field: K): Exstream<T[K], C>
pluck<D = undefined>(field: string, defaultValue?: D): Exstream<unknown | D, C>

Example

exstream(users).pluck('profile.email', 'unknown@example.com')

Parameters

field

Type stringRequired

A direct key or dot/bracket path such as profile.email, items[0].sku, or rows["primary"].id. TypeScript infers exact types only for direct keys.

defaultValue

Type unknownDefault undefined

Returned when the path cannot be traversed or the final value is undefined. Existing values such as null, false, and 0 are preserved.

Behavior

pluck() is synchronous and is implemented as a map() with a precompiled getter. It emits one result per successful input, preserves order and context, adds no queue, and respects downstream pressure.

Errors

A non-string field is rejected when the operator is created. Inputs that cannot be traversed return defaultValue; existing record errors pass through unchanged.

Forms

The direct standalone form requires the default argument; use undefined when no fallback is wanted:

stream.pluck('profile.email', 'missing')
exstream.pipeline().pluck('profile.email', 'missing')
exstream.pluck('profile.email', undefined, stream)
stream.through(exstream.pluck('profile.email', 'missing'))

pick(), omit(), map()