cartodb-4.42/lib/assets/javascripts/new-dashboard/utils/dynamic-import.js
2024-04-06 05:25:13 +00:00

17 lines
457 B
JavaScript

export function importFilesFrom (folderContext, patternNameRegex) {
const components = {};
folderContext.keys().forEach(filename => {
const name = stripTokenFromString(filename, patternNameRegex);
const component = folderContext(filename);
components[name] = component.default;
});
return components;
}
function stripTokenFromString (string, patternNameRegex) {
const results = patternNameRegex.exec(string);
return results[1];
}