dict: Replace items method with @@iterator method.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg
2020-02-03 00:04:48 -08:00
committed by Tim Abbott
parent 9e1343ff8a
commit fac2c71776
5 changed files with 11 additions and 10 deletions

View File

@@ -26,8 +26,8 @@ export class Dict<V> {
return this._items.values();
}
items(): [string, V][] {
return [...this._items];
[Symbol.iterator](): Iterator<[string, V]> {
return this._items.entries();
}
get size(): number {

View File

@@ -50,8 +50,10 @@ export class FoldDict<V> {
}
}
items(): [string, V][] {
return [...this._items.values()].map(({k, v}) => [k, v]);
*[Symbol.iterator](): Iterator<[string, V]> {
for (const {k, v} of this._items.values()) {
yield [k, v];
}
}
get size(): number {

View File

@@ -417,8 +417,7 @@ exports.get_message_reactions = function (message) {
}
collapsed_reaction.user_ids.push(user_id);
});
const reactions = message_reactions.items().map(function (item) {
const reaction = item[1];
const reactions = Array.from(message_reactions.values(), reaction => {
reaction.local_id = reaction.local_id;
reaction.reaction_type = reaction.reaction_type;
reaction.emoji_name = reaction.emoji_name;