String - toString and valueOf

This commit is contained in:
Lachezar Lechev
2018-06-26 22:21:51 +02:00
parent 9f087241a1
commit 16517fadcb
2 changed files with 66 additions and 0 deletions

View File

@ -644,6 +644,12 @@ extern {
#[wasm_bindgen(method, js_class = "String")]
pub fn substr(this: &JsString, start: i32, length: i32) -> JsString;
/// The toString() method returns a string representing the specified object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString
#[wasm_bindgen(method, js_class = "String", js_name = toString)]
pub fn to_string(this: &JsString) -> JsString;
/// The trim() method removes whitespace from both ends of a string.
/// Whitespace in this context is all the whitespace characters
/// (space, tab, no-break space, etc.) and all the line terminator characters (LF, CR, etc.).
@ -679,6 +685,12 @@ extern {
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart
#[wasm_bindgen(method, js_class = "String", js_name = trimLeft)]
pub fn trim_left(this: &JsString) -> JsString;
/// The valueOf() method returns the primitive value of a String object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/valueOf
#[wasm_bindgen(method, js_class = "String", js_name = valueOf)]
pub fn value_of(this: &JsString) -> JsString;
}
impl<'a> From<&'a str> for JsString {