mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
isEmpty method for dict
commit_hash:f3e964657a07b8c6de490b7a7f105e9a5a3f1214
This commit is contained in:
@@ -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"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user