chore: tweak Map/Set for better inspect output (#12013)

* chore: tweak Map/Set for better inspect output

* chore: tweak Map/Set for better inspect output

* chore: tweak Map/Set for better inspect output

* chore: tweak Map/Set for better inspect output

* chore: tweak Map/Set for better inspect output

* changeset

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/12024/head
Dominic Gannaway 6 months ago committed by GitHub
parent 50fd94fe61
commit 4cdc3710d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
chore: clear `Map`/`Set` before triggering `$inspect` callbacks

@ -122,17 +122,18 @@ export class ReactiveMap extends Map {
}
clear() {
var sources = this.#sources;
if (super.size !== 0) {
set(this.#size, 0);
for (var s of sources.values()) {
set(s, -1);
}
increment(this.#version);
sources.clear();
if (super.size === 0) {
return;
}
// Clear first, so we get nice console.log outputs with $inspect
super.clear();
var sources = this.#sources;
set(this.#size, 0);
for (var s of sources.values()) {
set(s, -1);
}
increment(this.#version);
sources.clear();
}
#read_all() {

@ -117,19 +117,20 @@ export class ReactiveSet extends Set {
}
clear() {
if (super.size !== 0) {
var sources = this.#sources;
for (var s of sources.values()) {
set(s, false);
}
if (super.size === 0) {
return;
}
// Clear first, so we get nice console.log outputs with $inspect
super.clear();
var sources = this.#sources;
sources.clear();
set(this.#size, 0);
increment(this.#version);
for (var s of sources.values()) {
set(s, false);
}
super.clear();
sources.clear();
set(this.#size, 0);
increment(this.#version);
}
keys() {

Loading…
Cancel
Save