fix(types): Add StringMap type
This commit is contained in:
parent
56f4e84d45
commit
cd90038950
@ -1,6 +1,6 @@
|
|||||||
import {isBlank, isPresent, BaseException, stringify} from 'angular2/src/facade/lang';
|
import {isBlank, isPresent, BaseException, stringify} from 'angular2/src/facade/lang';
|
||||||
import {DOM, Element} from 'angular2/src/facade/dom';
|
import {DOM, Element} from 'angular2/src/facade/dom';
|
||||||
import {StringMapWrapper} from 'angular2/src/facade/collection';
|
import {StringMapWrapper, StringMap} from 'angular2/src/facade/collection';
|
||||||
|
|
||||||
import {XHR} from './xhr/xhr';
|
import {XHR} from './xhr/xhr';
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ import {Template} from 'angular2/src/core/annotations/template';
|
|||||||
*/
|
*/
|
||||||
export class TemplateLoader {
|
export class TemplateLoader {
|
||||||
_xhr: XHR;
|
_xhr: XHR;
|
||||||
_cache;
|
_cache: StringMap;
|
||||||
|
|
||||||
constructor(xhr: XHR) {
|
constructor(xhr: XHR) {
|
||||||
this._xhr = xhr;
|
this._xhr = xhr;
|
||||||
|
@ -57,7 +57,6 @@ class MapWrapper {
|
|||||||
static Iterable values(Map m) => m.values;
|
static Iterable values(Map m) => m.values;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: how to export StringMap=Map as a type?
|
|
||||||
class StringMapWrapper {
|
class StringMapWrapper {
|
||||||
static HashMap create() => new HashMap();
|
static HashMap create() => new HashMap();
|
||||||
static bool contains(Map map, key) => map.containsKey(key);
|
static bool contains(Map map, key) => map.containsKey(key);
|
||||||
|
@ -3,6 +3,7 @@ import {int, isJsObject, global} from 'angular2/src/facade/lang';
|
|||||||
export var List = global.Array;
|
export var List = global.Array;
|
||||||
export var Map = global.Map;
|
export var Map = global.Map;
|
||||||
export var Set = global.Set;
|
export var Set = global.Set;
|
||||||
|
export var StringMap = global.Object;
|
||||||
|
|
||||||
export class MapWrapper {
|
export class MapWrapper {
|
||||||
static create():Map { return new Map(); }
|
static create():Map { return new Map(); }
|
||||||
@ -29,7 +30,6 @@ export class MapWrapper {
|
|||||||
static values(m) { return m.values(); }
|
static values(m) { return m.values(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: cannot export StringMap as a type as Dart does not support renaming types...
|
|
||||||
/**
|
/**
|
||||||
* Wraps Javascript Objects
|
* Wraps Javascript Objects
|
||||||
*/
|
*/
|
||||||
|
6
modules/angular2/src/forms/model.js
vendored
6
modules/angular2/src/forms/model.js
vendored
@ -1,4 +1,4 @@
|
|||||||
import {StringMapWrapper} from 'angular2/src/facade/collection';
|
import {StringMapWrapper, StringMap} from 'angular2/src/facade/collection';
|
||||||
|
|
||||||
export class Control {
|
export class Control {
|
||||||
value:any;
|
value:any;
|
||||||
@ -9,9 +9,9 @@ export class Control {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ControlGroup {
|
export class ControlGroup {
|
||||||
controls;
|
controls: StringMap;
|
||||||
|
|
||||||
constructor(controls) {
|
constructor(controls:StringMap) {
|
||||||
this.controls = controls;
|
this.controls = controls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { Date } from 'angular2/src/facade/lang';
|
import { Date } from 'angular2/src/facade/lang';
|
||||||
|
import { StringMap } from 'angular2/src/facade/collection';
|
||||||
|
|
||||||
export class MeasureValues {
|
export class MeasureValues {
|
||||||
timeStamp:Date;
|
timeStamp:Date;
|
||||||
runIndex:number;
|
runIndex:number;
|
||||||
values:any;
|
values:StringMap;
|
||||||
|
|
||||||
constructor(runIndex:number, timeStamp:Date, values:any) {
|
constructor(runIndex:number, timeStamp:Date, values:StringMap) {
|
||||||
this.timeStamp = timeStamp;
|
this.timeStamp = timeStamp;
|
||||||
this.runIndex = runIndex;
|
this.runIndex = runIndex;
|
||||||
this.values = values;
|
this.values = values;
|
||||||
|
@ -4,6 +4,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
ABSTRACT, BaseException
|
ABSTRACT, BaseException
|
||||||
} from 'angular2/src/facade/lang';
|
} from 'angular2/src/facade/lang';
|
||||||
|
import { StringMap } from 'angular2/src/facade/collection';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A metric is measures values
|
* A metric is measures values
|
||||||
@ -22,7 +23,7 @@ export class Metric {
|
|||||||
* since the begin call.
|
* since the begin call.
|
||||||
* @param restart: Whether to restart right after this.
|
* @param restart: Whether to restart right after this.
|
||||||
*/
|
*/
|
||||||
endMeasure(restart:boolean):Promise<any> {
|
endMeasure(restart:boolean):Promise<StringMap> {
|
||||||
throw new BaseException('NYI');
|
throw new BaseException('NYI');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ export class Metric {
|
|||||||
* Describes the metrics provided by this metric implementation.
|
* Describes the metrics provided by this metric implementation.
|
||||||
* (e.g. units, ...)
|
* (e.g. units, ...)
|
||||||
*/
|
*/
|
||||||
describe():any {
|
describe():StringMap {
|
||||||
throw new BaseException('NYI');
|
throw new BaseException('NYI');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { PromiseWrapper, Promise } from 'angular2/src/facade/async';
|
import { PromiseWrapper, Promise } from 'angular2/src/facade/async';
|
||||||
import { isPresent, isBlank, int, BaseException, StringWrapper } from 'angular2/src/facade/lang';
|
import { isPresent, isBlank, int, BaseException, StringWrapper } from 'angular2/src/facade/lang';
|
||||||
import { ListWrapper } from 'angular2/src/facade/collection';
|
import { ListWrapper, StringMap } from 'angular2/src/facade/collection';
|
||||||
import { bind, OpaqueToken } from 'angular2/di';
|
import { bind, OpaqueToken } from 'angular2/di';
|
||||||
|
|
||||||
import { WebDriverExtension } from '../web_driver_extension';
|
import { WebDriverExtension } from '../web_driver_extension';
|
||||||
@ -28,7 +28,7 @@ export class PerflogMetric extends Metric {
|
|||||||
this._setTimeout = setTimeout;
|
this._setTimeout = setTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe() {
|
describe():StringMap {
|
||||||
return {
|
return {
|
||||||
'script': 'script execution time in ms',
|
'script': 'script execution time in ms',
|
||||||
'render': 'render time in ms',
|
'render': 'render time in ms',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { StringMapWrapper, ListWrapper } from 'angular2/src/facade/collection';
|
import { StringMapWrapper, ListWrapper, StringMap } from 'angular2/src/facade/collection';
|
||||||
import { bind, OpaqueToken } from 'angular2/di';
|
import { bind, OpaqueToken } from 'angular2/di';
|
||||||
import { Sampler } from './sampler';
|
import { Sampler } from './sampler';
|
||||||
import { Validator } from './validator';
|
import { Validator } from './validator';
|
||||||
@ -13,10 +13,10 @@ export class SampleDescription {
|
|||||||
static get BINDINGS() { return _BINDINGS; }
|
static get BINDINGS() { return _BINDINGS; }
|
||||||
|
|
||||||
id:string;
|
id:string;
|
||||||
description:any;
|
description:StringMap;
|
||||||
metrics:any;
|
metrics:StringMap;
|
||||||
|
|
||||||
constructor(id, descriptions, metrics) {
|
constructor(id, descriptions:List<StringMap>, metrics:StringMap) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.metrics = metrics;
|
this.metrics = metrics;
|
||||||
this.description = {};
|
this.description = {};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { isPresent, isBlank, Date, DateWrapper } from 'angular2/src/facade/lang';
|
import { isPresent, isBlank, Date, DateWrapper } from 'angular2/src/facade/lang';
|
||||||
import { Promise, PromiseWrapper } from 'angular2/src/facade/async';
|
import { Promise, PromiseWrapper } from 'angular2/src/facade/async';
|
||||||
import { StringMapWrapper, List, ListWrapper } from 'angular2/src/facade/collection';
|
import { StringMapWrapper, StringMap, List, ListWrapper } from 'angular2/src/facade/collection';
|
||||||
import { bind, OpaqueToken } from 'angular2/di';
|
import { bind, OpaqueToken } from 'angular2/di';
|
||||||
|
|
||||||
import { Metric } from './metric';
|
import { Metric } from './metric';
|
||||||
@ -95,7 +95,7 @@ export class Sampler {
|
|||||||
.then( (measureValues) => this._report(lastState, measureValues) );
|
.then( (measureValues) => this._report(lastState, measureValues) );
|
||||||
}
|
}
|
||||||
|
|
||||||
_report(state:SampleState, metricValues:any):Promise<SampleState> {
|
_report(state:SampleState, metricValues:StringMap):Promise<SampleState> {
|
||||||
var measureValues = new MeasureValues(state.completeSample.length, this._time(), metricValues);
|
var measureValues = new MeasureValues(state.completeSample.length, this._time(), metricValues);
|
||||||
var completeSample = ListWrapper.concat(state.completeSample, [measureValues]);
|
var completeSample = ListWrapper.concat(state.completeSample, [measureValues]);
|
||||||
var validSample = this._validator.validate(completeSample);
|
var validSample = this._validator.validate(completeSample);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { List } from 'angular2/src/facade/collection';
|
import { List, StringMap } from 'angular2/src/facade/collection';
|
||||||
import {
|
import {
|
||||||
ABSTRACT, BaseException
|
ABSTRACT, BaseException
|
||||||
} from 'angular2/src/facade/lang';
|
} from 'angular2/src/facade/lang';
|
||||||
@ -23,7 +23,7 @@ export class Validator {
|
|||||||
* Returns a Map that describes the properties of the validator
|
* Returns a Map that describes the properties of the validator
|
||||||
* (e.g. sample size, ...)
|
* (e.g. sample size, ...)
|
||||||
*/
|
*/
|
||||||
describe():any {
|
describe():StringMap {
|
||||||
throw new BaseException('NYI');
|
throw new BaseException('NYI');
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
import { List, ListWrapper } from 'angular2/src/facade/collection';
|
import { List, ListWrapper, StringMap } from 'angular2/src/facade/collection';
|
||||||
import { bind, OpaqueToken } from 'angular2/di';
|
import { bind, OpaqueToken } from 'angular2/di';
|
||||||
|
|
||||||
import { Validator } from '../validator';
|
import { Validator } from '../validator';
|
||||||
@ -26,7 +26,7 @@ export class RegressionSlopeValidator extends Validator {
|
|||||||
this._metric = metric;
|
this._metric = metric;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe():any {
|
describe():StringMap {
|
||||||
return {
|
return {
|
||||||
'sampleSize': this._sampleSize,
|
'sampleSize': this._sampleSize,
|
||||||
'regressionSlopeMetric': this._metric
|
'regressionSlopeMetric': this._metric
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { List, ListWrapper } from 'angular2/src/facade/collection';
|
import { List, ListWrapper, StringMap } from 'angular2/src/facade/collection';
|
||||||
import { bind, OpaqueToken } from 'angular2/di';
|
import { bind, OpaqueToken } from 'angular2/di';
|
||||||
|
|
||||||
import { Validator } from '../validator';
|
import { Validator } from '../validator';
|
||||||
|
import { MeasureValues } from '../measure_values';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A validator that waits for the sample to have a certain size.
|
* A validator that waits for the sample to have a certain size.
|
||||||
@ -19,13 +20,13 @@ export class SizeValidator extends Validator {
|
|||||||
this._sampleSize = size;
|
this._sampleSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe():any {
|
describe():StringMap {
|
||||||
return {
|
return {
|
||||||
'sampleSize': this._sampleSize
|
'sampleSize': this._sampleSize
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
validate(completeSample:List<any>):List<any> {
|
validate(completeSample:List<MeasureValues>):List<MeasureValues> {
|
||||||
if (completeSample.length >= this._sampleSize) {
|
if (completeSample.length >= this._sampleSize) {
|
||||||
return ListWrapper.slice(completeSample, completeSample.length - this._sampleSize, completeSample.length);
|
return ListWrapper.slice(completeSample, completeSample.length - this._sampleSize, completeSample.length);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
// JS -> Dart
|
||||||
export var typeMapping = {
|
export var typeMapping = {
|
||||||
'number': 'num',
|
'number': 'num',
|
||||||
'boolean': 'bool',
|
'boolean': 'bool',
|
||||||
'string': 'String',
|
'string': 'String',
|
||||||
'any': 'dynamic',
|
'any': 'dynamic',
|
||||||
'Promise': 'Future',
|
'Promise': 'Future',
|
||||||
'Date': 'DateTime'
|
'Date': 'DateTime',
|
||||||
|
'StringMap': 'Map'
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user