mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-17 15:01:23 +00:00
bindings for parseInt/parseFloat (#384)
* parseInt, parseFloat, JsValue::is_nan * Number.parseInt, Number.parseFloat * remove `JsValue::is_nan` * parse_int/float returns f64
This commit is contained in:
committed by
Alex Crichton
parent
d6a0b34480
commit
bfec9e6401
28
src/js.rs
28
src/js.rs
@ -87,6 +87,20 @@ extern "C" {
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite
|
||||
#[wasm_bindgen(js_name = isFinite)]
|
||||
pub fn is_finite(value: &JsValue) -> bool;
|
||||
|
||||
/// The `parseInt()` function parses a string argument and returns an integer
|
||||
/// of the specified radix (the base in mathematical numeral systems), or NaN on error.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt
|
||||
#[wasm_bindgen(js_name = parseInt)]
|
||||
pub fn parse_int(text: &str, radix: u8) -> f64;
|
||||
|
||||
/// The parseFloat() function parses an argument and returns a floating point number,
|
||||
/// or NaN on error.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat
|
||||
#[wasm_bindgen(js_name = parseFloat)]
|
||||
pub fn parse_float(text: &str) -> f64;
|
||||
}
|
||||
|
||||
// UInt8Array
|
||||
@ -780,6 +794,20 @@ extern "C" {
|
||||
#[wasm_bindgen(constructor)]
|
||||
pub fn new(value: JsValue) -> Number;
|
||||
|
||||
/// The Number.parseInt() method parses a string argument and returns an
|
||||
/// integer of the specified radix or base.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt
|
||||
#[wasm_bindgen(static_method_of = Number, js_name = parseInt)]
|
||||
pub fn parse_int(text: &str, radix: u8) -> Number;
|
||||
|
||||
/// The Number.parseFloat() method parses a string argument and returns a
|
||||
/// floating point number.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat
|
||||
#[wasm_bindgen(static_method_of = Number, js_name = parseFloat)]
|
||||
pub fn parse_float(text: &str) -> Number;
|
||||
|
||||
/// The toLocaleString() method returns a string with a language sensitive
|
||||
/// representation of this number.
|
||||
///
|
||||
|
Reference in New Issue
Block a user