Created
February 29, 2020 05:37
-
-
Save shnam7/702bc3b84ea6a4e2c641be09bf4ac857 to your computer and use it in GitHub Desktop.
Typescript pick() function
This file contains hidden or 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
| /** pick */ | |
| export function pick<T, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K> { | |
| const ret: any = {}; | |
| keys.forEach(key => { ret[key] = obj[key]; }); | |
| return ret; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment