All files util.ts

100% Statements 25/25
100% Branches 16/16
100% Functions 5/5
100% Lines 25/25

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 331x   1x   1x 21x 21x 68x 68x 21x 43x 43x 21x 21x   1x 62x 52x 52x 62x   62x   1x 44x   44x 14x 14x   22x 22x  
import { version } from 'vue';
 
export const isVue3 = version.startsWith('3.');
 
export function createSymbolProperty<T>(symbol: symbol) {
    return {
        set(instance: any, value: T): void {
            instance[symbol] = value;
        },
        get(instance: any): T | undefined {
            return symbol in instance ? instance[symbol] : void 0;
        }
    } as const;
}
 
export function isESModule(obj: unknown): obj is Record<string | symbol, any> {
    if (!obj || typeof obj !== 'object') return false;
    const module = obj as Record<string | symbol, any>;
    return (
        Boolean(module.__esModule) || module[Symbol.toStringTag] === 'Module'
    );
}
 
export function resolveComponent(component: unknown): unknown {
    if (!component) return null;
 
    if (isESModule(component)) {
        return component.default || component;
    }
 
    return component;
}