Skip to content

Commit fb3ca5e

Browse files
committed
fix: implement SimpleMap without using getters/setters
Squashed commit of the following: commit ea31b3a8b0a60f2e428a61fdf28f6cc0f8d469e2 Author: Gajus Kuizinas <gajus@gajus.com> Date: Sat Sep 10 10:59:27 2016 +0100 refactor: remove SimpleMap factory commit 9549afdab039fb151387c65214e78edaef3a3ada Merge: 1cb161d fb31781 Author: Gajus Kuizinas <gajus@gajus.com> Date: Sat Sep 10 10:54:33 2016 +0100 Merge branch 'simple-map-ie8-fix' of https://github.com/lbeschastny/react-css-modules into lbeschastny-simple-map-ie8-fix commit fb31781 Author: Leonid Beschastny <lbeschastny@iknow.travel> Date: Mon Aug 29 12:00:17 2016 +0300 Add createSimpleMap factory function to defer SimpleMap creation commit 7e6a9f9 Author: Leonid Beschastny <lbeschastny@iknow.travel> Date: Mon Aug 29 11:52:35 2016 +0300 Replace size getter in SimpleMap class with regularly updated property
1 parent 1cb161d commit fb3ca5e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
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
}

tests/simple-map.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import {
22
expect
33
} from 'chai';
4-
import {SimpleMap} from './../src/simple-map';
4+
import {
5+
SimpleMap
6+
} from './../src/simple-map';
57

68
const getTests = (map) => {
79
return () => {

0 commit comments

Comments
 (0)