Skip to content

Commit 7e6a9f9

Browse files
committed
Replace size getter in SimpleMap class with regularly updated property
1 parent b611446 commit 7e6a9f9

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/simple-map.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
export class SimpleMap {
22
constructor () {
3+
this.size = 0;
34
this.keys = [];
45
this.values = [];
56
}
67

7-
get size () {
8-
return this.keys.length;
9-
}
10-
118
get (key) {
129
const index = this.keys.indexOf(key);
1310

@@ -17,6 +14,7 @@ export class SimpleMap {
1714
set (key, value) {
1815
this.keys.push(key);
1916
this.values.push(value);
17+
this.size = this.keys.length;
2018

2119
return value;
2220
}

0 commit comments

Comments
 (0)