本文整理汇总了TypeScript中angular2/src/facade/collection.ListWrapper.sort方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ListWrapper.sort方法的具体用法?TypeScript ListWrapper.sort怎么用?TypeScript ListWrapper.sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/src/facade/collection.ListWrapper
的用法示例。
在下文中一共展示了ListWrapper.sort方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: diff
function diff(actual: string[], expected: string[]): string[] {
ListWrapper.sort(actual, compareIgnoreLang);
ListWrapper.sort(expected, compareIgnoreLang);
let mode = IS_DART ? "dart" : "js";
let missing = actual.filter(i => expected.indexOf(i) < 0 && expected.indexOf(`${i}:${mode}`) < 0)
.map(s => `+${s}`);
let extra = expected.filter(i => shouldIgnore(i) ? false : (actual.indexOf(stripLang(i)) < 0))
.map(s => `-${s}`);
return ListWrapper.concat(missing, extra);
}
示例2: _addEvents
_addEvents(events: { [key: string]: string }[]) {
var needSort = false;
events.forEach(event => {
if (StringWrapper.equals(event['ph'], 'X')) {
needSort = true;
var startEvent = {};
var endEvent = {};
StringMapWrapper.forEach(event, (value, prop) => {
startEvent[prop] = value;
endEvent[prop] = value;
});
startEvent['ph'] = 'B';
endEvent['ph'] = 'E';
endEvent['ts'] = startEvent['ts'] + startEvent['dur'];
this._remainingEvents.push(startEvent);
this._remainingEvents.push(endEvent);
} else {
this._remainingEvents.push(event);
}
});
if (needSort) {
// Need to sort because of the ph==='X' events
ListWrapper.sort(this._remainingEvents, (a, b) => {
var diff = a['ts'] - b['ts'];
return diff > 0 ? 1 : diff < 0 ? -1 : 0;
});
}
}
示例3: stringifyElement
export function stringifyElement(el): string {
var result = '';
if (DOM.isElementNode(el)) {
var tagName = StringWrapper.toLowerCase(DOM.tagName(el));
// Opening tag
result += `<${tagName}`;
// Attributes in an ordered way
var attributeMap = DOM.attributeMap(el);
var keys = [];
MapWrapper.forEach(attributeMap, (v, k) => { keys.push(k); });
ListWrapper.sort(keys);
for (let i = 0; i < keys.length; i++) {
var key = keys[i];
var attValue = MapWrapper.get(attributeMap, key);
if (!isString(attValue)) {
result += ` ${key}`;
} else {
result += ` ${key}="${attValue}"`;
}
}
result += '>';
// Children
var children = DOM.childNodes(DOM.templateAwareRoot(el));
for (let j = 0; j < children.length; j++) {
result += stringifyElement(children[j]);
}
// Closing tag
if (!ListWrapper.contains(_singleTagWhitelist, tagName)) {
result += `</${tagName}>`;
}
} else {
result += DOM.getText(el);
}
return result;
}