Skip to content

Commit

Permalink
feat(core): implement Deno.core.isProxy()
Browse files Browse the repository at this point in the history
Another binding ... but it's required for denoland#12286 and could be useful elsewhere
  • Loading branch information
AaronO committed Oct 1, 2021
1 parent 5065c7b commit b43138d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ lazy_static::lazy_static! {
v8::ExternalReference {
function: get_proxy_details.map_fn_to()
},
v8::ExternalReference {
function: is_proxy.map_fn_to()
},
v8::ExternalReference {
function: memory_usage.map_fn_to(),
},
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b43138d

Please sign in to comment.