Skip to content

Commit ddfa9a5

Browse files
committed
Caching configuration to prefer forEach.
1 parent 2d7c2f6 commit ddfa9a5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/makeConfiguration.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import _ from 'lodash';
2+
import Map from 'es6-map';
3+
4+
let userConfigurationIndex;
5+
6+
userConfigurationIndex = new Map();
27

38
/**
49
* @typedef CSSModules~Options
@@ -14,6 +19,12 @@ import _ from 'lodash';
1419
export default (userConfiguration = {}) => {
1520
let configuration;
1621

22+
configuration = userConfigurationIndex.get(userConfiguration);
23+
24+
if (configuration) {
25+
return configuration;
26+
}
27+
1728
configuration = {
1829
allowMultiple: false,
1930
errorWhenNotFound: true
@@ -31,5 +42,7 @@ export default (userConfiguration = {}) => {
3142
configuration[name] = value;
3243
});
3344

45+
userConfigurationIndex.set(userConfiguration, configuration);
46+
3447
return configuration;
3548
};

0 commit comments

Comments
 (0)