Created
October 6, 2023 15:59
-
-
Save olibooty/74d3b890bc5542e230b420d94bbddd1d to your computer and use it in GitHub Desktop.
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
| /** | |
| * | |
| * Selects elements from target object by provided keys | |
| */ | |
| export const pick = <T extends object, K extends keyof T = keyof T>( | |
| object: T, | |
| keys: K[] | |
| ): Pick<T, K> => { | |
| let output: any = {}; | |
| for (const key of keys) { | |
| if (key in object) { | |
| output[key] = object[key]; | |
| } | |
| } | |
| return output; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment