mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-07-31 20:11:55 +00:00
Merge pull request #299 from jonathan-s/number
Adds valueOf and toString to Number
This commit is contained in:
37
src/js.rs
37
src/js.rs
@@ -208,6 +208,41 @@ extern {
|
||||
pub fn entries(this: &Array) -> ArrayIterator;
|
||||
}
|
||||
|
||||
// Number.
|
||||
#[wasm_bindgen]
|
||||
extern {
|
||||
pub type Number;
|
||||
|
||||
/// The toLocaleString() method returns a string with a language sensitive
|
||||
/// representation of this number.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString
|
||||
#[wasm_bindgen(method, js_name = toLocaleString)]
|
||||
pub fn to_locale_string(this: &Number, locale: String) -> String;
|
||||
|
||||
/// The toPrecision() method returns a string representing the Number
|
||||
/// object to the specified precision.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision
|
||||
#[wasm_bindgen(catch, method, js_name = toPrecision)]
|
||||
pub fn to_precision(this: &Number, precision: u8) -> Result<String, JsValue>;
|
||||
|
||||
/// The toString() method returns a string representing the
|
||||
/// specified Number object.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString
|
||||
#[wasm_bindgen(catch, method, js_name = toString)]
|
||||
pub fn to_string(this: &Number, radix: u8) -> Result<String, JsValue>;
|
||||
|
||||
/// The valueOf() method returns the wrapped primitive value of
|
||||
/// a Number object.
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf
|
||||
#[wasm_bindgen(method, js_name = valueOf)]
|
||||
pub fn value_of(this: &Number) -> Number;
|
||||
|
||||
}
|
||||
|
||||
// Object.
|
||||
#[wasm_bindgen]
|
||||
extern {
|
||||
@@ -275,4 +310,4 @@ extern {
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice
|
||||
#[wasm_bindgen(method, js_class = "String")]
|
||||
pub fn slice(this: &JsString, start: u32, end: u32) -> JsString;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user