Skip to content

Commit 42c53e7

Browse files
committed
Merge branch 'master' of github.com:gajus/react-css-modules
2 parents fe9e555 + 92a5b37 commit 42c53e7

File tree

5 files changed

+64
-3
lines changed

5 files changed

+64
-3
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
},
2121
"license": "BSD-3-Clause",
2222
"dependencies": {
23-
"es6-map": "^0.1.3",
2423
"hoist-non-react-statics": "^1.0.5",
2524
"lodash": "^4.6.1",
2625
"object-unfreeze": "^1.0.2"

src/generateAppendClassName.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Map from 'es6-map';
1+
import Map from './simple-map';
22

33
const stylesIndex = new Map();
44

src/makeConfiguration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import _ from 'lodash';
2-
import Map from 'es6-map';
2+
import Map from './simple-map';
33

44
const userConfigurationIndex = new Map();
55

src/simple-map.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
export class SimpleMap {
2+
constructor () {
3+
this.keys = [];
4+
this.values = [];
5+
}
6+
7+
get size () {
8+
return this.keys.length;
9+
}
10+
11+
get (key) {
12+
const index = this.keys.indexOf(key);
13+
14+
return this.values[index];
15+
}
16+
17+
set (key, value) {
18+
this.keys.push(key);
19+
this.values.push(value);
20+
21+
return value;
22+
}
23+
}
24+
25+
const exportedMap = typeof Map === 'undefined' ? SimpleMap : Map;
26+
27+
export default exportedMap;

tests/simple-map.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import {
2+
expect
3+
} from 'chai';
4+
import {SimpleMap} from './../src/simple-map';
5+
6+
const getTests = (map) => {
7+
return () => {
8+
const values = [
9+
[1, 'something'],
10+
['1', 'somethingElse'],
11+
[{}, []],
12+
[null, null]
13+
];
14+
15+
it('should set', () => {
16+
values.forEach(([key, value]) => {
17+
map.set(key, value);
18+
});
19+
expect(map.size).to.equal(values.length);
20+
});
21+
22+
it('should get', () => {
23+
values.forEach(([key, value]) => {
24+
expect(map.get(key)).to.equal(value);
25+
});
26+
});
27+
};
28+
};
29+
30+
describe('SimpleMap', () => {
31+
context('simple map with primitive or object as keys', getTests(new SimpleMap()));
32+
if (typeof Map !== 'undefined') {
33+
context('sanity - running tests against native Map', getTests(new Map()));
34+
}
35+
});

0 commit comments

Comments
 (0)