hubl/src/components/getRoute.js
Jean-Baptiste Pasquier 41a2910a4a major: core 0.16
2021-03-16 15:27:30 +01:00

14 lines
470 B
JavaScript

window.hubl.getRoute = (type, returnFirst = false) => {
let availables = window.hubl.components.filter(c => c.type == type || c.uniq == type);
if (availables.length > 1) {
if (returnFirst) {
return availables[0].route;
} else {
console.error(`Too much components availables for route ${type}`);
}
} else if (availables.length < 1) {
console.error(`No component found for route ${type}`);
} else {
return availables[0].route;
}
}