From caa86a07a01c408a8b57e10a6d521d6c549614ac Mon Sep 17 00:00:00 2001 From: Samuel Warfield Date: Thu, 27 Jun 2019 15:48:18 -0600 Subject: [PATCH] Attempted to tackle #1622 --- crates/js-sys/src/lib.rs | 40 ++++++++++++++++++++++++++-- crates/js-sys/tests/wasm/Function.rs | 2 +- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/crates/js-sys/src/lib.rs b/crates/js-sys/src/lib.rs index 5dd1a8be..c11902de 100644 --- a/crates/js-sys/src/lib.rs +++ b/crates/js-sys/src/lib.rs @@ -1076,8 +1076,44 @@ extern "C" { /// with a given sequence of arguments preceding any provided when the new function is called. /// /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind) - #[wasm_bindgen(method)] - pub fn bind(this: &Function, context: &JsValue) -> Function; + #[wasm_bindgen(method, js_name = bind)] + pub fn bind0(this: &Function, context: &JsValue) -> Function; + + /// The bind() method creates a new function that, when called, has its this keyword set to the provided value, + /// with a given sequence of arguments preceding any provided when the new function is called. + /// + /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind) + #[wasm_bindgen(method, js_name = bind)] + pub fn bind1( + this: &Function, + context: &JsValue, + arg1: &JsValue, + ) -> Function; + + /// The bind() method creates a new function that, when called, has its this keyword set to the provided value, + /// with a given sequence of arguments preceding any provided when the new function is called. + /// + /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind) + #[wasm_bindgen(method, js_name = bind)] + pub fn bind2( + this: &Function, + context: &JsValue, + arg1: &JsValue, + arg2: &JsValue, + ) -> Function; + + /// The bind() method creates a new function that, when called, has its this keyword set to the provided value, + /// with a given sequence of arguments preceding any provided when the new function is called. + /// + /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind) + #[wasm_bindgen(method, js_name = bind)] + pub fn bind3( + this: &Function, + context: &JsValue, + arg1: &JsValue, + arg2: &JsValue, + arg3: &JsValue, + ) -> Function; /// The length property indicates the number of arguments expected by the function. /// diff --git a/crates/js-sys/tests/wasm/Function.rs b/crates/js-sys/tests/wasm/Function.rs index b3ad413b..34faf1a9 100644 --- a/crates/js-sys/tests/wasm/Function.rs +++ b/crates/js-sys/tests/wasm/Function.rs @@ -40,7 +40,7 @@ extern "C" { #[wasm_bindgen_test] fn bind() { let f = get_function_to_bind(); - let new_f = f.bind(&get_value_to_bind_to()); + let new_f = f.bind0(&get_value_to_bind_to()); assert_eq!(call_function(f), 1); assert_eq!(call_function(new_f), 2); }