fix(lib): simplify type checks

This commit is contained in:
PalmDevs 2025-04-16 16:17:43 +07:00
parent b29e1bc2f6
commit 8da47da0f9
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA
2 changed files with 2 additions and 2 deletions

View file

@ -79,7 +79,7 @@ export function isModuleExportsBad(exports: Metro.ModuleExports): boolean {
// Isn't an object or function?
// - Number exports are not useful, usually just an asset ID
// - String, Boolean, Symbol, BigInt exports are not useful (who would do `module.exports = ...`?)
!(typeof exports === 'object' || exports.__proto__ === Function.prototype) ||
!(typeof exports === 'object' || typeof exports === 'function') ||
// Checking if the object is empty
(exports.__proto__ === Object.prototype && !Reflect.ownKeys(exports).length)
)

View file

@ -36,7 +36,7 @@ const _proxifyHandler = {
const target = unproxifyFromHint(hint)
const val = Reflect.get(target!, p, recv)
if (val && val.__proto__ === Function.prototype)
if (typeof val === 'function')
return new Proxy(val, {
// If thisArg happens to be a proxified value, we will use the target object instead
apply: (fn, thisArg, args) => Reflect.apply(fn, thisArg === recv ? target : thisArg, args),