mirror of https://github.com/zulip/zulip.git
js: Convert _.all(a, …), _.every(a, …) to a.every(…).
And convert the corresponding function expressions to arrow style while we’re here. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
70ff164f89
commit
cdd774b790
|
@ -215,9 +215,7 @@ function filter_emojis() {
|
|||
|
||||
for (const emoji_dict of emojis) {
|
||||
for (const alias of emoji_dict.aliases) {
|
||||
const match = _.every(search_terms, function (search_term) {
|
||||
return alias.includes(search_term);
|
||||
});
|
||||
const match = search_terms.every(search_term => alias.includes(search_term));
|
||||
if (match) {
|
||||
search_results.push(_.extend({}, emoji_dict, {name: alias}));
|
||||
break; // We only need the first matching alias per emoji.
|
||||
|
|
|
@ -572,7 +572,7 @@ Filter.prototype = {
|
|||
// build JavaScript code in a string and then eval() it.
|
||||
|
||||
return function (message) {
|
||||
return _.all(operators, function (term) {
|
||||
return operators.every(term => {
|
||||
let ok = message_matches_search_term(message, term.operator, term.operand);
|
||||
if (term.negated) {
|
||||
ok = !ok;
|
||||
|
|
|
@ -162,7 +162,7 @@ exports.user_ids_string_to_emails_string = function (user_ids_string) {
|
|||
return person && person.email;
|
||||
});
|
||||
|
||||
if (!_.all(emails)) {
|
||||
if (!emails.every(Boolean)) {
|
||||
blueslip.warn('Unknown user ids: ' + user_ids_string);
|
||||
return;
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ exports.reply_to_to_user_ids_string = function (emails_string) {
|
|||
return person && person.user_id;
|
||||
});
|
||||
|
||||
if (!_.all(user_ids)) {
|
||||
if (!user_ids.every(Boolean)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ exports.email_list_to_user_ids_string = function (emails) {
|
|||
return person && person.user_id;
|
||||
});
|
||||
|
||||
if (!_.all(user_ids)) {
|
||||
if (!user_ids.every(Boolean)) {
|
||||
blueslip.warn('Unknown emails: ' + emails);
|
||||
return;
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ exports.update_email_in_reply_to = function (reply_to, user_id, new_email) {
|
|||
|
||||
const persons = emails.map(email => people_dict.get(email.trim()));
|
||||
|
||||
if (!_.all(persons)) {
|
||||
if (!persons.every(Boolean)) {
|
||||
return reply_to;
|
||||
}
|
||||
|
||||
|
@ -494,7 +494,7 @@ exports.pm_with_operand_ids = function (operand) {
|
|||
persons = _.without(persons, people_by_user_id_dict.get(my_user_id));
|
||||
}
|
||||
|
||||
if (!_.all(persons)) {
|
||||
if (!persons.every(Boolean)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -643,7 +643,7 @@ exports.is_valid_email_for_compose = function (email) {
|
|||
|
||||
exports.is_valid_bulk_emails_for_compose = function (emails) {
|
||||
// Returns false if at least one of the emails is invalid.
|
||||
return _.every(emails, function (email) {
|
||||
return emails.every(email => {
|
||||
if (!exports.is_valid_email_for_compose(email)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -804,9 +804,7 @@ exports.build_person_matcher = function (query) {
|
|||
return true;
|
||||
}
|
||||
|
||||
return _.all(termlet_matchers, function (matcher) {
|
||||
return matcher(user);
|
||||
});
|
||||
return termlet_matchers.every(matcher => matcher(user));
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -166,9 +166,7 @@ exports.is_subscriber_subset = function (sub1, sub2) {
|
|||
if (sub1.subscribers && sub2.subscribers) {
|
||||
const sub2_set = sub2.subscribers;
|
||||
|
||||
return _.every(Array.from(sub1.subscribers.keys()), (key) => {
|
||||
return sub2_set.has(key);
|
||||
});
|
||||
return Array.from(sub1.subscribers.keys()).every(key => sub2_set.has(key));
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -451,9 +449,7 @@ exports.update_calculated_fields = function (sub) {
|
|||
};
|
||||
|
||||
exports.all_subscribed_streams_are_in_home_view = function () {
|
||||
return _.every(exports.subscribed_subs(), function (sub) {
|
||||
return !sub.is_muted;
|
||||
});
|
||||
return exports.subscribed_subs().every(sub => !sub.is_muted);
|
||||
};
|
||||
|
||||
exports.home_view_stream_names = function () {
|
||||
|
|
|
@ -38,7 +38,7 @@ const tictactoe_data_holder = function () {
|
|||
return square_values[i];
|
||||
}
|
||||
|
||||
return lines.some(line_won) || _.all(board, filled);
|
||||
return lines.some(line_won) || board.every(filled);
|
||||
}
|
||||
|
||||
self.get_widget_data = function () {
|
||||
|
|
|
@ -13,9 +13,7 @@ exports.eq_array = (a, b, eq) => {
|
|||
return false;
|
||||
}
|
||||
|
||||
return _.all(a, (item, i) => {
|
||||
return eq(item, b[i]);
|
||||
});
|
||||
return a.every((item, i) => eq(item, b[i]));
|
||||
};
|
||||
|
||||
exports.ul = (opts) => {
|
||||
|
|
Loading…
Reference in New Issue