Type Parameters
- const R extends UnknownRecord
- V2
Parameters
- record: R
- mapFn: (
value: R[keyof R],
key: ToString<RelaxedExclude<keyof R, symbol>>,
) => Optional<V2>
Returns FilteredRecord<
Readonly<
{ [K in string
| number
| symbol as K extends symbol ? never : K]: V2 },
>,
>
A new record holding only the kept entries, with mapped values
Transforms and drops entries in one pass: the callback returns
Optional.some(value)to keep an entry with a new value, orOptional.noneto drop it.Type Behavior: as with filter, the surviving keys are the keys of the source record made optional, and a record keyed by an index signature stays total. Unlike filter, every kept value takes the type the callback returns.
Optionalrather thanundefinedmarks the dropped entries, so a record whose values are legitimatelyundefinedstays expressible.Key handling: keys reach the callback the way
Object.entriesyields them, so a numeric key1arrives as'1'. Symbol-keyed properties are not enumerated byObject.entries; they are dropped from both the result and its type.