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