From 930219fc5317fc928e5ba7cbf5f4dd0a5bbf9c10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Flemstr=C3=B6m?= Date: Sun, 25 Mar 2018 12:15:34 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20some=20JS=20=3D=3D=20=E2=86=92=20=3D=3D?= =?UTF-8?q?=3D=20and=20!=3D=20=E2=86=92=20!=3D=3D=20occurrences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are the ones my linter complained about in particular --- DESIGN.md | 2 +- crates/wasm-bindgen-cli-support/src/js.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 8037b8a6..63395b2c 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -203,7 +203,7 @@ let slab = []; let slab_next = 0; function addHeapObject(obj) { - if (slab_next == slab.length) + if (slab_next === slab.length) slab.push(slab.length + 1); const idx = slab_next; const next = slab[idx]; diff --git a/crates/wasm-bindgen-cli-support/src/js.rs b/crates/wasm-bindgen-cli-support/src/js.rs index 89764958..f8ddba53 100644 --- a/crates/wasm-bindgen-cli-support/src/js.rs +++ b/crates/wasm-bindgen-cli-support/src/js.rs @@ -148,7 +148,7 @@ impl<'a> Context<'a> { bind("__wbindgen_boolean_new", &|me| { me.expose_add_heap_object(); String::from("function(v) { - return addHeapObject(v == 1); + return addHeapObject(v === 1); }") }); @@ -156,7 +156,7 @@ impl<'a> Context<'a> { me.expose_get_object(); String::from("function(i) { let v = getObject(i); - if (typeof(v) == 'boolean') { + if (typeof(v) === 'boolean') { return v ? 1 : 0; } else { return 2; @@ -182,7 +182,7 @@ impl<'a> Context<'a> { bind("__wbindgen_is_symbol", &|me| { me.expose_get_object(); String::from("function(i) { - return typeof(getObject(i)) == 'symbol' ? 1 : 0; + return typeof(getObject(i)) === 'symbol' ? 1 : 0; }") }); @@ -924,7 +924,7 @@ impl<'a> Context<'a> { }; self.globals.push_str(&format!(" function addHeapObject(obj) {{ - if (slab_next == slab.length) + if (slab_next === slab.length) slab.push(slab.length + 1); const idx = slab_next; const next = slab[idx]; @@ -1227,7 +1227,7 @@ impl<'a, 'b> SubContext<'a, 'b> { } Some(shared::TYPE_BOOLEAN) => { dst_ts.push_str(": boolean"); - format!("return ret != 0;") + format!("return ret !== 0;") } Some(shared::TYPE_JS_OWNED) => { dst_ts.push_str(": any"); @@ -1351,7 +1351,7 @@ impl<'a, 'b> SubContext<'a, 'b> { abi_args.push(format!("arg{}", i)); } shared::TYPE_BOOLEAN => { - invoc_args.push(format!("arg{} != 0", i)); + invoc_args.push(format!("arg{} !== 0", i)); abi_args.push(format!("arg{}", i)); } shared::TYPE_BORROWED_STR |