Lua truthiness fixes
parent
265aa8dab6
commit
b8835a07e2
|
@ -315,9 +315,12 @@ export class LuaTable implements ILuaSettable, ILuaGettable {
|
||||||
return this.arrayPart.length;
|
return this.arrayPart.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasKeys(): boolean {
|
empty(): boolean {
|
||||||
return !!(Object.keys(this.stringKeys).length > 0 ||
|
return (
|
||||||
this.arrayPart.length > 0 || (this.otherKeys && this.otherKeys.size > 0));
|
Object.keys(this.stringKeys).length === 0 &&
|
||||||
|
this.arrayPart.length === 0 &&
|
||||||
|
(this.otherKeys === null || this.otherKeys.size === 0)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
keys(): any[] {
|
keys(): any[] {
|
||||||
|
@ -700,7 +703,10 @@ export function luaTruthy(value: any): boolean {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (value instanceof LuaTable) {
|
if (value instanceof LuaTable) {
|
||||||
return value.hasKeys();
|
return value.empty();
|
||||||
|
}
|
||||||
|
if (value instanceof LuaMultiRes) {
|
||||||
|
return value.values.length > 0;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue