/** * Returns a new object which is a subject of the input, including only the specified properties. * Can be called with a single argument (array of props to pick), in which case it returns a partially * applied pick function. */ export function pick(props: Array): (input: U) => T; export function pick(input: U, props: Array): T; export function pick( inputOrProps: U | Array, maybeProps?: Array, ): T | ((input: U) => T) { if (Array.isArray(inputOrProps)) { return (input: U) => _pick(input, inputOrProps); } else { return _pick(inputOrProps, maybeProps || []); } } function _pick(input: U, props: Array): T { const output: any = {}; for (const prop of props) { output[prop] = input[prop]; } return output; }