feat(RegExp): expose match indexes in Dart

This commit is contained in:
Victor Berchet
2015-02-26 16:31:56 +01:00
parent 009e11a6be
commit 06f7481141
2 changed files with 36 additions and 2 deletions

View File

@ -137,14 +137,24 @@ class RegExpWrapper {
}
class RegExpMatcherWrapper {
static Match next(Iterator<Match> matcher) {
static _JSLikeMatch next(Iterator<Match> matcher) {
if (matcher.moveNext()) {
return matcher.current;
return new _JSLikeMatch(matcher.current);
}
return null;
}
}
class _JSLikeMatch {
Match _m;
_JSLikeMatch(this._m);
String operator[](index) => _m[index];
int get index => _m.start;
int get length => _m.groupCount + 1;
}
class FunctionWrapper {
static apply(Function fn, posArgs) {
return Function.apply(fn, posArgs);