From 2a70c11c5f3e7386064ebb5498b4687906e0ca29 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 1 Mar 2023 16:58:25 -0800 Subject: [PATCH] eslint: Fix unicorn/prefer-spread. This was initially disabled for IE/Babel-related reasons that no longer apply. Signed-off-by: Anders Kaseorg --- .eslintrc.json | 1 - web/shared/src/poll_data.js | 2 +- web/shared/src/typeahead.ts | 2 +- web/src/bot_data.js | 2 +- web/src/buddy_data.js | 2 +- web/src/color_data.ts | 2 +- web/src/compose_validate.js | 2 +- web/src/composebox_typeahead.js | 2 +- web/src/drafts.js | 2 +- web/src/emoji_picker.js | 2 +- web/src/filter.js | 4 +-- web/src/hash_util.js | 2 +- web/src/hotspots.js | 2 +- web/src/huddle_data.js | 2 +- web/src/lazy_set.ts | 2 +- web/src/linkifiers.js | 2 +- web/src/markdown.js | 2 +- web/src/message_events.js | 4 +-- web/src/message_fetch.js | 2 +- web/src/message_flags.js | 2 +- web/src/message_list_data.js | 12 +++---- web/src/message_list_view.js | 19 +++++----- web/src/message_user_ids.ts | 2 +- web/src/peer_data.js | 4 +-- web/src/people.js | 6 ++-- web/src/pill_typeahead.js | 6 ++-- web/src/popovers.js | 2 +- web/src/portico/desktop-login.js | 2 +- web/src/presence.js | 2 +- web/src/reactions.js | 2 +- web/src/realm_playground.js | 4 +-- web/src/recent_senders.js | 4 +-- web/src/recent_topics_data.js | 4 +-- web/src/recent_topics_ui.js | 4 +-- web/src/rtl.js | 32 +++++++++-------- web/src/search_suggestion.js | 4 +-- web/src/server_events.js | 4 +-- web/src/server_events_dispatch.js | 2 +- web/src/settings_config.ts | 31 ++++++++-------- web/src/settings_org.js | 4 +-- web/src/settings_playgrounds.js | 2 +- web/src/settings_user_groups_legacy.js | 4 +-- web/src/starred_messages.js | 4 +-- web/src/stats/stats.js | 2 +- web/src/stream_create_subscribers_data.js | 4 +-- web/src/stream_data.js | 12 +++---- web/src/stream_edit_subscribers.js | 4 +-- web/src/stream_pill.js | 4 +-- web/src/stream_settings_data.js | 2 +- web/src/stream_sort.js | 13 +++---- web/src/stream_topic_history.js | 4 +-- web/src/todo_widget.js | 2 +- web/src/topic_list.js | 8 ++--- web/src/typeahead_helper.js | 10 +++--- web/src/typing_data.js | 2 +- web/src/typing_events.js | 2 +- web/src/unread.js | 16 ++++----- web/src/user_group_create_members_data.js | 4 +-- web/src/user_group_edit.js | 2 +- web/src/user_group_edit_members.js | 8 ++--- web/src/user_group_pill.js | 11 +++--- web/src/user_groups.ts | 4 +-- web/src/util.ts | 2 +- web/tests/components.test.js | 2 +- web/tests/compose_pm_pill.test.js | 2 +- web/tests/composebox_typeahead.test.js | 4 +-- web/tests/filter.test.js | 36 +++++++++---------- web/tests/fold_dict.test.js | 25 +++++++------ web/tests/lib/zblueslip.js | 2 +- web/tests/lib/zjquery.js | 2 +- web/tests/linkifiers.test.js | 2 +- web/tests/pill_typeahead.test.js | 6 ++-- web/tests/recent_topics.test.js | 18 +++++----- web/tests/settings_org.test.js | 4 +-- web/tests/settings_user_groups_legacy.test.js | 2 +- web/tests/typeahead_helper.test.js | 8 ++--- web/tests/widgetize.test.js | 2 +- 77 files changed, 218 insertions(+), 216 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index dab1b59c29..b493cd93fd 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -116,7 +116,6 @@ "unicorn/numeric-separators-style": "off", "unicorn/prefer-module": "off", "unicorn/prefer-node-protocol": "off", - "unicorn/prefer-spread": "off", "unicorn/prefer-ternary": "off", "unicorn/prefer-top-level-await": "off", "unicorn/prevent-abbreviations": "off", diff --git a/web/shared/src/poll_data.js b/web/shared/src/poll_data.js index 5d9e9e9407..8399884b88 100644 --- a/web/shared/src/poll_data.js +++ b/web/shared/src/poll_data.js @@ -65,7 +65,7 @@ export class PollData { const options = []; for (const [key, obj] of this.key_to_option) { - const voters = Array.from(obj.votes.keys()); + const voters = [...obj.votes.keys()]; const current_user_vote = voters.includes(this.me); options.push({ diff --git a/web/shared/src/typeahead.ts b/web/shared/src/typeahead.ts index 9794c9f687..185e867070 100644 --- a/web/shared/src/typeahead.ts +++ b/web/shared/src/typeahead.ts @@ -147,7 +147,7 @@ export function triage( } } return { - matches: exactMatch.concat(beginswithCaseSensitive.concat(beginswithCaseInsensitive)), + matches: [...exactMatch, ...beginswithCaseSensitive, ...beginswithCaseInsensitive], rest: noMatch, }; } diff --git a/web/src/bot_data.js b/web/src/bot_data.js index 06f6352bdf..3d4e53c839 100644 --- a/web/src/bot_data.js +++ b/web/src/bot_data.js @@ -23,7 +23,7 @@ const services = new Map(); const services_fields = ["base_url", "interface", "config_data", "service_name", "token"]; export function all_user_ids() { - return Array.from(bots.keys()); + return [...bots.keys()]; } export function add(bot) { diff --git a/web/src/buddy_data.js b/web/src/buddy_data.js index c89f2d3b8b..d7b67b0d86 100644 --- a/web/src/buddy_data.js +++ b/web/src/buddy_data.js @@ -292,7 +292,7 @@ function filter_user_ids(user_filter_text, user_ids) { const user_id_dict = people.filter_people_by_search_terms(persons, search_terms); - return Array.from(user_id_dict.keys()); + return [...user_id_dict.keys()]; } function get_filtered_user_id_list(user_filter_text) { diff --git a/web/src/color_data.ts b/web/src/color_data.ts index f6dacb41aa..04cb86d738 100644 --- a/web/src/color_data.ts +++ b/web/src/color_data.ts @@ -35,7 +35,7 @@ const stream_colors = [ export const colors = _.shuffle(stream_colors); export function reset(): void { - unused_colors = colors.slice(); + unused_colors = [...colors]; } reset(); diff --git a/web/src/compose_validate.js b/web/src/compose_validate.js index d8cd9f9f8f..2669ae26e4 100644 --- a/web/src/compose_validate.js +++ b/web/src/compose_validate.js @@ -141,7 +141,7 @@ export function warn_if_mentioning_unsubscribed_user(mentioned) { `#compose_banners .${compose_banner.CLASSNAMES.recipient_not_subscribed}`, ); - const existing_invites = Array.from($existing_invites_area, (user_row) => + const existing_invites = [...$existing_invites_area].map((user_row) => Number.parseInt($(user_row).data("user-id"), 10), ); diff --git a/web/src/composebox_typeahead.js b/web/src/composebox_typeahead.js index 659a0e3cf8..f38eab526b 100644 --- a/web/src/composebox_typeahead.js +++ b/web/src/composebox_typeahead.js @@ -466,7 +466,7 @@ export function get_person_suggestions(query, opts) { persons = muted_users.filter_muted_users(persons); if (opts.want_broadcast) { - persons = persons.concat(broadcast_mentions()); + persons = [...persons, ...broadcast_mentions()]; } return persons.filter((item) => query_matches_person(query, item)); diff --git a/web/src/drafts.js b/web/src/drafts.js index 97af94ef08..635c0d4d1a 100644 --- a/web/src/drafts.js +++ b/web/src/drafts.js @@ -641,7 +641,7 @@ export function launch() { $("#draft_overlay").css("opacity"); open_overlay(); - set_initial_element(formatted_narrow_drafts.concat(formatted_other_drafts)); + set_initial_element([...formatted_narrow_drafts, ...formatted_other_drafts]); setup_event_handlers(); } diff --git a/web/src/emoji_picker.js b/web/src/emoji_picker.js index b82656f797..760a7e4060 100644 --- a/web/src/emoji_picker.js +++ b/web/src/emoji_picker.js @@ -122,7 +122,7 @@ export function rebuild_catalog() { const catalog = new Map(); catalog.set( "Custom", - Array.from(realm_emojis.keys(), (realm_emoji_name) => + [...realm_emojis.keys()].map((realm_emoji_name) => emoji.emojis_by_name.get(realm_emoji_name), ), ); diff --git a/web/src/filter.js b/web/src/filter.js index 2108b4bdf9..64b7ec37dd 100644 --- a/web/src/filter.js +++ b/web/src/filter.js @@ -947,7 +947,7 @@ export class Filter { return util.strcmp(a, b); }; - return term_types.slice().sort(compare); + return [...term_types].sort(compare); } static operator_to_prefix(operator, negated) { @@ -1060,7 +1060,7 @@ export class Filter { } return "unknown operator"; }); - return parts.concat(more_parts).join(", "); + return [...parts, ...more_parts].join(", "); } static describe(operators) { diff --git a/web/src/hash_util.js b/web/src/hash_util.js index ae7415c1c5..2c3464fa45 100644 --- a/web/src/hash_util.js +++ b/web/src/hash_util.js @@ -160,7 +160,7 @@ export function group_edit_url(group) { export function search_public_streams_notice_url(operators) { const public_operator = {operator: "streams", operand: "public"}; - return operators_to_hash([public_operator].concat(operators)); + return operators_to_hash([public_operator, ...operators]); } export function parse_narrow(hash) { diff --git a/web/src/hotspots.js b/web/src/hotspots.js index fc56ffcb3c..dfbb13e8e2 100644 --- a/web/src/hotspots.js +++ b/web/src/hotspots.js @@ -252,7 +252,7 @@ export function close_hotspot_icon(elem) { function close_read_hotspots(new_hotspots) { const unwanted_hotspots = _.difference( - Array.from(HOTSPOT_LOCATIONS.keys()), + [...HOTSPOT_LOCATIONS.keys()], new_hotspots.map((hotspot) => hotspot.name), ); diff --git a/web/src/huddle_data.js b/web/src/huddle_data.js index bd75aebbd4..82f1d1476d 100644 --- a/web/src/huddle_data.js +++ b/web/src/huddle_data.js @@ -23,7 +23,7 @@ export function process_loaded_messages(messages) { } export function get_huddles() { - let huddles = Array.from(huddle_timestamps.keys()); + let huddles = [...huddle_timestamps.keys()]; huddles = _.sortBy(huddles, (huddle) => huddle_timestamps.get(huddle)); return huddles.reverse(); } diff --git a/web/src/lazy_set.ts b/web/src/lazy_set.ts index 4cf759f72b..c1a8abf533 100644 --- a/web/src/lazy_set.ts +++ b/web/src/lazy_set.ts @@ -71,7 +71,7 @@ export class LazySet { } map(f: (v: number, k: number) => T): T[] { - return Array.from(this.keys(), f); + return [...this.keys()].map((v, k) => f(v, k)); } has(v: number): boolean { diff --git a/web/src/linkifiers.js b/web/src/linkifiers.js index 2148a63347..da613dad09 100644 --- a/web/src/linkifiers.js +++ b/web/src/linkifiers.js @@ -33,7 +33,7 @@ function python_to_js_linkifier(pattern, url) { // JS regexes only support i (case insensitivity) and m (multiline) // flags, so keep those and ignore the rest if (match) { - const py_flags = match[1].split(""); + const py_flags = match[1]; for (const flag of py_flags) { if ("im".includes(flag)) { diff --git a/web/src/markdown.js b/web/src/markdown.js index 6e68aeedc5..936d4e0b59 100644 --- a/web/src/markdown.js +++ b/web/src/markdown.js @@ -486,7 +486,7 @@ function handleTex(tex, fullmatch) { export function parse({raw_content, helper_config}) { function get_linkifier_regexes() { - return Array.from(helper_config.get_linkifier_map().keys()); + return [...helper_config.get_linkifier_map().keys()]; } function disable_markdown_regex(rules, name) { diff --git a/web/src/message_events.js b/web/src/message_events.js index 75b647b310..c1f2bfb9dd 100644 --- a/web/src/message_events.js +++ b/web/src/message_events.js @@ -217,7 +217,7 @@ export function update_messages(events) { if (msg.edit_history === undefined) { msg.edit_history = []; } - msg.edit_history = [edit_history_entry].concat(msg.edit_history); + msg.edit_history = [edit_history_entry, ...msg.edit_history]; } any_message_content_edited = true; @@ -312,7 +312,7 @@ export function update_messages(events) { if (msg.edit_history === undefined) { msg.edit_history = []; } - msg.edit_history = [edit_history_entry].concat(msg.edit_history); + msg.edit_history = [edit_history_entry, ...msg.edit_history]; } msg.last_edit_timestamp = event.edit_timestamp; diff --git a/web/src/message_fetch.js b/web/src/message_fetch.js index 84fa4fd5c5..8aa9e53e62 100644 --- a/web/src/message_fetch.js +++ b/web/src/message_fetch.js @@ -197,7 +197,7 @@ export function load_messages(opts, attempt = 1) { } else { let operators = opts.msg_list.data.filter.public_operators(); if (page_params.narrow !== undefined) { - operators = operators.concat(page_params.narrow); + operators = [...operators, ...page_params.narrow]; } data.narrow = JSON.stringify(operators); } diff --git a/web/src/message_flags.js b/web/src/message_flags.js index 24f11176f5..5b7fec0625 100644 --- a/web/src/message_flags.js +++ b/web/src/message_flags.js @@ -53,7 +53,7 @@ export const send_read = (function () { start = _.throttle(server_request, 1000); function add(messages) { - queue = queue.concat(messages); + queue = [...queue, ...messages]; start(); } diff --git a/web/src/message_list_data.js b/web/src/message_list_data.js index 3242851b2a..2416ccee57 100644 --- a/web/src/message_list_data.js +++ b/web/src/message_list_data.js @@ -337,10 +337,10 @@ export class MessageListData { const viewable_messages = this.unmuted_messages(messages); - this._all_items = messages.concat(this._all_items); + this._all_items = [...messages, ...this._all_items]; this._all_items.sort((a, b) => a.id - b.id); - this._items = viewable_messages.concat(this._items); + this._items = [...viewable_messages, ...this._items]; this._items.sort((a, b) => a.id - b.id); this._add_to_hash(messages); @@ -351,8 +351,8 @@ export class MessageListData { // Caller should have already filtered const viewable_messages = this.unmuted_messages(messages); - this._all_items = this._all_items.concat(messages); - this._items = this._items.concat(viewable_messages); + this._all_items = [...this._all_items, ...messages]; + this._items = [...this._items, ...viewable_messages]; this._add_to_hash(messages); return viewable_messages; @@ -362,8 +362,8 @@ export class MessageListData { // Caller should have already filtered const viewable_messages = this.unmuted_messages(messages); - this._all_items = messages.concat(this._all_items); - this._items = viewable_messages.concat(this._items); + this._all_items = [...messages, ...this._all_items]; + this._items = [...viewable_messages, ...this._items]; this._add_to_hash(messages); return viewable_messages; diff --git a/web/src/message_list_view.js b/web/src/message_list_view.js index 6a1c2172f0..8af98491d8 100644 --- a/web/src/message_list_view.js +++ b/web/src/message_list_view.js @@ -541,9 +541,10 @@ export class MessageListView { ) { first_msg_container.include_sender = false; } - first_group.message_containers = first_group.message_containers.concat( - second_group.message_containers, - ); + first_group.message_containers = [ + ...first_group.message_containers, + ...second_group.message_containers, + ]; return true; } @@ -626,7 +627,7 @@ export class MessageListView { message_actions.rerender_groups.push(second_group); } message_actions.prepend_groups = new_message_groups; - this._message_groups = new_message_groups.concat(this._message_groups); + this._message_groups = [...new_message_groups, ...this._message_groups]; } else { if (was_joined) { // rerender the last message @@ -642,7 +643,7 @@ export class MessageListView { } } message_actions.append_groups = new_message_groups; - this._message_groups = this._message_groups.concat(new_message_groups); + this._message_groups = [...this._message_groups, ...new_message_groups]; } return message_actions; @@ -787,7 +788,7 @@ export class MessageListView { const new_message_groups = this.build_message_groups(message_containers, this.table_name); const message_actions = this.merge_message_groups(new_message_groups, where); - let new_dom_elements = []; + const new_dom_elements = []; let $rendered_groups; let $dom_messages; let $last_message_row; @@ -808,7 +809,7 @@ export class MessageListView { }); $dom_messages = $rendered_groups.find(".message_row"); - new_dom_elements = new_dom_elements.concat($rendered_groups); + new_dom_elements.push($rendered_groups); this._post_process($dom_messages); @@ -857,7 +858,7 @@ export class MessageListView { $last_group_row.append($dom_messages); condense.condense_and_collapse($dom_messages); - new_dom_elements = new_dom_elements.concat($dom_messages); + new_dom_elements.push($dom_messages); } // Add new message groups to the end @@ -872,7 +873,7 @@ export class MessageListView { }); $dom_messages = $rendered_groups.find(".message_row"); - new_dom_elements = new_dom_elements.concat($rendered_groups); + new_dom_elements.push($rendered_groups); this._post_process($dom_messages); diff --git a/web/src/message_user_ids.ts b/web/src/message_user_ids.ts index 74ed1b0a80..418c512faf 100644 --- a/web/src/message_user_ids.ts +++ b/web/src/message_user_ids.ts @@ -18,7 +18,7 @@ export function clear_for_testing(): void { } export function user_ids(): number[] { - return Array.from(user_set); + return [...user_set]; } export function add_user_id(user_id: number): void { diff --git a/web/src/peer_data.js b/web/src/peer_data.js index 0d7733ccfb..0e9ece0890 100644 --- a/web/src/peer_data.js +++ b/web/src/peer_data.js @@ -39,7 +39,7 @@ export function is_subscriber_subset(stream_id1, stream_id2) { const sub1_set = get_user_set(stream_id1); const sub2_set = get_user_set(stream_id2); - return Array.from(sub1_set.keys()).every((key) => sub2_set.has(key)); + return [...sub1_set.keys()].every((key) => sub2_set.has(key)); } export function potential_subscribers(stream_id) { @@ -86,7 +86,7 @@ export function get_subscribers(stream_id) { // want an array of user_ids who are subscribed to a stream. const subscribers = get_user_set(stream_id); - return Array.from(subscribers.keys()); + return [...subscribers.keys()]; } export function set_subscribers(stream_id, user_ids) { diff --git a/web/src/people.js b/web/src/people.js index 058f3c9a8a..3bbf0409e2 100644 --- a/web/src/people.js +++ b/web/src/people.js @@ -864,7 +864,7 @@ export function filter_all_users(pred) { export function get_realm_users() { // includes humans and bots from your realm - return Array.from(active_user_dict.values()); + return [...active_user_dict.values()]; } export function get_active_human_ids() { @@ -915,11 +915,11 @@ export function get_active_human_count() { export function get_active_user_ids() { // This includes active users and active bots. - return Array.from(active_user_dict.keys()); + return [...active_user_dict.keys()]; } export function get_non_active_realm_users() { - return Array.from(non_active_user_dict.values()); + return [...non_active_user_dict.values()]; } export function is_cross_realm_email(email) { diff --git a/web/src/pill_typeahead.js b/web/src/pill_typeahead.js index 9f12824357..3322dce8dc 100644 --- a/web/src/pill_typeahead.js +++ b/web/src/pill_typeahead.js @@ -44,7 +44,7 @@ export function set_up($input, pills, opts) { } if (include_user_groups) { - source = source.concat(user_group_pill.typeahead_source(pills)); + source = [...source, ...user_group_pill.typeahead_source(pills)]; } if (include_users) { @@ -52,9 +52,9 @@ export function set_up($input, pills, opts) { // If user_source is specified in opts, it // is given priority. Otherwise we use // default user_pill.typeahead_source. - source = source.concat(opts.user_source()); + source = [...source, ...opts.user_source()]; } else { - source = source.concat(user_pill.typeahead_source(pills)); + source = [...source, ...user_pill.typeahead_source(pills)]; } } return source; diff --git a/web/src/popovers.js b/web/src/popovers.js index 3f9bd6bc62..b5327425fc 100644 --- a/web/src/popovers.js +++ b/web/src/popovers.js @@ -490,7 +490,7 @@ function show_user_group_info_popover(element, group, message) { const args = { group_name: group.name, group_description: group.description, - members: sort_group_members(fetch_group_members(Array.from(group.members))), + members: sort_group_members(fetch_group_members([...group.members])), }; $elt.popover({ placement: calculate_info_popover_placement(popover_size, $elt), diff --git a/web/src/portico/desktop-login.js b/web/src/portico/desktop-login.js index 6ebd3fa893..3205526099 100644 --- a/web/src/portico/desktop-login.js +++ b/web/src/portico/desktop-login.js @@ -43,7 +43,7 @@ async function decrypt_manual() { ? window.electron_bridge.decrypt_clipboard(1) : await decrypt_manual(); - const keyHex = Array.from(key, (b) => b.toString(16).padStart(2, "0")).join(""); + const keyHex = [...key].map((b) => b.toString(16).padStart(2, "0")).join(""); window.open( (window.location.search ? window.location.search + "&" : "?") + "desktop_flow_otp=" + diff --git a/web/src/presence.js b/web/src/presence.js index 0d9aa49413..1689755e23 100644 --- a/web/src/presence.js +++ b/web/src/presence.js @@ -41,7 +41,7 @@ export function get_status(user_id) { } export function get_user_ids() { - return Array.from(presence_info.keys()); + return [...presence_info.keys()]; } export function status_from_raw(raw) { diff --git a/web/src/reactions.js b/web/src/reactions.js index cd64f89ce1..07ba0dedef 100644 --- a/web/src/reactions.js +++ b/web/src/reactions.js @@ -403,7 +403,7 @@ export function get_emojis_used_by_user_for_message_id(message_id) { export function get_message_reactions(message) { set_clean_reactions(message); - return Array.from(message.clean_reactions.values()); + return [...message.clean_reactions.values()]; } export function set_clean_reactions(message) { diff --git a/web/src/realm_playground.js b/web/src/realm_playground.js index f3072f03fe..fc5fa69e13 100644 --- a/web/src/realm_playground.js +++ b/web/src/realm_playground.js @@ -54,7 +54,7 @@ export function get_pygments_typeahead_list_for_composebox() { const playground_pygment_langs = [...map_language_to_playground_info.keys()]; const generated_pygment_langs = Object.keys(generated_pygments_data.langs); - return playground_pygment_langs.concat(generated_pygment_langs); + return [...playground_pygment_langs, ...generated_pygment_langs]; } // This gets the candidate list for showing autocomplete in settings when @@ -78,7 +78,7 @@ export function get_pygments_typeahead_list_for_settings(query) { } for (const [key, values] of map_pygments_pretty_name_to_aliases) { - language_labels.set(key, key + " (" + Array.from(values).join(", ") + ")"); + language_labels.set(key, key + " (" + values.join(", ") + ")"); } return language_labels; diff --git a/web/src/recent_senders.js b/web/src/recent_senders.js index 88d22a41ad..3c85220a4d 100644 --- a/web/src/recent_senders.js +++ b/web/src/recent_senders.js @@ -31,7 +31,7 @@ export class IdTracker { max_id() { if (this._cached_max_id === undefined) { - this._cached_max_id = _.max(Array.from(this.ids)); + this._cached_max_id = _.max([...this.ids]); } return this._cached_max_id || -1; } @@ -208,7 +208,7 @@ export function get_topic_recent_senders(stream_id, topic) { return list2.max_id() - list1.max_id(); } - const sorted_senders = Array.from(sender_dict.entries()).sort(by_max_message_id); + const sorted_senders = [...sender_dict.entries()].sort(by_max_message_id); const recent_senders = []; for (const item of sorted_senders) { recent_senders.push(item[0]); diff --git a/web/src/recent_topics_data.js b/web/src/recent_topics_data.js index 6a413bf300..3cf351f543 100644 --- a/web/src/recent_topics_data.js +++ b/web/src/recent_topics_data.js @@ -43,9 +43,7 @@ export function process_message(msg) { function get_sorted_topics() { // Sort all recent topics by last message time. - return new Map( - Array.from(topics.entries()).sort((a, b) => b[1].last_msg_id - a[1].last_msg_id), - ); + return new Map([...topics.entries()].sort((a, b) => b[1].last_msg_id - a[1].last_msg_id)); } export function get() { diff --git a/web/src/recent_topics_ui.js b/web/src/recent_topics_ui.js index dac3a22d19..bd3814cd87 100644 --- a/web/src/recent_topics_ui.js +++ b/web/src/recent_topics_ui.js @@ -103,7 +103,7 @@ export function clear_for_tests() { } export function save_filters() { - ls.set(ls_key, Array.from(filters)); + ls.set(ls_key, [...filters]); } export function set_default_focus() { @@ -784,7 +784,7 @@ export function complete_rerender() { } // Show topics list - const mapped_topic_values = Array.from(get().values()).map((value) => value); + const mapped_topic_values = [...get().values()]; if (topics_widget) { topics_widget.replace_list_data(mapped_topic_values); diff --git a/web/src/rtl.js b/web/src/rtl.js index 4959fc902f..5598d54d2b 100644 --- a/web/src/rtl.js +++ b/web/src/rtl.js @@ -48,17 +48,18 @@ const digits = * character of the range, and the last character of the range. * All ranges are concatenated together and stored here. */ -const rl_ranges = convert_from_raw( - digits, - 2, - 'fIfIf}f}g0g0g3g3g6g6g8g"g,g,g/g/g;g;g~hKh?h[h^j1jhjijqjrjCjYj!j~krlplBm2mcmdmimJmOmOmYmYm#m#m*nknooP|j|j', -).concat( - convert_from_raw( +const rl_ranges = [ + ...convert_from_raw( + digits, + 2, + 'fIfIf}f}g0g0g3g3g6g6g8g"g,g,g/g/g;g;g~hKh?h[h^j1jhjijqjrjCjYj!j~krlplBm2mcmdmimJmOmOmYmYm#m#m*nknooP|j|j', + ), + ...convert_from_raw( digits, 3, '7S)7S)7S+7S>7S@7YZ7Y#7!n7!U7!(7!*7!+7#07$O7}U81%81(84g84k84k84n84r84w84+84/84<84>86Y86"87Q87Y8gv8g"8k=e)]e,fe,ne-De-Le|je|mf0f', ), -); +]; /** * Ranges of strong left-to-right characters. * @@ -66,18 +67,19 @@ const rl_ranges = convert_from_raw( * character of the range, and the last character of the range. * All ranges are concatenated together and stored here. */ -const lr_ranges = convert_from_raw( - digits, - 2, - '0$0}151u1<1<1|1|2222282u2w2!2#7Q7T7Z7:7;80848e8e9Q9T9W9$9&9+9.9.9:b1b3cOcWfBfDfEp7pZp"p"p$p(p;p>p@p]q0q9qcqEqGr7r9rcrhrorqrJrMrZr#r*r,r:r=sHsJsMsPsSsVsWs!s#s%t3t6t8tatktnt=t?t]t}t}u1u4u6upusuEuGuUuWvnvpvqvsvsvxvEvGvNvPvZv#w1w3w"w$w:wAgAiA>A^B0B2BlBoCxCzCFCJCJCLDIDKDLDTDWDYD%D/E>E@E[E}E}F1FbFiF~G2GsGuGuGwGwGCG{HbHbHhHhHkHoHAHAH-H?H[J0J5J5JcJcJfJgJjJHJKJNJRJ(J-J^J`J{J~K4K6KkKmR>R]SDSOTXTZ!T!V!@!^#h#l#N#R#?#]$l$o$`$}$}%6%d%f%g%s%y%A%A%C%T%%%+%`(k(n(U(W)[)`)}*1*9*b*g*k*n*p*r*u+|,w,S,V,W,Y-p-r-r-z-z-B-B-D-E-N-S-$-%-(.n.D/b/g/"/$/$/+/+/-/;/=:q:A:L:O:?:_:`:}:};2;V;X;X;!;#;%;%;*f>j>j>x>x>F>I>K>P>R>T>W@+[y[C[I{s{u{u{y{I{M{Y{#{:{>|0|3|3|i|i}p}r}D}D}T}+~Z~/~<~<~[~[', -).concat( - convert_from_raw( +const lr_ranges = [ + ...convert_from_raw( + digits, + 2, + '0$0}151u1<1<1|1|2222282u2w2!2#7Q7T7Z7:7;80848e8e9Q9T9W9$9&9+9.9.9:b1b3cOcWfBfDfEp7pZp"p"p$p(p;p>p@p]q0q9qcqEqGr7r9rcrhrorqrJrMrZr#r*r,r:r=sHsJsMsPsSsVsWs!s#s%t3t6t8tatktnt=t?t]t}t}u1u4u6upusuEuGuUuWvnvpvqvsvsvxvEvGvNvPvZv#w1w3w"w$w:wAgAiA>A^B0B2BlBoCxCzCFCJCJCLDIDKDLDTDWDYD%D/E>E@E[E}E}F1FbFiF~G2GsGuGuGwGwGCG{HbHbHhHhHkHoHAHAH-H?H[J0J5J5JcJcJfJgJjJHJKJNJRJ(J-J^J`J{J~K4K6KkKmR>R]SDSOTXTZ!T!V!@!^#h#l#N#R#?#]$l$o$`$}$}%6%d%f%g%s%y%A%A%C%T%%%+%`(k(n(U(W)[)`)}*1*9*b*g*k*n*p*r*u+|,w,S,V,W,Y-p-r-r-z-z-B-B-D-E-N-S-$-%-(.n.D/b/g/"/$/$/+/+/-/;/=:q:A:L:O:?:_:`:}:};2;V;X;X;!;#;%;%;*f>j>j>x>x>F>I>K>P>R>T>W@+[y[C[I{s{u{u{y{I{M{Y{#{:{>|0|3|3|i|i}p}r}D}D}T}+~Z~/~<~<~[~[', + ), + ...convert_from_raw( digits, 3, '0~_10310510510910d10k10k10m10m10o10o10q10t10v10F10I10L10R10V10!10"10>11s11w11z15}16%17117118f18f18T18=18~19j19>1a$1fU1fU1js1m71s]1s^1tq1tr1t!1t#1t;1t;1t_1uj1uo1w]1w~1x21x61xc1xk1yS1yU1zX1A)1Bz1B!1B!1CY1C+1Fa1Fz1FM1FP1FV1FX1F^1G11G61G71G91Gd1Gg1Gk1Go1Hk1Hp1Hr1Ht1Iq1Is1KD1K:1LE1LH1L~1Mg1MH1ML1N41Nk1Nv1NA1Pi1Pn1Qt1Qw1Q!1Q#2wv2x44|[4}L52452853a53s53V53Y54L54O54"55656f56h57J57L57N57P57S57U57>57[57[57{58758a58&58,59T59W59[5aa5aZ5a*5b25be5bX5b"5ci5ck5cl5cq5cr5ct5c(5c*5dI5dP5dQ5dT5dU5dX5d*5d,5d=5d?5ez5eB5e`5e|5e|5f15f25f55f95fc5fc5fe5fT5fW5f$5f&5is5iu5iv5ix5iA5iC7S(7"67"b7""7""7"[7"[7"{7"~7$Q7$Q7$^7%i7%p7%O7%!7&~7(77(77(f7(f7(w7+c7+e7+/7,Z7,"7,:7,=7,?7->7-@7:v7:Y7;|7<37}T8k>8k>8k@8lH8lX8l)8l}8mm8mq8m.8m=8m>8m[8nX8n"8o68oc8oc8ol8o@8o]8p38p68pV8p&8p;8p?8q_8q}8q~8r18r18r48r98rb8s<8s>8s@8s~8tj8tm8t=8t?8t[8t^8ut8uB8uD8uJ8wT8w#8w$8w)8w)8w+8x_8y18y18y38y68y98y98yc8A$8A*8A/8A<8A<8A?8Bf8Bi8Ca8Cj8Ck8Cm8Cm8Cp8CT8C)8DC8DE8DE8DG8DH8DO8DO8DQ8EY8E#8E$8E*8E*8E:8S+8S=8S=8S_8T;8U88U98Uh8Uh8Uk8Uk8Una|[a||a}Ta}"ba*ba/dFgdFjdFjdFoe72e76e7ee7ve7we7Ee7)e7.e8"e9GebHecDemiemkem:emeLXeL&eL&eL^eL_eM2eM2eM5eM5eMbe)[f0Yf0"f1,f1[f27f28f2of2of2Ef2Ef2 { @@ -421,7 +421,7 @@ function get_topic_suggestions(last, operators) { return topics.map((topic) => { const topic_term = {operator: "topic", operand: topic, negated}; - const operators = suggest_operators.concat([topic_term]); + const operators = [...suggest_operators, topic_term]; return format_as_suggestion(operators); }); } diff --git a/web/src/server_events.js b/web/src/server_events.js index 3e9c40ef4f..b218f899c9 100644 --- a/web/src/server_events.js +++ b/web/src/server_events.js @@ -48,12 +48,12 @@ function get_events_success(events) { } if (waiting_on_homeview_load) { - events_stored_while_loading = events_stored_while_loading.concat(events); + events_stored_while_loading = [...events_stored_while_loading, ...events]; return; } if (events_stored_while_loading.length > 0) { - events = events_stored_while_loading.concat(events); + events = [...events_stored_while_loading, ...events]; events_stored_while_loading = []; } diff --git a/web/src/server_events_dispatch.js b/web/src/server_events_dispatch.js index ac7ba05aa7..670fbfa1a1 100644 --- a/web/src/server_events_dispatch.js +++ b/web/src/server_events_dispatch.js @@ -133,7 +133,7 @@ export function dispatch_normal_event(event) { case "hotspots": hotspots.load_new(event.hotspots); page_params.hotspots = page_params.hotspots - ? page_params.hotspots.concat(event.hotspots) + ? [...page_params.hotspots, ...event.hotspots] : event.hotspots; break; diff --git a/web/src/settings_config.ts b/web/src/settings_config.ts index 65b159e6f0..b2ea8497fd 100644 --- a/web/src/settings_config.ts +++ b/web/src/settings_config.ts @@ -688,22 +688,25 @@ const other_email_settings = [ "enable_marketing_emails", ]; -const email_notification_settings = other_email_settings.concat( - email_message_notification_settings, -); +const email_notification_settings = [ + ...other_email_settings, + ...email_message_notification_settings, +]; -const other_notification_settings = desktop_notification_settings.concat( - ["desktop_icon_count_display"], - mobile_notification_settings, - email_notification_settings, - ["email_notifications_batching_period_seconds"], - ["notification_sound"], -); +const other_notification_settings = [ + ...desktop_notification_settings, + "desktop_icon_count_display", + ...mobile_notification_settings, + ...email_notification_settings, + "email_notifications_batching_period_seconds", + "notification_sound", +]; -export const all_notification_settings = other_notification_settings.concat( - pm_mention_notification_settings, - stream_notification_settings, -); +export const all_notification_settings = [ + ...other_notification_settings, + ...pm_mention_notification_settings, + ...stream_notification_settings, +]; type Settings = UserSettings | RealmDefaultSettings; type PageParamsItem = keyof Settings; diff --git a/web/src/settings_org.js b/web/src/settings_org.js index 9ff19ec98b..67dbfcfb93 100644 --- a/web/src/settings_org.js +++ b/web/src/settings_org.js @@ -207,7 +207,7 @@ export function extract_property_name($elem, for_realm_default_settings) { } export function get_subsection_property_elements(subsection) { - return Array.from($(subsection).find(".prop-element")); + return [...$(subsection).find(".prop-element")]; } const simple_dropdown_properties = [ @@ -1059,7 +1059,7 @@ function check_maximum_valid_value($custom_input_elem, property_name) { } function enable_or_disable_save_button($subsection_elem) { - const time_limit_settings = Array.from($subsection_elem.find(".time-limit-setting")); + const time_limit_settings = [...$subsection_elem.find(".time-limit-setting")]; let disable_save_btn = false; for (const setting_elem of time_limit_settings) { const $dropdown_elem = $(setting_elem).find("select"); diff --git a/web/src/settings_playgrounds.js b/web/src/settings_playgrounds.js index 0eba4b4f91..d4725edbc1 100644 --- a/web/src/settings_playgrounds.js +++ b/web/src/settings_playgrounds.js @@ -166,7 +166,7 @@ function build_page() { $search_pygments_box.typeahead({ source(query) { language_labels = realm_playground.get_pygments_typeahead_list_for_settings(query); - return Array.from(language_labels.keys()); + return [...language_labels.keys()]; }, items: 5, fixed: true, diff --git a/web/src/settings_user_groups_legacy.js b/web/src/settings_user_groups_legacy.js index 9e6823e6bf..f733fec45d 100644 --- a/web/src/settings_user_groups_legacy.js +++ b/web/src/settings_user_groups_legacy.js @@ -108,7 +108,7 @@ export function populate_user_groups() { function is_user_group_changed() { const draft_group = get_pill_user_ids(); const group_data = user_groups.get_user_group_from_id(data.id); - const original_group = Array.from(group_data.members); + const original_group = [...group_data.members]; const same_groups = _.isEqual(_.sortBy(draft_group), _.sortBy(original_group)); const description = $(`#user-groups #${CSS.escape(data.id)} .description`) .text() @@ -172,7 +172,7 @@ export function populate_user_groups() { function save_members() { const draft_group = get_pill_user_ids(); const group_data = user_groups.get_user_group_from_id(data.id); - const original_group = Array.from(group_data.members); + const original_group = [...group_data.members]; const same_groups = _.isEqual(_.sortBy(draft_group), _.sortBy(original_group)); if (!draft_group.length || same_groups) { return; diff --git a/web/src/starred_messages.js b/web/src/starred_messages.js index 3dd94d4772..eb24360e82 100644 --- a/web/src/starred_messages.js +++ b/web/src/starred_messages.js @@ -37,7 +37,7 @@ export function get_count() { } export function get_starred_msg_ids() { - return Array.from(starred_ids); + return [...starred_ids]; } export function get_count_in_topic(stream_id, topic) { @@ -45,7 +45,7 @@ export function get_count_in_topic(stream_id, topic) { return 0; } - const messages = Array.from(starred_ids).filter((id) => { + const messages = [...starred_ids].filter((id) => { const message = message_store.get(id); if (message === undefined) { diff --git a/web/src/stats/stats.js b/web/src/stats/stats.js index 9823f20222..c31cd438c9 100644 --- a/web/src/stats/stats.js +++ b/web/src/stats/stats.js @@ -487,7 +487,7 @@ function compute_summary_chart_data(time_series_data, num_steps, labels_) { } data.set(key, sum); } - const labels = labels_.slice(); + const labels = [...labels_]; const values = []; for (const label of labels) { if (data.has(label)) { diff --git a/web/src/stream_create_subscribers_data.js b/web/src/stream_create_subscribers_data.js index 5743ec3a77..33648755f4 100644 --- a/web/src/stream_create_subscribers_data.js +++ b/web/src/stream_create_subscribers_data.js @@ -10,7 +10,7 @@ export function initialize_with_current_user() { } export function sorted_user_ids() { - const users = people.get_users_from_ids(Array.from(user_id_set)); + const users = people.get_users_from_ids([...user_id_set]); people.sort_but_pin_current_user_on_top(users); return users.map((user) => user.user_id); } @@ -25,7 +25,7 @@ export function get_all_user_ids() { export function get_principals() { // Return list of user ids which were selected by user. - return Array.from(user_id_set); + return [...user_id_set]; } export function get_potential_subscribers() { diff --git a/web/src/stream_data.js b/web/src/stream_data.js index f7fcf66c51..b27b74f79c 100644 --- a/web/src/stream_data.js +++ b/web/src/stream_data.js @@ -355,14 +355,14 @@ export function delete_sub(stream_id) { } export function get_non_default_stream_names() { - let subs = Array.from(stream_info.values()); + let subs = [...stream_info.values()]; subs = subs.filter((sub) => !is_default_stream_id(sub.stream_id) && !sub.invite_only); const names = subs.map((sub) => sub.name); return names; } export function get_unsorted_subs() { - return Array.from(stream_info.values()); + return [...stream_info.values()]; } export function num_subscribed_subs() { @@ -370,11 +370,11 @@ export function num_subscribed_subs() { } export function subscribed_subs() { - return Array.from(stream_info.true_values()); + return [...stream_info.true_values()]; } export function unsubscribed_subs() { - return Array.from(stream_info.false_values()); + return [...stream_info.false_values()]; } export function subscribed_streams() { @@ -687,7 +687,7 @@ export function set_realm_default_streams(realm_default_streams) { } export function get_default_stream_ids() { - return Array.from(default_stream_ids); + return [...default_stream_ids]; } export function is_default_stream_id(stream_id) { @@ -821,7 +821,7 @@ export function get_streams_for_admin() { return util.strcmp(a.name, b.name); } - const subs = Array.from(stream_info.values()); + const subs = [...stream_info.values()]; subs.sort(by_name); diff --git a/web/src/stream_edit_subscribers.js b/web/src/stream_edit_subscribers.js index f2c6398e9a..a710e5f6ff 100644 --- a/web/src/stream_edit_subscribers.js +++ b/web/src/stream_edit_subscribers.js @@ -157,7 +157,7 @@ function subscribe_new_users({pill_user_ids}) { } let ignored_deactivated_users; if (deactivated_users.size > 0) { - ignored_deactivated_users = Array.from(deactivated_users); + ignored_deactivated_users = [...deactivated_users]; ignored_deactivated_users = ignored_deactivated_users.map((user_id) => people.get_by_user_id(user_id), ); @@ -172,7 +172,7 @@ function subscribe_new_users({pill_user_ids}) { return; } - const user_ids = Array.from(user_id_set); + const user_ids = [...user_id_set]; function invite_success(data) { pill_widget.clear(); diff --git a/web/src/stream_pill.js b/web/src/stream_pill.js index c2c23e020d..d46fa75146 100644 --- a/web/src/stream_pill.js +++ b/web/src/stream_pill.js @@ -42,7 +42,7 @@ function get_user_ids_from_subs(items) { for (const item of items) { // only some of our items have streams (for copy-from-stream) if (item.stream_id !== undefined) { - user_ids = user_ids.concat(peer_data.get_subscribers(item.stream_id)); + user_ids = [...user_ids, ...peer_data.get_subscribers(item.stream_id)]; } } return user_ids; @@ -51,7 +51,7 @@ function get_user_ids_from_subs(items) { export function get_user_ids(pill_widget) { const items = pill_widget.items(); let user_ids = get_user_ids_from_subs(items); - user_ids = Array.from(new Set(user_ids)); + user_ids = [...new Set(user_ids)]; user_ids = user_ids.filter(Boolean); user_ids.sort((a, b) => a - b); diff --git a/web/src/stream_settings_data.js b/web/src/stream_settings_data.js index 38f6f2d2a9..e49496ed32 100644 --- a/web/src/stream_settings_data.js +++ b/web/src/stream_settings_data.js @@ -105,7 +105,7 @@ export function get_streams_for_settings_page() { } subscribed_rows.sort(by_name); unsubscribed_rows.sort(by_name); - const all_subs = unsubscribed_rows.concat(subscribed_rows); + const all_subs = [...unsubscribed_rows, ...subscribed_rows]; return get_subs_for_settings(all_subs); } diff --git a/web/src/stream_sort.js b/web/src/stream_sort.js index 7db56a6f45..544848802a 100644 --- a/web/src/stream_sort.js +++ b/web/src/stream_sort.js @@ -88,12 +88,13 @@ export function sort_groups(streams, search_term) { previous_muted_active = muted_active_streams; previous_dormant = dormant_streams; - all_streams = pinned_streams.concat( - muted_pinned_streams, - normal_streams, - muted_active_streams, - dormant_streams, - ); + all_streams = [ + ...pinned_streams, + ...muted_pinned_streams, + ...normal_streams, + ...muted_active_streams, + ...dormant_streams, + ]; } return { diff --git a/web/src/stream_topic_history.js b/web/src/stream_topic_history.js index 03a4987310..2340b99b36 100644 --- a/web/src/stream_topic_history.js +++ b/web/src/stream_topic_history.js @@ -199,7 +199,7 @@ export class PerStreamHistory { } get_recent_topic_names() { - const my_recents = Array.from(this.topics.values()); + const my_recents = [...this.topics.values()]; /* Add any older topics with unreads that may not be present * in our local cache. */ @@ -208,7 +208,7 @@ export class PerStreamHistory { topic_dict: this.topics, }); - const recents = my_recents.concat(missing_topics); + const recents = [...my_recents, ...missing_topics]; recents.sort((a, b) => b.message_id - a.message_id); diff --git a/web/src/todo_widget.js b/web/src/todo_widget.js index efb4e74340..db9db31590 100644 --- a/web/src/todo_widget.js +++ b/web/src/todo_widget.js @@ -22,7 +22,7 @@ export class TaskData { } get_widget_data() { - const all_tasks = Array.from(this.task_map.values()); + const all_tasks = [...this.task_map.values()]; all_tasks.sort((a, b) => util.strcmp(a.task, b.task)); const pending_tasks = []; diff --git a/web/src/topic_list.js b/web/src/topic_list.js index 246b621994..c43ed4b601 100644 --- a/web/src/topic_list.js +++ b/web/src/topic_list.js @@ -52,7 +52,7 @@ export function close() { export function zoom_out() { zoomed = false; - const stream_ids = Array.from(active_widgets.keys()); + const stream_ids = [...active_widgets.keys()]; if (stream_ids.length !== 1) { blueslip.error("Unexpected number of topic lists to zoom out."); @@ -198,7 +198,7 @@ export function clear_topic_search(e) { // Since this changes the contents of the search input, we // need to rerender the topic list. - const stream_ids = Array.from(active_widgets.keys()); + const stream_ids = [...active_widgets.keys()]; const stream_id = stream_ids[0]; const widget = active_widgets.get(stream_id); @@ -209,7 +209,7 @@ export function clear_topic_search(e) { } export function active_stream_id() { - const stream_ids = Array.from(active_widgets.keys()); + const stream_ids = [...active_widgets.keys()]; if (stream_ids.length !== 1) { return undefined; @@ -219,7 +219,7 @@ export function active_stream_id() { } export function get_stream_li() { - const widgets = Array.from(active_widgets.values()); + const widgets = [...active_widgets.values()]; if (widgets.length !== 1) { return undefined; diff --git a/web/src/typeahead_helper.js b/web/src/typeahead_helper.js index d9036e5458..080949afb0 100644 --- a/web/src/typeahead_helper.js +++ b/web/src/typeahead_helper.js @@ -146,7 +146,7 @@ export function render_emoji(item) { export function sorter(query, objs, get_item) { const results = typeahead.triage(query, objs, get_item); - return results.matches.concat(results.rest); + return [...results.matches, ...results.rest]; } export function compare_by_pms(user_a, user_b) { @@ -353,7 +353,7 @@ export function sort_languages(matches, query) { // Languages that have the query somewhere in their name results.rest = results.rest.sort(compare_language); - return retain_unique_language_aliases(results.matches.concat(results.rest)); + return retain_unique_language_aliases([...results.matches, ...results.rest]); } export function sort_recipients({ @@ -394,7 +394,7 @@ export function sort_recipients({ for (const getter of getters) { if (items.length < max_num_items) { - items = items.concat(getter()); + items = [...items, ...getter()]; } } @@ -418,7 +418,7 @@ export function sort_slash_commands(matches, query) { results.matches = results.matches.sort(slash_command_comparator); results.rest = results.rest.sort(slash_command_comparator); - return results.matches.concat(results.rest); + return [...results.matches, ...results.rest]; } // Gives stream a score from 0 to 3 based on its activity @@ -465,5 +465,5 @@ export function sort_streams(matches, query) { // Streams with names and descriptions that don't start with the query. desc_results.rest = desc_results.rest.sort(compare_by_activity); - return name_results.matches.concat(desc_results.matches.concat(desc_results.rest)); + return [...name_results.matches, ...desc_results.matches, ...desc_results.rest]; } diff --git a/web/src/typing_data.js b/web/src/typing_data.js index 58b58aff8b..878bcf3b12 100644 --- a/web/src/typing_data.js +++ b/web/src/typing_data.js @@ -52,7 +52,7 @@ export function get_group_typists(group) { } export function get_all_typists() { - let typists = Array.from(typist_dct.values()).flat(); + let typists = [...typist_dct.values()].flat(); typists = util.sorted_ids(typists); return muted_users.filter_muted_user_ids(typists); } diff --git a/web/src/typing_events.js b/web/src/typing_events.js index 85580b8c87..34a143f62b 100644 --- a/web/src/typing_events.js +++ b/web/src/typing_events.js @@ -44,7 +44,7 @@ function get_users_typing_for_narrow() { const narrow_user_ids = narrow_user_ids_string .split(",") .map((user_id_string) => Number.parseInt(user_id_string, 10)); - const group = narrow_user_ids.concat([page_params.user_id]); + const group = [...narrow_user_ids, page_params.user_id]; return typing_data.get_group_typists(group); } // Get all users typing (in all private conversations with current user) diff --git a/web/src/unread.js b/web/src/unread.js index 278850ef76..f9a5e7c6d6 100644 --- a/web/src/unread.js +++ b/web/src/unread.js @@ -209,7 +209,7 @@ class UnreadPMCounter { return []; } - const ids = Array.from(bucket); + const ids = [...bucket]; return util.sorted_ids(ids); } } @@ -309,12 +309,12 @@ class UnreadTopicCounter { return []; } - let topic_names = Array.from(per_stream_bucketer.keys()); + let topic_names = [...per_stream_bucketer.keys()]; /* Include topics that have at least one unread. It would likely * be better design for buckets to be deleted when emptied. */ topic_names = topic_names.filter((topic_name) => { - const messages = Array.from(per_stream_bucketer.get_bucket(topic_name)); + const messages = [...per_stream_bucketer.get_bucket(topic_name)]; return messages.length > 0; }); /* And aren't already present in topic_dict. */ @@ -325,7 +325,7 @@ class UnreadTopicCounter { return { pretty_name: topic_name, - message_id: Math.max(...Array.from(msgs)), + message_id: Math.max(...msgs), }; }); @@ -396,7 +396,7 @@ class UnreadTopicCounter { return []; } - const ids = Array.from(topic_bucket); + const ids = [...topic_bucket]; return util.sorted_ids(ids); } @@ -707,7 +707,7 @@ export function get_counts() { const streams_with_mentions = unread_topic_counter.get_streams_with_unread_mentions(); res.home_unread_messages = topic_res.stream_unread_messages; res.stream_count = topic_res.stream_count; - res.streams_with_mentions = Array.from(streams_with_mentions); + res.streams_with_mentions = [...streams_with_mentions]; const pm_res = unread_pm_counter.get_counts(); res.pm_count = pm_res.pm_dict; @@ -797,13 +797,13 @@ export function get_msg_ids_for_private() { } export function get_msg_ids_for_mentions() { - const ids = Array.from(unread_mentions_counter); + const ids = [...unread_mentions_counter]; return util.sorted_ids(ids); } export function get_all_msg_ids() { - const ids = Array.from(unread_messages); + const ids = [...unread_messages]; return util.sorted_ids(ids); } diff --git a/web/src/user_group_create_members_data.js b/web/src/user_group_create_members_data.js index 171f24ee59..66e34973d4 100644 --- a/web/src/user_group_create_members_data.js +++ b/web/src/user_group_create_members_data.js @@ -10,7 +10,7 @@ export function initialize_with_current_user() { } export function sorted_user_ids() { - const users = people.get_users_from_ids(Array.from(user_id_set)); + const users = people.get_users_from_ids([...user_id_set]); people.sort_but_pin_current_user_on_top(users); return users.map((user) => user.user_id); } @@ -25,7 +25,7 @@ export function get_all_user_ids() { export function get_principals() { // Return list of user ids which were selected by user. - return Array.from(user_id_set); + return [...user_id_set]; } export function get_potential_members() { diff --git a/web/src/user_group_edit.js b/web/src/user_group_edit.js index d9024fb67b..c7360ee1ec 100644 --- a/web/src/user_group_edit.js +++ b/web/src/user_group_edit.js @@ -111,7 +111,7 @@ export function handle_member_edit_event(group_id) { const group = user_groups.get_user_group_from_id(group_id); // update members list. - const members = Array.from(group.members); + const members = [...group.members]; user_group_edit_members.update_member_list_widget(group_id, members); // update_settings buttons. diff --git a/web/src/user_group_edit_members.js b/web/src/user_group_edit_members.js index 13c9bcdaa3..cbbd18ac30 100644 --- a/web/src/user_group_edit_members.js +++ b/web/src/user_group_edit_members.js @@ -97,7 +97,7 @@ export function enable_member_management({group, $parent_container}) { member_list_widget = make_list_widget({ $parent_container, name: "user_group_members", - user_ids: Array.from(group.members), + user_ids: [...group.members], }); } @@ -179,13 +179,13 @@ function add_new_members({pill_user_ids}) { let ignored_deactivated_users; let ignored_already_added_users; if (deactivated_users.size > 0) { - ignored_deactivated_users = Array.from(deactivated_users); + ignored_deactivated_users = [...deactivated_users]; ignored_deactivated_users = ignored_deactivated_users.map((user_id) => people.get_by_user_id(user_id), ); } if (already_added_users.size > 0) { - ignored_already_added_users = Array.from(already_added_users); + ignored_already_added_users = [...already_added_users]; ignored_already_added_users = ignored_already_added_users.map((user_id) => people.get_by_user_id(user_id), ); @@ -201,7 +201,7 @@ function add_new_members({pill_user_ids}) { }); return; } - const user_ids = Array.from(user_id_set); + const user_ids = [...user_id_set]; function invite_success() { pill_widget.clear(); diff --git a/web/src/user_group_pill.js b/web/src/user_group_pill.js index 2e59c55983..3067dee583 100644 --- a/web/src/user_group_pill.js +++ b/web/src/user_group_pill.js @@ -31,19 +31,16 @@ export function get_group_name_from_item(item) { } function get_user_ids_from_user_groups(items) { - let user_ids = []; const group_ids = items.map((item) => item.id).filter(Boolean); - for (const group_id of group_ids) { - const user_group = user_groups.get_user_group_from_id(group_id); - user_ids = user_ids.concat(Array.from(user_group.members)); - } - return user_ids; + return group_ids.flatMap((group_id) => [ + ...user_groups.get_user_group_from_id(group_id).members, + ]); } export function get_user_ids(pill_widget) { const items = pill_widget.items(); let user_ids = get_user_ids_from_user_groups(items); - user_ids = Array.from(new Set(user_ids)); + user_ids = [...new Set(user_ids)]; user_ids.sort((a, b) => a - b); user_ids = user_ids.filter(Boolean); diff --git a/web/src/user_groups.ts b/web/src/user_groups.ts index 59e0f6dd04..453b9fcbb4 100644 --- a/web/src/user_groups.ts +++ b/web/src/user_groups.ts @@ -81,7 +81,7 @@ export function get_user_group_from_name(name: string): UserGroup | undefined { } export function get_realm_user_groups(): UserGroup[] { - const user_groups = Array.from(user_group_by_id_dict.values()).sort((a, b) => a.id - b.id); + const user_groups = [...user_group_by_id_dict.values()].sort((a, b) => a.id - b.id); return user_groups.filter((group) => !group.is_system_group); } @@ -239,5 +239,5 @@ export function get_realm_user_groups_for_dropdown_list_widget( value: group.id.toString(), })); - return system_user_groups.concat(user_groups_excluding_system_groups); + return [...system_user_groups, ...user_groups_excluding_system_groups]; } diff --git a/web/src/util.ts b/web/src/util.ts index b46ab30c88..925deabb98 100644 --- a/web/src/util.ts +++ b/web/src/util.ts @@ -224,7 +224,7 @@ export function sorted_ids(ids: string[]): number[] { // This mapping makes sure we are using ints, and // it also makes sure we don't mutate the list. let id_list = ids.map((s) => Number.parseInt(s, 10)); - id_list = Array.from(new Set(id_list)); + id_list = [...new Set(id_list)]; id_list.sort((a, b) => a - b); return id_list; diff --git a/web/tests/components.test.js b/web/tests/components.test.js index 4b6726fee2..521cfdefaf 100644 --- a/web/tests/components.test.js +++ b/web/tests/components.test.js @@ -20,7 +20,7 @@ function make_tab(i) { $self.addClass = (c) => { $self.class += " " + c; const tokens = $self.class.trim().split(/ +/); - $self.class = Array.from(new Set(tokens)).join(" "); + $self.class = [...new Set(tokens)].join(" "); }; $self.removeClass = (c) => { diff --git a/web/tests/compose_pm_pill.test.js b/web/tests/compose_pm_pill.test.js index 252e466f94..f649b115a9 100644 --- a/web/tests/compose_pm_pill.test.js +++ b/web/tests/compose_pm_pill.test.js @@ -53,7 +53,7 @@ run_test("pills", ({override}) => { assert.ok(!all_pills.has(id)); all_pills.set(id, item); }; - pills.items = () => Array.from(all_pills.values()); + pills.items = () => [...all_pills.values()]; let text_cleared; pills.clear_text = () => { diff --git a/web/tests/composebox_typeahead.test.js b/web/tests/composebox_typeahead.test.js index 5ec2726367..9dc6893d28 100644 --- a/web/tests/composebox_typeahead.test.js +++ b/web/tests/composebox_typeahead.test.js @@ -160,7 +160,7 @@ const emojis_by_name = new Map( headphones: emoji_headphones, }), ); -const emoji_list = Array.from(emojis_by_name.values(), (emoji_dict) => ({ +const emoji_list = [...emojis_by_name.values()].map((emoji_dict) => ({ emoji_name: emoji_dict.name, emoji_code: emoji_dict.emoji_code, reaction_type: "unicode_emoji", @@ -221,7 +221,7 @@ for (const [key, val] of emojis_by_name.entries()) { const emoji_codes = { name_to_codepoint, - names: Array.from(emojis_by_name.keys()), + names: [...emojis_by_name.keys()], emoji_catalog: {}, emoticon_conversions: {}, codepoint_to_name: {}, diff --git a/web/tests/filter.test.js b/web/tests/filter.test.js index 67fda4d035..132152c20b 100644 --- a/web/tests/filter.test.js +++ b/web/tests/filter.test.js @@ -276,41 +276,41 @@ test("basics", () => { function assert_not_mark_read_with_has_operands(additional_operators_to_test) { additional_operators_to_test = additional_operators_to_test || []; let has_operator = [{operator: "has", operand: "link"}]; - let filter = new Filter(additional_operators_to_test.concat(has_operator)); + let filter = new Filter([...additional_operators_to_test, ...has_operator]); assert.ok(!filter.can_mark_messages_read()); has_operator = [{operator: "has", operand: "link", negated: true}]; - filter = new Filter(additional_operators_to_test.concat(has_operator)); + filter = new Filter([...additional_operators_to_test, ...has_operator]); assert.ok(!filter.can_mark_messages_read()); has_operator = [{operator: "has", operand: "image"}]; - filter = new Filter(additional_operators_to_test.concat(has_operator)); + filter = new Filter([...additional_operators_to_test, ...has_operator]); assert.ok(!filter.can_mark_messages_read()); has_operator = [{operator: "has", operand: "image", negated: true}]; - filter = new Filter(additional_operators_to_test.concat(has_operator)); + filter = new Filter([...additional_operators_to_test, ...has_operator]); assert.ok(!filter.can_mark_messages_read()); has_operator = [{operator: "has", operand: "attachment", negated: true}]; - filter = new Filter(additional_operators_to_test.concat(has_operator)); + filter = new Filter([...additional_operators_to_test, ...has_operator]); assert.ok(!filter.can_mark_messages_read()); has_operator = [{operator: "has", operand: "attachment"}]; - filter = new Filter(additional_operators_to_test.concat(has_operator)); + filter = new Filter([...additional_operators_to_test, ...has_operator]); assert.ok(!filter.can_mark_messages_read()); } function assert_not_mark_read_with_is_operands(additional_operators_to_test) { additional_operators_to_test = additional_operators_to_test || []; let is_operator = [{operator: "is", operand: "starred"}]; - let filter = new Filter(additional_operators_to_test.concat(is_operator)); + let filter = new Filter([...additional_operators_to_test, ...is_operator]); assert.ok(!filter.can_mark_messages_read()); is_operator = [{operator: "is", operand: "starred", negated: true}]; - filter = new Filter(additional_operators_to_test.concat(is_operator)); + filter = new Filter([...additional_operators_to_test, ...is_operator]); assert.ok(!filter.can_mark_messages_read()); is_operator = [{operator: "is", operand: "mentioned"}]; - filter = new Filter(additional_operators_to_test.concat(is_operator)); + filter = new Filter([...additional_operators_to_test, ...is_operator]); if (additional_operators_to_test.length === 0) { assert.ok(filter.can_mark_messages_read()); } else { @@ -318,27 +318,27 @@ function assert_not_mark_read_with_is_operands(additional_operators_to_test) { } is_operator = [{operator: "is", operand: "mentioned", negated: true}]; - filter = new Filter(additional_operators_to_test.concat(is_operator)); + filter = new Filter([...additional_operators_to_test, ...is_operator]); assert.ok(!filter.can_mark_messages_read()); is_operator = [{operator: "is", operand: "alerted"}]; - filter = new Filter(additional_operators_to_test.concat(is_operator)); + filter = new Filter([...additional_operators_to_test, ...is_operator]); assert.ok(!filter.can_mark_messages_read()); is_operator = [{operator: "is", operand: "alerted", negated: true}]; - filter = new Filter(additional_operators_to_test.concat(is_operator)); + filter = new Filter([...additional_operators_to_test, ...is_operator]); assert.ok(!filter.can_mark_messages_read()); is_operator = [{operator: "is", operand: "unread"}]; - filter = new Filter(additional_operators_to_test.concat(is_operator)); + filter = new Filter([...additional_operators_to_test, ...is_operator]); assert.ok(!filter.can_mark_messages_read()); is_operator = [{operator: "is", operand: "unread", negated: true}]; - filter = new Filter(additional_operators_to_test.concat(is_operator)); + filter = new Filter([...additional_operators_to_test, ...is_operator]); assert.ok(!filter.can_mark_messages_read()); is_operator = [{operator: "is", operand: "resolved"}]; - filter = new Filter(additional_operators_to_test.concat(is_operator)); + filter = new Filter([...additional_operators_to_test, ...is_operator]); if (additional_operators_to_test.length === 0) { assert.ok(filter.can_mark_messages_read()); } else { @@ -346,18 +346,18 @@ function assert_not_mark_read_with_is_operands(additional_operators_to_test) { } is_operator = [{operator: "is", operand: "resolved", negated: true}]; - filter = new Filter(additional_operators_to_test.concat(is_operator)); + filter = new Filter([...additional_operators_to_test, ...is_operator]); assert.ok(!filter.can_mark_messages_read()); } function assert_not_mark_read_when_searching(additional_operators_to_test) { additional_operators_to_test = additional_operators_to_test || []; let search_op = [{operator: "search", operand: "keyword"}]; - let filter = new Filter(additional_operators_to_test.concat(search_op)); + let filter = new Filter([...additional_operators_to_test, ...search_op]); assert.ok(!filter.can_mark_messages_read()); search_op = [{operator: "search", operand: "keyword", negated: true}]; - filter = new Filter(additional_operators_to_test.concat(search_op)); + filter = new Filter([...additional_operators_to_test, ...search_op]); assert.ok(!filter.can_mark_messages_read()); } diff --git a/web/tests/fold_dict.test.js b/web/tests/fold_dict.test.js index ea23dc216c..95fe420f6a 100644 --- a/web/tests/fold_dict.test.js +++ b/web/tests/fold_dict.test.js @@ -12,7 +12,7 @@ run_test("basic", () => { assert.equal(d.size, 0); - assert.deepEqual(Array.from(d.keys()), []); + assert.deepEqual([...d.keys()], []); d.set("foo", "bar"); assert.equal(d.get("foo"), "bar"); @@ -30,18 +30,21 @@ run_test("basic", () => { assert.equal(d.has("bar"), true); assert.equal(d.has("baz"), false); - assert.deepEqual(Array.from(d.keys()), ["foo", "bar"]); - assert.deepEqual(Array.from(d.values()), ["baz", "qux"]); - assert.deepEqual(Array.from(d), [ - ["foo", "baz"], - ["bar", "qux"], - ]); + assert.deepEqual([...d.keys()], ["foo", "bar"]); + assert.deepEqual([...d.values()], ["baz", "qux"]); + assert.deepEqual( + [...d], + [ + ["foo", "baz"], + ["bar", "qux"], + ], + ); d.delete("bar"); assert.equal(d.has("bar"), false); assert.strictEqual(d.get("bar"), undefined); - assert.deepEqual(Array.from(d.keys()), ["foo"]); + assert.deepEqual([...d.keys()], ["foo"]); const val = ["foo"]; const res = d.set("abc", val); @@ -51,7 +54,7 @@ run_test("basic", () => { run_test("case insensitivity", () => { const d = new FoldDict(); - assert.deepEqual(Array.from(d.keys()), []); + assert.deepEqual([...d.keys()], []); assert.ok(!d.has("foo")); d.set("fOO", "Hello world"); @@ -60,12 +63,12 @@ run_test("case insensitivity", () => { assert.ok(d.has("FOO")); assert.ok(!d.has("not_a_key")); - assert.deepEqual(Array.from(d.keys()), ["fOO"]); + assert.deepEqual([...d.keys()], ["fOO"]); d.delete("Foo"); assert.equal(d.has("foo"), false); - assert.deepEqual(Array.from(d.keys()), []); + assert.deepEqual([...d.keys()], []); }); run_test("clear", () => { diff --git a/web/tests/lib/zblueslip.js b/web/tests/lib/zblueslip.js index 305181ff3a..a9013972c5 100644 --- a/web/tests/lib/zblueslip.js +++ b/web/tests/lib/zblueslip.js @@ -14,7 +14,7 @@ function make_zblueslip() { warn: true, error: true, }; - const names = Array.from(Object.keys(opts)); + const names = Object.keys(opts); // For fatal messages, we should use assert.throws /* istanbul ignore next */ diff --git a/web/tests/lib/zjquery.js b/web/tests/lib/zjquery.js index a071a630c3..b8a3f3b0f5 100644 --- a/web/tests/lib/zjquery.js +++ b/web/tests/lib/zjquery.js @@ -159,7 +159,7 @@ function make_zjquery() { /* istanbul ignore next */ zjquery.state = function () { // useful for debugging - let res = Array.from(elems.values(), ($v) => $v.debug()); + let res = [...elems.values()].map(($v) => $v.debug()); res = res.map((v) => [v.selector, v.value, v.shown]); diff --git a/web/tests/linkifiers.test.js b/web/tests/linkifiers.test.js index 0b34ab762e..0ab3d30eb1 100644 --- a/web/tests/linkifiers.test.js +++ b/web/tests/linkifiers.test.js @@ -11,7 +11,7 @@ const linkifiers = zrequire("linkifiers"); linkifiers.initialize([]); function get_linkifier_regexes() { - return Array.from(linkifiers.get_linkifier_map().keys()); + return [...linkifiers.get_linkifier_map().keys()]; } run_test("python_to_js_linkifier", () => { diff --git a/web/tests/pill_typeahead.test.js b/web/tests/pill_typeahead.test.js index 51eadce21d..b32916160a 100644 --- a/web/tests/pill_typeahead.test.js +++ b/web/tests/pill_typeahead.test.js @@ -258,13 +258,13 @@ run_test("set_up", ({mock_template}) => { }) .filter(Boolean); if (opts.user_group) { - expected_result = expected_result.concat(groups); + expected_result = [...expected_result, ...groups]; } if (opts.user) { if (opts.user_source) { - expected_result = expected_result.concat(opts.user_source()); + expected_result = [...expected_result, ...opts.user_source()]; } else { - expected_result = expected_result.concat(persons); + expected_result = [...expected_result, ...persons]; } } expected_result = expected_result diff --git a/web/tests/recent_topics.test.js b/web/tests/recent_topics.test.js index 57bb728c12..b64dc4c82e 100644 --- a/web/tests/recent_topics.test.js +++ b/web/tests/recent_topics.test.js @@ -411,7 +411,7 @@ test("test_filter_all", ({mock_template}) => { {last_msg_id: 1, participated: true, type: "stream"}, ]; - row_data = row_data.concat(generate_topic_data([[1, "topic-7", 1, true, true]])); + row_data = [...row_data, ...generate_topic_data([[1, "topic-7", 1, true, true]])]; i = row_data.length; // topic is muted (=== hidden) stub_out_filter_buttons(); @@ -754,7 +754,7 @@ test("basic assertions", ({mock_template, override_rewire}) => { // total 8 topics, 1 muted assert.equal(all_topics.size, 8); assert.equal( - Array.from(all_topics.keys()).toString(), + [...all_topics.keys()].toString(), "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1", ); @@ -766,7 +766,7 @@ test("basic assertions", ({mock_template, override_rewire}) => { all_topics = rt_data.get(); assert.equal(all_topics.size, 9); assert.equal( - Array.from(all_topics.keys()).toString(), + [...all_topics.keys()].toString(), "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1,6,7,8", ); @@ -790,7 +790,7 @@ test("basic assertions", ({mock_template, override_rewire}) => { all_topics = rt_data.get(); assert.equal( - Array.from(all_topics.keys()).toString(), + [...all_topics.keys()].toString(), "1:topic-3,4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-2,1:topic-1,6,7,8", ); verify_topic_data(all_topics, stream1, topic3, id, true); @@ -807,7 +807,7 @@ test("basic assertions", ({mock_template, override_rewire}) => { all_topics = rt_data.get(); assert.equal( - Array.from(all_topics.keys()).toString(), + [...all_topics.keys()].toString(), "1:topic-7,1:topic-3,4:topic-10,1:topic-6,1:topic-5,1:topic-4,1:topic-2,1:topic-1,6,7,8", ); @@ -885,14 +885,14 @@ test("test_delete_messages", ({override}) => { let all_topics = rt_data.get(); assert.equal( - Array.from(all_topics.keys()).toString(), + [...all_topics.keys()].toString(), "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1", ); rt.update_topics_of_deleted_message_ids([messages[0].id]); all_topics = rt_data.get(); assert.equal( - Array.from(all_topics.keys()).toString(), + [...all_topics.keys()].toString(), "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2", ); @@ -903,7 +903,7 @@ test("test_delete_messages", ({override}) => { all_topics = rt_data.get(); assert.equal( - Array.from(all_topics.keys()).toString(), + [...all_topics.keys()].toString(), "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3", ); // test deleting a message which is not locally @@ -923,7 +923,7 @@ test("test_topic_edit", ({override}) => { let all_topics = rt_data.get(); assert.equal( - Array.from(all_topics.keys()).toString(), + [...all_topics.keys()].toString(), "4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1", ); diff --git a/web/tests/settings_org.test.js b/web/tests/settings_org.test.js index 5fb38a288f..a288e4eb11 100644 --- a/web/tests/settings_org.test.js +++ b/web/tests/settings_org.test.js @@ -332,9 +332,7 @@ function test_sync_realm_settings() { settings_config.common_policy_values.by_members.code; $property_elem.val(settings_config.common_policy_values.by_members.code); - for (const policy_value of Array.from( - Object.values(settings_config.common_policy_values), - )) { + for (const policy_value of Object.values(settings_config.common_policy_values)) { page_params[`realm_${property_name}`] = policy_value.code; settings_org.sync_realm_settings(property_name); assert.equal($property_elem.val(), policy_value.code); diff --git a/web/tests/settings_user_groups_legacy.test.js b/web/tests/settings_user_groups_legacy.test.js index 189b7f7fcb..67f033ba15 100644 --- a/web/tests/settings_user_groups_legacy.test.js +++ b/web/tests/settings_user_groups_legacy.test.js @@ -156,7 +156,7 @@ test_ui("populate_user_groups", ({mock_template}) => { assert.ok(!all_pills.has(id)); all_pills.set(id, item); }; - pills.items = () => Array.from(all_pills.values()); + pills.items = () => [...all_pills.values()]; let text_cleared; pills.clear_text = () => { diff --git a/web/tests/typeahead_helper.test.js b/web/tests/typeahead_helper.test.js index a4fc17116a..700d4c1768 100644 --- a/web/tests/typeahead_helper.test.js +++ b/web/tests/typeahead_helper.test.js @@ -420,7 +420,7 @@ test("sort_recipients all mention", () => { assert.equal(all_obj.idx, 0); // Test person email is "all" or "everyone" - const test_objs = matches.concat([all_obj]); + const test_objs = [...matches, all_obj]; const results = th.sort_recipients({ users: test_objs, @@ -482,7 +482,7 @@ test("sort_recipients pm counts", () => { }); test("sort_recipients dup bots", () => { - const dup_objects = matches.concat([a_bot]); + const dup_objects = [...matches, a_bot]; const recipients = th.sort_recipients({ users: dup_objects, @@ -583,7 +583,7 @@ test("sort broadcast mentions for stream message type", () => { // Reverse the list to test actual sorting // and ensure test coverage for the defensive // code. Also, add in some people users. - const test_objs = Array.from(ct.broadcast_mentions()).reverse(); + const test_objs = [...ct.broadcast_mentions()].reverse(); test_objs.unshift(zman); test_objs.push(a_user); @@ -604,7 +604,7 @@ test("sort broadcast mentions for private message type", () => { ["all", "everyone"], ); - const test_objs = Array.from(ct.broadcast_mentions()).reverse(); + const test_objs = [...ct.broadcast_mentions()].reverse(); test_objs.unshift(zman); test_objs.push(a_user); diff --git a/web/tests/widgetize.test.js b/web/tests/widgetize.test.js index c9128a4f19..24bc6492c9 100644 --- a/web/tests/widgetize.test.js +++ b/web/tests/widgetize.test.js @@ -85,7 +85,7 @@ test("activate", ({override}) => { override(narrow_state, "active", () => narrow_active); const opts = { - events: events.slice(), + events: [...events], extra_data: "", message: { id: 2001,