mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-04-20 20:38:06 +00:00
44 lines
777 B
JavaScript
44 lines
777 B
JavaScript
import { obj } from '../util';
|
|
|
|
const { isPlainObject } = obj;
|
|
|
|
/**
|
|
* 过滤 undefined 类型的值
|
|
* @param {*} obj
|
|
* @return {Object}
|
|
*/
|
|
export function filterUndefinedValue(object) {
|
|
if (!isPlainObject(object)) {
|
|
return object;
|
|
}
|
|
|
|
const obj = {};
|
|
|
|
Object.keys(object).forEach(key => {
|
|
const value = object[key];
|
|
|
|
if (value !== undefined) {
|
|
obj[key] = value;
|
|
}
|
|
});
|
|
|
|
return obj;
|
|
}
|
|
|
|
/**
|
|
* 从 obj 中去除 subObj
|
|
* @param {*} obj
|
|
* @param {*} subObj
|
|
* @return {Object}
|
|
*/
|
|
export function stripObject(obj, subObj) {
|
|
const newObject = {};
|
|
|
|
Object.keys(obj).forEach(key => {
|
|
if (!(key in subObj)) {
|
|
newObject[key] = obj[key];
|
|
}
|
|
});
|
|
return newObject;
|
|
}
|