fps-import: support fps version 1.4

This commit is contained in:
undefined committed 2022-11-10 13:33:49 +08:00
1 parent bd1034eff8
commit 88613c8a05
3 files changed
+23 -20

No files matched your search

+3 -3
View File
@@ -64,13 +64,13 @@ String.prototype.format = function formatStr(...args) {
return result;
};
export function isClass(obj: any, strict = false) {
export function isClass(obj: any, strict = false): obj is new (...args: any) => any {
if (typeof obj !== 'function') return false;
const str = obj.toString();
if (obj.prototype === undefined) return false;
if (obj.prototype.constructor !== obj) return false;
if (str.slice(0, 5) === 'class') return true;
if (Object.getOwnPropertyNames(obj.prototype).length >= 2) return true;
const str = obj.toString();
if (str.slice(0, 5) === 'class') return true;
if (/^function\s+\(|^function\s+anonymous\(/.test(str)) return false;
if (strict && /^function\s+[A-Z]/.test(str)) return true;
if (/\b\(this\b|\bthis[.[]\b/.test(str)) {