@fesjs/fes-design
Version:
fes-design for PC
29 lines (26 loc) • 681 B
JavaScript
import { noop } from './utils';
function withInstall(main, extra, directives) {
const _main = main;
_main.install = app => {
for (const comp of [main, ...Object.values(extra !== null && extra !== void 0 ? extra : {})]) {
app.component(comp.name, comp);
}
if (directives) {
for (const directive of directives) {
app.directive(directive.name, directive);
}
}
};
if (extra) {
for (const [key, comp] of Object.entries(extra)) {
_main[key] = comp;
}
}
return _main;
}
function withNoopInstall(component) {
const _main = component;
_main.install = noop;
return _main;
}
export { withInstall, withNoopInstall };