Add basic support for String.prototype.charAt() (#306)

* String - charAt() implementation

* String - charAt() - add js_class
This commit is contained in:
Lachezar Lechev
2018-06-25 20:24:44 +02:00
committed by Nick Fitzgerald
parent 245f0f0eea
commit d28d81f38d
2 changed files with 36 additions and 0 deletions

View File

@ -347,6 +347,13 @@ 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 String object's charAt() method returns a new string consisting of the single
/// UTF-16 code unit located at the specified offset into the string.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt
#[wasm_bindgen(method, js_class = "String", js_name = charAt)]
pub fn char_at(this: &JsString, index: u32) -> JsString;
}
impl<'a> From<&'a str> for JsString {