当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ListWrapper.sort方法代码示例

本文整理汇总了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);
}
开发者ID:ChinnasamyM,项目名称:angular,代码行数:10,代码来源:public_api_spec.ts

示例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;
     });
   }
 }
开发者ID:ProjectFrank,项目名称:angular,代码行数:28,代码来源:perflog_metric.ts

示例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;
}
开发者ID:AsherBarak,项目名称:angular,代码行数:40,代码来源:utils.ts


注:本文中的angular2/src/facade/collection.ListWrapper.sort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。