Skip to content

Commit

Permalink
Fixed linting
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary authored and Michael-F-Bryan committed Nov 21, 2023
1 parent bebfd61 commit 6cee243
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ fn on_start() {
console_error_panic_hook::set_once();
}


#[wasm_bindgen(js_name = setWorkerUrl)]
pub fn set_worker_url(url: js_sys::JsString) {
crate::utils::set_worker_url(url);
Expand Down
11 changes: 9 additions & 2 deletions src/tasks/worker_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,15 @@ static WORKER_URL: Lazy<String> = Lazy::new(|| {
}

tracing::trace!(import_url = IMPORT_META_URL.as_str());
tracing::trace!(custom_worker_url = CUSTOM_WORKER_URL.as_ref().unwrap_or(&"".to_string()).as_str());
let import_url: String = CUSTOM_WORKER_URL.to_owned().unwrap_or(IMPORT_META_URL.to_string());
tracing::trace!(
custom_worker_url = CUSTOM_WORKER_URL
.as_ref()
.unwrap_or(&"".to_string())
.as_str()
);
let import_url: String = CUSTOM_WORKER_URL
.to_owned()
.unwrap_or(IMPORT_META_URL.to_string());

let script = include_str!("worker.js").replace("$IMPORT_META_URL", &import_url);

Expand Down
10 changes: 3 additions & 7 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
num::NonZeroUsize,
};

use js_sys::{JsString, Promise, global};
use js_sys::{global, JsString, Promise};

use wasm_bindgen::{JsCast, JsValue};
use web_sys::{Window, WorkerGlobalScope};
Expand Down Expand Up @@ -253,11 +253,7 @@ pub(crate) fn js_record_of_strings(obj: &js_sys::Object) -> Result<Vec<(String,
Ok(parsed)
}


pub(crate) fn set_worker_url(url: JsString) {
js_sys::Reflect::set(
&global(),
&JsString::from("customWorkerUrl"),
&url,
).expect("Can't set worker url in the global JS scope");
js_sys::Reflect::set(&global(), &JsString::from("customWorkerUrl"), &url)
.expect("Can't set worker url in the global JS scope");
}

0 comments on commit 6cee243

Please sign in to comment.