feat(parser): adds basic expressions to the parser.
Mostly copy pasta from angular.dart. Remove GetterFactory in favor for ClosureMap (which has basically the same implementation).
This commit is contained in:
@ -27,6 +27,26 @@ class IMPLEMENTS {
|
||||
|
||||
bool isPresent(obj) => obj != null;
|
||||
bool isBlank(obj) => obj == null;
|
||||
bool toBool(x) {
|
||||
if (x is bool) return x;
|
||||
if (x is num) return x != 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
autoConvertAdd(a, b) {
|
||||
if (a != null && b != null) {
|
||||
if (a is String && b is! String) {
|
||||
return a + b.toString();
|
||||
}
|
||||
if (a is! String && b is String) {
|
||||
return a.toString() + b;
|
||||
}
|
||||
return a + b;
|
||||
}
|
||||
if (a != null) return a;
|
||||
if (b != null) return b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
String stringify(obj) => obj.toString();
|
||||
|
||||
|
@ -20,6 +20,14 @@ export function isBlank(obj):boolean {
|
||||
return obj === undefined || obj === null;
|
||||
}
|
||||
|
||||
export function toBool(obj) {
|
||||
return !!obj;
|
||||
}
|
||||
|
||||
export function autoConvertAdd(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
export function stringify(token):string {
|
||||
if (typeof token === 'string') {
|
||||
return token;
|
||||
|
Reference in New Issue
Block a user