import omit from 'lodash/omit'; import pick from 'lodash/pick'; /** * Returns an array of 2 objects, * first, the result of calling `_.pick`, * second, the result of calling `_.omit` * * e.g. * ```js * const obj = { a: 'A', b: 'B', c: 'C', d: 'D' } * pickAndOmit(obj, ['a', 'b']) // [{a: "A", b: "B"}, {c: "C", d: "D"}] * ``` */ export const pickAndOmit = ( object: T, keys: Array, ): [Pick, Omit] => { const picked = pick(object, keys); const omitted = omit(object, keys); return [picked, omitted]; };