refactor: gather
This commit is contained in:
parent
b9e3ac433b
commit
263cf37e27
|
@ -4,16 +4,16 @@ function capitalize(string) {
|
|||
|
||||
export default function gather(imports, options = {}) {
|
||||
const {
|
||||
mapperForPath = (path) => path.replace(/\.\/(.*)\.js/, '$1'),
|
||||
} = options;
|
||||
const Gathered = {};
|
||||
for (const [path, Component] of Object.entries(imports).sort(([l], [r]) => l < r ? -1 : 1)) {
|
||||
Gathered[
|
||||
mapperForPath(path)
|
||||
pathToKey = (path) => (
|
||||
path.replace(/\.\/(.*)\.js/, '$1')
|
||||
.split('-')
|
||||
.map(capitalize)
|
||||
.join('')
|
||||
] = Component;
|
||||
),
|
||||
} = options;
|
||||
const Gathered = {};
|
||||
for (const [path, Component] of Object.entries(imports).sort(([l], [r]) => l < r ? -1 : 1)) {
|
||||
Gathered[pathToKey(path)] = Component;
|
||||
}
|
||||
return Gathered;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user