Added isEmpty and isNotEmpty methods to ObjectUtils

pull/1846/head
mertsincan 2021-12-05 20:21:16 +03:00
parent 16c0e43024
commit 605424d3c3
2 changed files with 17 additions and 3 deletions

View File

@ -198,10 +198,22 @@ export default {
let kebapProp = prop.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
let propName = Object.prototype.hasOwnProperty.call(props, kebapProp) ? kebapProp : prop;
return ((vnode.type.props[prop].type === Boolean && props[propName] === '') ? true : props[propName]);
return ((vnode.type.props[prop].type === Boolean && props[propName] === '') ? true : props[propName]);
}
return null;
}
},
}
isEmpty(value) {
return (
value === null || value === undefined || value === '' ||
(Array.isArray(value) && value.length === 0) ||
(!(value instanceof Date) && typeof value === 'object' && Object.keys(value).length === 0)
);
},
isNotEmpty(value) {
return !this.isEmpty(value);
}
}

View File

@ -62,6 +62,8 @@ export declare class ObjectUtils {
static contains(value: any, list: any[]): boolean;
static insertIntoOrderedArray(item: any, index: number, arr: any[], sourceArr: any[]): void;
static removeAccents(str: any): string;
static isEmpty(value: any): boolean;
static isNotEmpty(value: any): boolean;
}
export declare namespace ZIndexUtils {