UNPKG

typescript-immutable-utils

Version:

Type-safe immutability helpers for simple objects and arrays

12 lines (11 loc) 228 B
export function mapValues<K, T, R>( src: Map<K, T>, map: (value: T, key: K) => R, ): Map<K, R> { return new Map( Array.from( src.entries(), ([key, value]) => [key, map(value, key)] as [K, R], ), ); }