Skip to content

Commit fa97453

Browse files
committed
Add atanh to Math
1 parent 884b50d commit fa97453

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
@@ -286,6 +286,14 @@ extern {
286286
#[wasm_bindgen(static_method_of = Math)]
287287
pub fn atan2(y: i32, x: i32) -> Number;
288288

289+
/// The Math.atanh() function returns the hyperbolic arctangent of a number,
290+
/// that is ∀x ∊ (-1,1), Math.atanh(x) = arctanh(x) = the unique y such that
291+
/// tanh(y) = x
292+
///
293+
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh
294+
#[wasm_bindgen(static_method_of = Math)]
295+
pub fn atanh(x: i32) -> Number;
296+
289297
}
290298

291299
// Number.

tests/all/js_globals/Math.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,29 @@ fn atan2() {
186186
"#)
187187
.test()
188188
}
189+
190+
#[test]
191+
fn atanh() {
192+
project()
193+
.file("src/lib.rs", r#"
194+
#![feature(proc_macro, wasm_custom_section)]
195+
196+
extern crate wasm_bindgen;
197+
use wasm_bindgen::prelude::*;
198+
use wasm_bindgen::js;
199+
200+
#[wasm_bindgen]
201+
pub fn atanh(x: i32) -> js::Number {
202+
js::Math::atanh(x)
203+
}
204+
"#)
205+
.file("test.ts", r#"
206+
import * as assert from "assert";
207+
import * as wasm from "./out";
208+
209+
export function test() {
210+
assert.equal(wasm.atanh(1), Math.atanh(1));
211+
}
212+
"#)
213+
.test()
214+
}

0 commit comments

Comments
 (0)