mapProps()function

mapProps(obj: I, transform: (prop: Prop<I>, ...args: A) => Value<O>, ...args: A): O
ParamType
objI
The source object. required
transform(prop: Prop<I>, ...args: A) => Value<O>
Function applied to each [key, value] prop to produce the output value. required
argsA
Additional arguments passed through to transform on every call. required
Return
O
A new object with the same keys and transformed values.

Transform the values of an object's props into a new object.

  • Keys are preserved; each prop entry is passed to transform to produce its new value.

Examples

mapProps({ a: 1, b: 2 }, ([, v]) => v * 2) // { a: 2, b: 4 }