mapDictionary()function

mapDictionary(dictionary: ImmutableDictionary<I>, transform: (value: I, ...args: A) => O, ...args: A): ImmutableDictionary<O>
ParamType
dictionaryImmutableDictionary<I>
The source dictionary. required
transform(value: I, ...args: A) => O
Function applied to each value to produce the output value. required
argsA
Additional arguments passed through to transform on every call. required
Return
ImmutableDictionary<O>
A new dictionary with the same keys and transformed values.

Transform the values of a dictionary into a new dictionary.

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

Examples

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