aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/bindings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/bindings/bindings.cpp')
-rw-r--r--src/bun.js/bindings/bindings.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp
index 9e0857578..f273bca46 100644
--- a/src/bun.js/bindings/bindings.cpp
+++ b/src/bun.js/bindings/bindings.cpp
@@ -3791,6 +3791,27 @@ bool JSC__JSValue__isConstructor(JSC__JSValue JSValue0)
return value.isConstructor();
}
+bool JSC__JSValue__isInstanceOf(JSC__JSValue JSValue0, JSC__JSGlobalObject* globalObject, JSC__JSValue JSValue1)
+{
+ VM& vm = globalObject->vm();
+
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+
+ JSValue jsValue = JSValue::decode(JSValue0);
+ JSValue jsValue1 = JSValue::decode(JSValue1);
+ if (UNLIKELY(!jsValue1.isObject())) {
+ return false;
+ }
+ JSObject* jsConstructor = JSC::asObject(jsValue1);
+ if (UNLIKELY(!jsConstructor->structure()->typeInfo().implementsHasInstance()))
+ return false;
+ bool result = jsConstructor->hasInstance(globalObject, jsValue);
+
+ RETURN_IF_EXCEPTION(scope, false);
+
+ return result;
+}
+
extern "C" JSC__JSValue JSC__JSValue__createRopeString(JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* globalObject)
{
return JSValue::encode(JSC::jsString(globalObject, JSC::JSValue::decode(JSValue0).toString(globalObject), JSC::JSValue::decode(JSValue1).toString(globalObject)));