feat(facade/lang): support int
This commit is contained in:
parent
c7feaba1cb
commit
3482fb1291
|
@ -1,7 +1,7 @@
|
||||||
library angular.core.facade.async;
|
library angular.core.facade.async;
|
||||||
|
|
||||||
export 'dart:async' show Future;
|
export 'dart:async' show Future;
|
||||||
export 'dart:core' show Type;
|
export 'dart:core' show Type, int;
|
||||||
|
|
||||||
class FIELD {
|
class FIELD {
|
||||||
const constructor(this.definition);
|
const constructor(this.definition);
|
||||||
|
|
|
@ -13,11 +13,11 @@ export class IMPLEMENTS {}
|
||||||
|
|
||||||
|
|
||||||
export class StringWrapper {
|
export class StringWrapper {
|
||||||
static fromCharCode(code:number/*int*/) {
|
static fromCharCode(code:int) {
|
||||||
return String.fromCharCode(code);
|
return String.fromCharCode(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static charCodeAt(s:string, index:number/*int*/) {
|
static charCodeAt(s:string, index:int) {
|
||||||
return s.charCodeAt(index);
|
return s.charCodeAt(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,16 +37,16 @@ export class StringJoiner {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NumberWrapper {
|
export class NumberWrapper {
|
||||||
static parseIntAutoRadix(text:string):number/*int*/ {
|
static parseIntAutoRadix(text:string):int {
|
||||||
var result:number/*int*/ = parseInt(text);
|
var result:int = parseInt(text);
|
||||||
if (isNaN(result)) {
|
if (isNaN(result)) {
|
||||||
throw new Error("Invalid integer literal when parsing " + text);
|
throw new Error("Invalid integer literal when parsing " + text);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static parseInt(text:string, radix:number/*int*/):number/*int*/ {
|
static parseInt(text:string, radix:int):int {
|
||||||
var result:number/*int*/ = parseInt(text, radix);
|
var result:int = parseInt(text, radix);
|
||||||
if (isNaN(result)) {
|
if (isNaN(result)) {
|
||||||
throw new Error("Invalid integer literal when parsing " + text + " in base " + radix);
|
throw new Error("Invalid integer literal when parsing " + text + " in base " + radix);
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,12 @@ export class NumberWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: NaN is a valid literal but is returned by parseFloat to indicate an error.
|
// TODO: NaN is a valid literal but is returned by parseFloat to indicate an error.
|
||||||
static parseFloat(text:string):number/*int*/ {
|
static parseFloat(text:string):number {
|
||||||
return parseFloat(text);
|
return parseFloat(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function int() {};
|
||||||
|
int.assert = function(value) {
|
||||||
|
return value == null || typeof value == 'number' && value === Math.floor(value);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue