function capitalize(string) { return string.charAt(0).toUpperCase() + string.slice(1); } export default function gather(imports, options = {}) { const { mapperForPath = (path) => path.replace(/\.\/(.*)\.js/, '$1'), } = options; const Gathered = {}; let id = 1; for (const [path, Component] of Object.entries(imports).sort(([l], [r]) => l < r ? -1 : 1)) { const key = mapperForPath(path) .split('-') .map(capitalize) .join(''); if (Component.gathered) { Component.gathered(id, key); } Gathered[key] = Gathered[id] = Component; id += 1; } return Gathered; }