Skip to content

Instantly share code, notes, and snippets.

@jtmthf
Created September 24, 2020 23:17
Show Gist options
  • Select an option

  • Save jtmthf/8577d6653a98b532f30704f2471fabc4 to your computer and use it in GitHub Desktop.

Select an option

Save jtmthf/8577d6653a98b532f30704f2471fabc4 to your computer and use it in GitHub Desktop.
export const pick = <
T extends Record<keyof unknown, unknown>,
K extends keyof T
>(
object: T,
paths: readonly K[],
): Pick<T, K> =>
Object.assign({}, ...paths.map((path) => ({ [path]: object[path] })));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment