Skip to content

Commit 8f6f84e

Browse files
committed
Add asinh to Math
1 parent 0dc199f commit 8f6f84e

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/js.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,14 @@ extern {
266266
#[wasm_bindgen(static_method_of = Math)]
267267
pub fn asin(number: i32) -> Number;
268268

269+
/// The Math.asinh() function returns the hyperbolic arcsine of a
270+
/// number, that is Math.asinh(x) = arsinh(x) = the unique y such that sinh(y) = x
271+
///
272+
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh
273+
#[wasm_bindgen(static_method_of = Math)]
274+
pub fn asinh(number: i32) -> Number;
275+
276+
269277
}
270278

271279
// Number.

tests/all/js_globals/Math.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,29 @@ fn asin() {
108108
"#)
109109
.test()
110110
}
111+
112+
#[test]
113+
fn asinh() {
114+
project()
115+
.file("src/lib.rs", r#"
116+
#![feature(proc_macro, wasm_custom_section)]
117+
118+
extern crate wasm_bindgen;
119+
use wasm_bindgen::prelude::*;
120+
use wasm_bindgen::js;
121+
122+
#[wasm_bindgen]
123+
pub fn asinh(number: i32) -> js::Number {
124+
js::Math::asinh(number)
125+
}
126+
"#)
127+
.file("test.ts", r#"
128+
import * as assert from "assert";
129+
import * as wasm from "./out";
130+
131+
export function test() {
132+
assert.equal(wasm.asinh(1), Math.asinh(1));
133+
}
134+
"#)
135+
.test()
136+
}

0 commit comments

Comments
 (0)