Skip to content

Commit caa86a0

Browse files
author
Samuel Warfield
committed
Attempted to tackle #1622
1 parent 792ab40 commit caa86a0

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

crates/js-sys/src/lib.rs

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,8 +1076,44 @@ extern "C" {
10761076
/// with a given sequence of arguments preceding any provided when the new function is called.
10771077
///
10781078
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
1079-
#[wasm_bindgen(method)]
1080-
pub fn bind(this: &Function, context: &JsValue) -> Function;
1079+
#[wasm_bindgen(method, js_name = bind)]
1080+
pub fn bind0(this: &Function, context: &JsValue) -> Function;
1081+
1082+
/// The bind() method creates a new function that, when called, has its this keyword set to the provided value,
1083+
/// with a given sequence of arguments preceding any provided when the new function is called.
1084+
///
1085+
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
1086+
#[wasm_bindgen(method, js_name = bind)]
1087+
pub fn bind1(
1088+
this: &Function,
1089+
context: &JsValue,
1090+
arg1: &JsValue,
1091+
) -> Function;
1092+
1093+
/// The bind() method creates a new function that, when called, has its this keyword set to the provided value,
1094+
/// with a given sequence of arguments preceding any provided when the new function is called.
1095+
///
1096+
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
1097+
#[wasm_bindgen(method, js_name = bind)]
1098+
pub fn bind2(
1099+
this: &Function,
1100+
context: &JsValue,
1101+
arg1: &JsValue,
1102+
arg2: &JsValue,
1103+
) -> Function;
1104+
1105+
/// The bind() method creates a new function that, when called, has its this keyword set to the provided value,
1106+
/// with a given sequence of arguments preceding any provided when the new function is called.
1107+
///
1108+
/// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind)
1109+
#[wasm_bindgen(method, js_name = bind)]
1110+
pub fn bind3(
1111+
this: &Function,
1112+
context: &JsValue,
1113+
arg1: &JsValue,
1114+
arg2: &JsValue,
1115+
arg3: &JsValue,
1116+
) -> Function;
10811117

10821118
/// The length property indicates the number of arguments expected by the function.
10831119
///

crates/js-sys/tests/wasm/Function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extern "C" {
4040
#[wasm_bindgen_test]
4141
fn bind() {
4242
let f = get_function_to_bind();
43-
let new_f = f.bind(&get_value_to_bind_to());
43+
let new_f = f.bind0(&get_value_to_bind_to());
4444
assert_eq!(call_function(f), 1);
4545
assert_eq!(call_function(new_f), 2);
4646
}

0 commit comments

Comments
 (0)