js: Convert _.without to filter or other logic.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2020-02-26 00:27:28 -08:00 committed by Tim Abbott
parent e2290ef0de
commit 57cc5cb25a
4 changed files with 17 additions and 18 deletions

View File

@ -2,8 +2,6 @@
const {strict: assert} = require("assert");
const _ = require("lodash");
const {$t} = require("../zjsunit/i18n");
const {mock_jquery, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
@ -27,7 +25,7 @@ function make_tab(i) {
self.removeClass = (c) => {
const tokens = self.class.trim().split(/ +/);
self.class = _.without(tokens, c).join(" ");
self.class = tokens.filter((token) => token !== c).join(" ");
};
self.hasClass = (c) => {

View File

@ -2,8 +2,6 @@
const {strict: assert} = require("assert");
const _ = require("lodash");
const {$t} = require("../zjsunit/i18n");
const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
@ -635,12 +633,17 @@ test_ui("on_events", ({override_rewire, mock_template}) => {
// Any of the blur_exceptions trigger blur event.
for (const class_name of blur_event_classes) {
const handler = $(user_group_selector).get_on_handler("blur", class_name);
const blur_exceptions = _.without(
[".pill-container", ".name", ".description", ".input", ".delete"],
class_name,
);
for (const blur_exception of blur_exceptions) {
for (const blur_exception of [
".pill-container",
".name",
".description",
".input",
".delete",
]) {
if (blur_exception === class_name) {
continue;
}
api_endpoint_called = false;
fake_this.closest = (class_name) => {
if (class_name === blur_exception || class_name === user_group_selector) {

View File

@ -1,6 +1,5 @@
import md5 from "blueimp-md5";
import {format, utcToZonedTime} from "date-fns-tz";
import _ from "lodash";
import * as typeahead from "../shared/js/typeahead";
@ -548,7 +547,8 @@ export function pm_with_operand_ids(operand) {
// If your email is included in a PM group with other people, just ignore it
if (persons.length > 1) {
persons = _.without(persons, people_by_user_id_dict.get(my_user_id));
const my_user = people_by_user_id_dict.get(my_user_id);
persons = persons.filter((person) => person !== my_user);
}
if (!persons.every(Boolean)) {

View File

@ -222,13 +222,11 @@ export function populate_user_groups() {
return true;
}
const blur_exceptions = _.without(
[".pill-container", ".name", ".description", ".input", ".delete"],
except_class,
);
if ($(event.relatedTarget).closest(`#user-groups #${CSS.escape(data.id)}`).length) {
return blur_exceptions.some(
(class_name) => $(event.relatedTarget).closest(class_name).length,
return [".pill-container", ".name", ".description", ".input", ".delete"].some(
(class_name) =>
class_name !== except_class &&
$(event.relatedTarget).closest(class_name).length,
);
}
return false;