UNPKG

@queso/pick

Version:

Creates an object composed of the picked object properties.

17 lines (15 loc) 446 B
/** * Creates an object composed of the picked `object` properties. * @param object The source object. * @param paths The property paths to pick. * @category Object * @returns A new object composed of the picked `object` properties. * @example const obj = { a: 1, b: 2, c: 3 } pick(obj, 'a', 'c') // => { a: 1, c: 3 } */ export default function pick<T extends object, K extends keyof T>( object: T, ...paths: K[] ): Partial<Pick<T, K>>