Skip to content

Commit 047b557

Browse files
committed
simplify, make entries lazy
1 parent 2555ceb commit 047b557

File tree

1 file changed

+7
-8
lines changed
  • packages/svelte/src/reactivity

1 file changed

+7
-8
lines changed

packages/svelte/src/reactivity/set.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,16 @@ export class ReactiveSet extends Set {
160160
}
161161

162162
entries() {
163-
const values = Array.from(this.values());
164-
let next_index = 0;
163+
const iterator = this.values();
165164

166165
return make_iterable(
167-
/** @type {any} */ ({
166+
/** @type {IterableIterator<[T, T]>} */ ({
168167
next() {
169-
const index = next_index;
170-
next_index += 1;
171-
return index < values.length
172-
? { value: [values[index], values[index]], done: false }
173-
: { done: true };
168+
for (const value of iterator) {
169+
return { value: [value, value], done: false };
170+
}
171+
172+
return { done: true };
174173
}
175174
})
176175
);

0 commit comments

Comments
 (0)