Skip to content

Instantly share code, notes, and snippets.

@ariofrio
Created March 22, 2019 03:58
Show Gist options
  • Save ariofrio/c2bf1178382f9484e1a3b930fbec7888 to your computer and use it in GitHub Desktop.
Save ariofrio/c2bf1178382f9484e1a3b930fbec7888 to your computer and use it in GitHub Desktop.
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