cartodb-4.42/lib/assets/javascripts/new-dashboard/utils/dynamic-import.js

17 lines
457 B
JavaScript
Raw Normal View History

2024-04-06 13:25:13 +08:00
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];
}