Created
March 22, 2019 03:58
-
-
Save ariofrio/c2bf1178382f9484e1a3b930fbec7888 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function mapValues<A, B>( | |
obj: { [key: string]: A }, | |
f: (x: A) => B | |
): { [key: string]: B } { | |
const rv: { [key: string]: B } = {} | |
for (const key in obj) { | |
if (obj.hasOwnProperty(key)) { | |
rv[key] = f(obj[key]) | |
} | |
} | |
return rv | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment