add plain object check and omit helpers

This commit is contained in:
2017-02-28 14:45:43 -07:00
parent 5e0cc440ff
commit 64c1c90337
4 changed files with 99 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
export default function (obj) {
return (typeof obj === 'object' && !Array.isArray(obj) && obj !== null);
}

View File

@@ -0,0 +1,11 @@
import isPlainObject from './is_plain_object';
export default function (obj, props) {
if (!isPlainObject(obj)) return obj;
if (!Array.isArray(props)) props = [props];
const newObj = Object.assign({}, obj);
props.forEach(prop => delete newObj[prop]);
return newObj;
}