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 | 44x 44x 44x 626x 587x 44x | /**
* Performs a key comparison between two objects, deleting from the first where
* the keys exist in the second
*
* Can be used to remove unwanted component prop values. For example:
*
* ```jsx
* render() {
* const { children, className, ...props } = this.props;
*
* return (
* <div
* {...objectKeyFilter(props, Item.propTypes)}
* className={classNames('dp-item', className)}
* >
* {children}
* </div>
* )
* }
* ```
*
* @param {Object} obj1
* @param {Object} obj2
* @returns {*}
*/
export function objectKeyFilter(obj1, obj2) {
const obj2Keys = Object.keys(obj2);
const newProps = Object.assign({}, obj1);
Object.keys(newProps)
.filter(key => obj2Keys.indexOf(key) !== -1)
.forEach(key => delete newProps[key]);
return newProps;
}
|