export class ClassUtil {

    //======================================================================
    /** 대상이 class 키워드를 통해 정의된 클래스인지 검사
    *///====================================================================
    public static IsClassDefinition(obj: any): boolean {
        if (typeof obj !== "function") return false;
        
        try {
            obj(); // 일반 함수를 호출하면 정상 실행될 수 있음.
            return false;
        } catch (error) {
            // 클래스는 new 없이 호출하면 반드시 에러 발생
            return /Class constructor/.test(String(error));
        }
    }

    //======================================================================
    /** 대상이 class 키워드를 통해 생성된 클래스의 객체인지 검사
    *///====================================================================
    public static IsClassInstance(obj: any): boolean {
        return (
            typeof obj === "object" &&
            obj !== null &&
            obj.constructor !== Object &&
            typeof obj.constructor === "function" &&
            typeof obj.constructor.prototype === "object"
        );
    }
}