11 lines
243 B
TypeScript
11 lines
243 B
TypeScript
|
import _ from 'lodash';
|
||
|
|
||
|
export function filterByFields(data: any, fields: any = {}): any {
|
||
|
const {
|
||
|
only = Array.isArray(fields) ? fields : null,
|
||
|
except = []
|
||
|
} = fields;
|
||
|
|
||
|
return _.omit(only ? _.pick(data, only): data, except);
|
||
|
}
|