Pick Object Fields By Condition
Creates a new object containing only the properties that satisfy a given condition.
pickObjectFieldsByCondition
The pickObjectFieldsByCondition function filters an object's properties by evaluating a predicate function (condition) against each key-value pair.
Function Signature
function pickObjectFieldsByCondition<T extends GenericObject>(
source: T,
condition: (key: keyof T, value: T[keyof T]) => boolean
): Partial<T>Parameters
source(T): The source object to filter.condition((key: keyof T, value: T[keyof T]) => boolean): A function evaluated for each property. Returntrueto keep the property, orfalseto omit it.
Return Value
Partial<T>: A new object containing only the properties that satisfy the condition.
Example Usage
playground.ts
Notes
- This function operates on top-level properties only. It does not recursively inspect nested objects.
- It is non-destructive and returns a new object without mutating the original
source.
Aliases
The following aliases can be used for the pickObjectFieldsByCondition function:
pickFieldsByCondition
Last updated: Sun, Jun 14, 2026 07:06:16AM (UTC)
