From 890f2f527f6750438dc68bafd05f93932d415749 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Wed, 17 Aug 2022 22:46:45 +0100 Subject: [PATCH] Add a placeholder for JavaScript fetch() function --- lib/src/fnc/script/globals/fetch.rs | 10 ++++++++++ lib/src/fnc/script/globals/mod.rs | 1 + lib/src/fnc/script/main.rs | 2 ++ 3 files changed, 13 insertions(+) create mode 100644 lib/src/fnc/script/globals/fetch.rs diff --git a/lib/src/fnc/script/globals/fetch.rs b/lib/src/fnc/script/globals/fetch.rs new file mode 100644 index 00000000..44754d2d --- /dev/null +++ b/lib/src/fnc/script/globals/fetch.rs @@ -0,0 +1,10 @@ +use crate::sql::value::Value; +use js::Rest; +use js::Result; + +#[js::bind(object, public)] +#[quickjs(rename = "fetch")] +#[allow(unused_variables)] +pub fn fetch(args: Rest) -> Result { + Ok(Value::None) +} diff --git a/lib/src/fnc/script/globals/mod.rs b/lib/src/fnc/script/globals/mod.rs index 95383506..df38b675 100644 --- a/lib/src/fnc/script/globals/mod.rs +++ b/lib/src/fnc/script/globals/mod.rs @@ -1 +1,2 @@ pub mod surrealdb; +pub mod fetch; diff --git a/lib/src/fnc/script/main.rs b/lib/src/fnc/script/main.rs index 7d2e3874..bcddb930 100644 --- a/lib/src/fnc/script/main.rs +++ b/lib/src/fnc/script/main.rs @@ -39,6 +39,8 @@ pub async fn run( let global = ctx.globals(); // Register the surrealdb module as a global object global.init_def::().unwrap(); + // Register the fetch function as a global object + global.init_def::()?; // Register the Duration type as a global class global.init_def::().unwrap(); // Register the Record type as a global class