summaryrefslogtreecommitdiff
path: root/core/bindings.rs
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-10-01 20:25:33 +0200
committerGitHub <noreply@github.com>2021-10-01 20:25:33 +0200
commit26de5165589ea10567d59ce7f630ec521cce6083 (patch)
tree66961c42cfa5a1659efc5bcd8e0d3aa88a6f6720 /core/bindings.rs
parent1dfa35b2ba1dadf0158a00b72e98d83cd3e69ee5 (diff)
feat(core): implement Deno.core.isProxy() (#12288)
Diffstat (limited to 'core/bindings.rs')
-rw-r--r--core/bindings.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/bindings.rs b/core/bindings.rs
index 3bff22e50..aff632161 100644
--- a/core/bindings.rs
+++ b/core/bindings.rs
@@ -64,6 +64,9 @@ lazy_static::lazy_static! {
function: get_proxy_details.map_fn_to()
},
v8::ExternalReference {
+ function: is_proxy.map_fn_to()
+ },
+ v8::ExternalReference {
function: memory_usage.map_fn_to(),
},
v8::ExternalReference {
@@ -146,6 +149,7 @@ pub fn initialize_context<'s>(
set_func(scope, core_val, "deserialize", deserialize);
set_func(scope, core_val, "getPromiseDetails", get_promise_details);
set_func(scope, core_val, "getProxyDetails", get_proxy_details);
+ set_func(scope, core_val, "isProxy", is_proxy);
set_func(scope, core_val, "memoryUsage", memory_usage);
set_func(scope, core_val, "callConsole", call_console);
set_func(scope, core_val, "createHostObject", create_host_object);
@@ -1119,6 +1123,14 @@ fn get_proxy_details(
rv.set(to_v8(scope, p).unwrap());
}
+fn is_proxy(
+ scope: &mut v8::HandleScope,
+ args: v8::FunctionCallbackArguments,
+ mut rv: v8::ReturnValue,
+) {
+ rv.set(v8::Boolean::new(scope, args.get(0).is_proxy()).into())
+}
+
fn throw_type_error(scope: &mut v8::HandleScope, message: impl AsRef<str>) {
let message = v8::String::new(scope, message.as_ref()).unwrap();
let exception = v8::Exception::type_error(scope, message);