Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 1x 1x 2x 2x 2x 8x 8x 4x 8x | import { purry } from './purry'; export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; /** * Returns a partial copy of an object omitting the keys specified. * @param object the object * @param names the property names * @signature * R.omit(obj, names); * @example * R.omit({ a: 1, b: 2, c: 3, d: 4 }, ['a', 'd']) // => { b: 2, c: 3 } * @data_first * @category Object */ export function omit<T extends {}, K extends keyof T>( object: T, names: K[] ): Omit<T, K>; /** * Returns a partial copy of an object omitting the keys specified. * @param object the object * @param names the property names * @signature * R.omit(names)(obj); * @example * R.pipe({ a: 1, b: 2, c: 3, d: 4 }, R.omit(['a', 'd'])) // => { b: 2, c: 3 } * @data_last * @category Object */ export function omit<T extends {}, K extends keyof T>( names: K[] ): (object: T) => Omit<T, K>; export function omit() { return purry(_omit, arguments); } function _omit<T extends {}, K extends keyof T>( object: T, names: K[] ): Omit<T, K> { const set = new Set(names as string[]); return Object.entries(object).reduce( (acc, [name, value]) => { if (!set.has(name)) { acc[name] = value; } return acc; }, {} as any ) as Omit<T, K>; } |