schema: Convert _.find used as loop to for…of.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg
2020-02-07 20:29:01 -08:00
committed by Tim Abbott
parent 13b8bf830f
commit 29dbf8ec77

View File

@@ -37,19 +37,12 @@ exports.check_array = function (var_name, val, checker) {
return var_name + ' is not an array';
}
let msg;
for (const item of val) {
const msg = checker('item', item);
_.find(val, function (item) {
const res = checker('item', item);
if (res) {
msg = res;
return msg;
if (msg) {
return 'in ' + var_name + ' we found an item where ' + msg;
}
});
if (msg) {
return 'in ' + var_name + ' we found an item where ' + msg;
}
};