@tencentcloud/call-uikit-vue
Version:
An Open-source Voice & Video Calling UI Component Based on Tencent Cloud Service.
35 lines (30 loc) • 866 B
text/typescript
export function classNames(...rest) {
const classes = [];
const hasOwn = {}.hasOwnProperty;
for (let i = 0; i < rest.length; i++) {
const arg = rest[i];
if (!arg) continue;
const argType = typeof arg;
if (argType === 'string' || argType === 'number') {
classes.push(arg);
} else if (Array.isArray(arg)) {
if (arg.length) {
const inner = classNames.apply(null, arg);
if (inner) {
classes.push(inner);
}
}
} else if (argType === 'object') {
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
classes.push(arg.toString());
continue;
}
for (const key in arg) {
if (hasOwn.call(arg, key) && arg[key]) {
classes.push(key);
}
}
}
}
return classes.join(' ');
}