isEmpty method for dict

commit_hash:f3e964657a07b8c6de490b7a7f105e9a5a3f1214
This commit is contained in:
4eb0da
2024-09-18 13:04:36 +03:00
parent ede6fc60cf
commit fd1aabb412
2 changed files with 12 additions and 2 deletions
@@ -101,6 +101,13 @@ function containsKey(_ext: EvalContext, dict: DictValue, key: StringValue): Bool
};
}
function isEmpty(_ext: EvalContext, dict: DictValue): BooleanValue {
return {
type: BOOLEAN,
value: Object.keys(dict.value).length ? 0 : 1
};
}
export function registerDict(): void {
const STRING_VARARG = {
type: STRING,
@@ -166,4 +173,5 @@ export function registerDict(): void {
registerMethod('getArray', [DICT, STRING_VARARG], getDictArray);
registerMethod('getDict', [DICT, STRING_VARARG], getDictDict);
registerMethod('containsKey', [DICT, STRING], containsKey);
registerMethod('isEmpty', [DICT], isEmpty);
}
@@ -486,7 +486,8 @@
}
],
"platforms": [
"android"
"android",
"web"
]
},
{
@@ -503,7 +504,8 @@
}
],
"platforms": [
"android"
"android",
"web"
]
}
]