feat(facade/lang): add math and regexp support
This commit is contained in:
parent
cc115d58ca
commit
d4c099de8c
|
@ -1,6 +1,13 @@
|
|||
library angular.core.facade.lang;
|
||||
|
||||
export 'dart:core' show Type;
|
||||
export 'dart:core' show Type, RegExp;
|
||||
import 'dart:math' as math;
|
||||
|
||||
class Math {
|
||||
static final _random = new math.Random();
|
||||
static int floor(num n) => n.floor();
|
||||
static double random() => _random.nextDouble();
|
||||
}
|
||||
|
||||
class FIELD {
|
||||
final String definition;
|
||||
|
@ -58,3 +65,21 @@ class NumberWrapper {
|
|||
}
|
||||
}
|
||||
|
||||
class RegExpWrapper {
|
||||
static RegExp create(regExpStr) {
|
||||
return new RegExp(regExpStr);
|
||||
}
|
||||
static matcher(regExp, input) {
|
||||
return regExp.allMatches(input).iterator;
|
||||
}
|
||||
}
|
||||
|
||||
class RegExpMatcherWrapper {
|
||||
static next(matcher) {
|
||||
if (matcher.moveNext()) {
|
||||
return matcher.current;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
export var Type = Function;
|
||||
export var Math = window.Math;
|
||||
|
||||
export class FIELD {
|
||||
constructor(definition) {
|
||||
|
@ -107,3 +108,24 @@ export function int() {};
|
|||
int.assert = function(value) {
|
||||
return value == null || typeof value == 'number' && value === Math.floor(value);
|
||||
}
|
||||
|
||||
export var RegExp = window.RegExp;
|
||||
|
||||
export class RegExpWrapper {
|
||||
static create(regExpStr):RegExp {
|
||||
return new RegExp(regExpStr, 'g');
|
||||
}
|
||||
static matcher(regExp, input) {
|
||||
return {
|
||||
re: regExp,
|
||||
input: input
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class RegExpMatcherWrapper {
|
||||
static next(matcher) {
|
||||
return matcher.re.exec(matcher.input);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue