mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-01 18:01:06 +00:00
js-sys: add bindings for regexp.lastIndex
This commit is contained in:
parent
dc028d38c8
commit
178a5e89df
@ -2280,6 +2280,20 @@ extern {
|
|||||||
#[wasm_bindgen(static_method_of = RegExp, getter)]
|
#[wasm_bindgen(static_method_of = RegExp, getter)]
|
||||||
pub fn input() -> JsString;
|
pub fn input() -> JsString;
|
||||||
|
|
||||||
|
/// The lastIndex is a read/write integer property of regular expression
|
||||||
|
/// instances that specifies the index at which to start the next match.
|
||||||
|
///
|
||||||
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex
|
||||||
|
#[wasm_bindgen(structural, getter = lastIndex, method)]
|
||||||
|
pub fn last_index(this: &RegExp) -> u32;
|
||||||
|
|
||||||
|
/// The lastIndex is a read/write integer property of regular expression
|
||||||
|
/// instances that specifies the index at which to start the next match.
|
||||||
|
///
|
||||||
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex
|
||||||
|
#[wasm_bindgen(structural, setter = lastIndex, method)]
|
||||||
|
pub fn set_last_index(this: &RegExp, index: u32);
|
||||||
|
|
||||||
/// The non-standard lastMatch property is a static and read-only
|
/// The non-standard lastMatch property is a static and read-only
|
||||||
/// property of regular expressions that contains the last matched
|
/// property of regular expressions that contains the last matched
|
||||||
/// characters. RegExp.$& is an alias for this property.
|
/// characters. RegExp.$& is an alias for this property.
|
||||||
|
@ -56,6 +56,15 @@ fn input() {
|
|||||||
assert_eq!(RegExp::input(), "hi there!");
|
assert_eq!(RegExp::input(), "hi there!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn last_index() {
|
||||||
|
let re = RegExp::new("hi", "g");
|
||||||
|
assert_eq!(re.last_index(), 0);
|
||||||
|
|
||||||
|
re.set_last_index(42);
|
||||||
|
assert_eq!(re.last_index(), 42);
|
||||||
|
}
|
||||||
|
|
||||||
#[wasm_bindgen_test]
|
#[wasm_bindgen_test]
|
||||||
fn last_match() {
|
fn last_match() {
|
||||||
let re = RegExp::new("hi", "g");
|
let re = RegExp::new("hi", "g");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user