String - substr() support

This commit is contained in:
Lachezar Lechev
2018-06-24 23:03:39 +02:00
parent 7936e1eb27
commit b81dc46220
2 changed files with 44 additions and 0 deletions

View File

@ -340,6 +340,14 @@ 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;
/// The substr() method returns the part of a string between
/// the start index and a number of characters after it.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr
/// TODO: Add `NaN` and `undefined` support
#[wasm_bindgen(method, js_class = "String")]
pub fn substr(this: &JsString, start: i32, length: i32) -> JsString;
}
impl<'a> From<&'a str> for JsString {