Created
January 6, 2017 19:07
-
-
Save gabrielschulhof/ffd0a7e323ddb6c17bee9d1e16bc627f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool napi_instanceof(napi_env e, napi_value o, napi_value c) { | |
v8::Isolate *isolate = v8impl::V8IsolateFromJsEnv(e); | |
v8::Local<v8::Value> obj = v8impl::V8LocalValueFromJsValue(o); | |
v8::Local<v8::Value> consProto = v8impl::V8LocalValueFromJsValue(c) | |
->ToObject()->Get(v8::String::NewFromUtf8(isolate, "prototype")); | |
v8::Local<v8::String> protoString = | |
v8::String::NewFromUtf8(isolate, "__proto__"); | |
while (!obj->IsNull()) { | |
if (obj->StrictEquals(consProto)) { | |
return true; | |
} | |
obj = obj->ToObject()->Get(protoString); | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment