本文整理汇总了TypeScript中angular2/src/facade/collection.StringMapWrapper.keys方法的典型用法代码示例。如果您正苦于以下问题:TypeScript StringMapWrapper.keys方法的具体用法?TypeScript StringMapWrapper.keys怎么用?TypeScript StringMapWrapper.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/src/facade/collection.StringMapWrapper
的用法示例。
在下文中一共展示了StringMapWrapper.keys方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: endMeasure
/**
* Ends measuring.
*/
endMeasure(restart: boolean): Promise<{[key: string]: any}> {
let completer = PromiseWrapper.completer<{[key: string]: any}>();
let adapter = this._wdAdapter;
let names = StringMapWrapper.keys(this._userMetrics);
function getAndClearValues() {
PromiseWrapper.all(names.map(name => adapter.executeScript(`return window.${name}`)))
.then((values: any[]) => {
if (values.every(isNumber)) {
PromiseWrapper.all(names.map(name => adapter.executeScript(`delete window.${name}`)))
.then((_: any[]) => {
let map = StringMapWrapper.create();
for (let i = 0, n = names.length; i < n; i++) {
StringMapWrapper.set(map, names[i], values[i]);
}
completer.resolve(map);
}, completer.reject);
} else {
TimerWrapper.setTimeout(getAndClearValues, 100);
}
}, completer.reject);
}
getAndClearValues();
return completer.promise;
}
示例2: recognize
/**
* Given a URL and a parent component, return the most specific instruction for navigating
* the application into the state specified by the
*/
recognize(url: string, parentComponent): Instruction {
var componentRecognizer = MapWrapper.get(this._rules, parentComponent);
if (isBlank(componentRecognizer)) {
return null;
}
// Matches some beginning part of the given URL
var possibleMatches = componentRecognizer.recognize(url);
// A list of instructions that captures all of the given URL
var fullSolutions = ListWrapper.create();
for (var i = 0; i < possibleMatches.length; i++) {
var candidate: RouteMatch = possibleMatches[i];
// if the candidate captures all of the URL, add it to our list of solutions
if (candidate.unmatchedUrl.length == 0) {
ListWrapper.push(fullSolutions, routeMatchToInstruction(candidate, parentComponent));
} else {
// otherwise, recursively match the remaining part of the URL against the component's
// children
var children = StringMapWrapper.create(), allChildrenMatch = true,
components = StringMapWrapper.get(candidate.handler, 'components');
var componentNames = StringMapWrapper.keys(components);
for (var nameIndex = 0; nameIndex < componentNames.length; nameIndex++) {
var name = componentNames[nameIndex];
var component = StringMapWrapper.get(components, name);
var childInstruction = this.recognize(candidate.unmatchedUrl, component);
if (isPresent(childInstruction)) {
childInstruction.params = candidate.params;
children[name] = childInstruction;
} else {
allChildrenMatch = false;
break;
}
}
if (allChildrenMatch) {
ListWrapper.push(fullSolutions, new Instruction({
component: parentComponent,
children: children,
matchedUrl: candidate.matchedUrl,
parentSpecificity: candidate.specificity
}));
}
}
}
if (fullSolutions.length > 0) {
var mostSpecificSolution = fullSolutions[0];
for (var solutionIndex = 1; solutionIndex < fullSolutions.length; solutionIndex++) {
var solution = fullSolutions[solutionIndex];
if (solution.specificity > mostSpecificSolution.specificity) {
mostSpecificSolution = solution;
}
}
return mostSpecificSolution;
}
return null;
}