UNPKG

@crpt/react-utils

Version:

A useful kit for daily using

18 lines (16 loc) 661 B
import { isArray, isObjectLike, isPlainObject, isString, keys, omit } from 'lodash'; /** * @param {Array|Object|String} props */ export var makeBlacklist = function makeBlacklist(props) { return [isArray(props) && props.reduce(function (acc, value) { return isObjectLike(value) ? [].concat(acc, makeBlacklist(value)) : isString(value) && [].concat(acc, [value]); }, []), isPlainObject(props) && keys(props), isString(props) && [props]].find(Boolean); }; /** * @param {Object} target * @param {Array|Object|String} props */ export var omitProps = function omitProps(target, props) { return props ? omit(target, makeBlacklist(props)) : target; };