add plain object check and omit helpers
This commit is contained in:
11
src/helpers/object_omit.js
Normal file
11
src/helpers/object_omit.js
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user