Add additional check for array.isEmpty

This commit is contained in:
Ray 2024-12-31 23:08:59 +00:00
parent 993a2eef96
commit 8cfb52d2a6
2 changed files with 8 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "LiteRyzJS", "name": "LiteRyzJS",
"version": "0.1.0.424", "version": "0.1.0.455",
"devDependencies": { "devDependencies": {
"css-loader": "^7.1.2", "css-loader": "^7.1.2",
"sass": "^1.77.8", "sass": "^1.77.8",

View File

@ -4,6 +4,10 @@
* @returns Boolean True, if array is empty or not an array type. * @returns Boolean True, if array is empty or not an array type.
*/ */
Array.isEmpty = function(value) { Array.isEmpty = function(value) {
if (typeof(value) == "undefined") {
return true;
}
const dataType = Object.getDataType(value); const dataType = Object.getDataType(value);
if (dataType != "array") { if (dataType != "array") {
return true; return true;
@ -161,11 +165,11 @@ Array.prototype.create = function (length, value) {
}; };
Array.prototype.distinct = function() { Array.prototype.distinct = function() {
this = this.filter((obj, index, self) => let result = this.filter((obj, index, self) =>
index === self.findIndex((x) => JSON.stringify(x) === JSON.stringify(obj)) index === self.findIndex((x) => JSON.stringify(x) === JSON.stringify(obj))
); );
return this; return result;
} }
/** /**