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


TypeScript ListWrapper.reduce方法代码示例

本文整理汇总了TypeScript中angular2/src/facade/collection.ListWrapper.reduce方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ListWrapper.reduce方法的具体用法?TypeScript ListWrapper.reduce怎么用?TypeScript ListWrapper.reduce使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2/src/facade/collection.ListWrapper的用法示例。


在下文中一共展示了ListWrapper.reduce方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: _addFrameMetrics

 _addFrameMetrics(result: StringMap<string, any>, frameTimes: any[]) {
   result['frameTime.mean'] =
       ListWrapper.reduce(frameTimes, (a, b) => a + b, 0) / frameTimes.length;
   var firstFrame = ListWrapper.get(frameTimes, 0);
   result['frameTime.worst'] = ListWrapper.reduce(frameTimes, (a, b) => a > b ? a : b, firstFrame);
   result['frameTime.best'] = ListWrapper.reduce(frameTimes, (a, b) => a < b ? a : b, firstFrame);
   result['frameTime.smooth'] =
       ListWrapper.filter(frameTimes, (a) => a < _FRAME_TIME_SMOOTH_THRESHOLD).length /
       frameTimes.length;
 }
开发者ID:goderbauer,项目名称:angular,代码行数:10,代码来源:perflog_metric.ts

示例2: function

 return function(c) {
   var res = ListWrapper.reduce(validators, (res, validator) => {
     var errors = validator(c);
     return isPresent(errors) ? StringMapWrapper.merge(res, errors) : res;
   }, {});
   return StringMapWrapper.isEmpty(res) ? null : res;
 };
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:7,代码来源:validators.ts

示例3: addPipes

  addPipes(bindingAst: ASTWithSource, pipes: List<string>): ASTWithSource {
    if (ListWrapper.isEmpty(pipes)) return bindingAst;

    var res: AST = ListWrapper.reduce(
        pipes, (result, currentPipeName) => new Pipe(result, currentPipeName, [], false),
        bindingAst.ast);
    return new ASTWithSource(res, bindingAst.source, bindingAst.location);
  }
开发者ID:188799958,项目名称:angular,代码行数:8,代码来源:parser.ts

示例4: _aggregateEvents


//.........这里部分代码省略.........
        name = microIterationsMatch[1];
        microIterations = NumberWrapper.parseInt(microIterationsMatch[2], 10);
      }

      if (StringWrapper.equals(ph, 'b') && StringWrapper.equals(name, markName)) {
        markStartEvent = event;
      } else if (StringWrapper.equals(ph, 'e') && StringWrapper.equals(name, markName)) {
        markEndEvent = event;
      }

      if (isPresent(markStartEvent) && isBlank(markEndEvent) &&
          event['pid'] === markStartEvent['pid']) {
        if (StringWrapper.equals(ph, 'b') && StringWrapper.equals(name, _MARK_NAME_FRAME_CAPUTRE)) {
          if (isPresent(frameCaptureStartEvent)) {
            throw new BaseException('can capture frames only once per benchmark run');
          }
          if (!this._captureFrames) {
            throw new BaseException(
                'found start event for frame capture, but frame capture was not requested in benchpress')
          }
          frameCaptureStartEvent = event;
        } else if (StringWrapper.equals(ph, 'e') &&
                   StringWrapper.equals(name, _MARK_NAME_FRAME_CAPUTRE)) {
          if (isBlank(frameCaptureStartEvent)) {
            throw new BaseException('missing start event for frame capture');
          }
          frameCaptureEndEvent = event;
        }

        if (StringWrapper.equals(ph, 'I') || StringWrapper.equals(ph, 'i')) {
          if (isPresent(frameCaptureStartEvent) && isBlank(frameCaptureEndEvent) &&
              StringWrapper.equals(name, 'frame')) {
            ListWrapper.push(frameTimestamps, event['ts']);
            if (frameTimestamps.length >= 2) {
              ListWrapper.push(frameTimes, frameTimestamps[frameTimestamps.length - 1] -
                                               frameTimestamps[frameTimestamps.length - 2]);
            }
          }
        }

        if (StringWrapper.equals(ph, 'B') || StringWrapper.equals(ph, 'b')) {
          if (isBlank(intervalStarts[name])) {
            intervalStartCount[name] = 1;
            intervalStarts[name] = event;
          } else {
            intervalStartCount[name]++;
          }
        } else if ((StringWrapper.equals(ph, 'E') || StringWrapper.equals(ph, 'e')) &&
                   isPresent(intervalStarts[name])) {
          intervalStartCount[name]--;
          if (intervalStartCount[name] === 0) {
            var startEvent = intervalStarts[name];
            var duration = (event['ts'] - startEvent['ts']);
            intervalStarts[name] = null;
            if (StringWrapper.equals(name, 'gc')) {
              result['gcTime'] += duration;
              var amount =
                  (startEvent['args']['usedHeapSize'] - event['args']['usedHeapSize']) / 1000;
              result['gcAmount'] += amount;
              var majorGc = event['args']['majorGc'];
              if (isPresent(majorGc) && majorGc) {
                result['majorGcTime'] += duration;
              }
              if (isPresent(intervalStarts['script'])) {
                gcTimeInScript += duration;
              }
            } else if (StringWrapper.equals(name, 'render')) {
              result['renderTime'] += duration;
              if (isPresent(intervalStarts['script'])) {
                renderTimeInScript += duration;
              }
            } else if (StringWrapper.equals(name, 'script')) {
              result['scriptTime'] += duration;
            } else if (isPresent(this._microMetrics[name])) {
              result[name] += duration / microIterations;
            }
          }
        }
      }
    });
    if (!isPresent(markStartEvent) || !isPresent(markEndEvent)) {
      // not all events have been received, no further processing for now
      return null;
    }

    if (isPresent(markEndEvent) && isPresent(frameCaptureStartEvent) &&
        isBlank(frameCaptureEndEvent)) {
      throw new BaseException('missing end event for frame capture');
    }
    if (this._captureFrames && isBlank(frameCaptureStartEvent)) {
      throw new BaseException(
          'frame capture requested in benchpress, but no start event was found');
    }
    if (frameTimes.length > 0) {
      result['meanFrameTime'] =
          ListWrapper.reduce(frameTimes, (a, b) => a + b, 0) / frameTimes.length;
    }
    result['pureScriptTime'] = result['scriptTime'] - gcTimeInScript - renderTimeInScript;
    return result;
  }
开发者ID:B-Thapa,项目名称:angular,代码行数:101,代码来源:perflog_metric.ts


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