Skip to content

Instantly share code, notes, and snippets.

@monkpit
Forked from kpittman-securus/keymap.ts
Created April 28, 2021 23:19
Show Gist options
  • Save monkpit/65c632c1f9d8725edbd8be3d170bed79 to your computer and use it in GitHub Desktop.
Save monkpit/65c632c1f9d8725edbd8be3d170bed79 to your computer and use it in GitHub Desktop.
const keymap = <T extends unknown, U extends object>(
object: U,
callback: (key: keyof U, index: number) => T
) => (Object.keys(object) as (keyof U)[]).map(callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment