• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript di.provide函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@angular/core/src/di.provide函数的典型用法代码示例。如果您正苦于以下问题:TypeScript provide函数的具体用法?TypeScript provide怎么用?TypeScript provide使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _markName

  _markName(index) { return `${_MARK_NAME_PREFIX}${index}`; }
}

var _MICRO_ITERATIONS_REGEX = /(.+)\*(\d+)$/g;

var _MAX_RETRY_COUNT = 20;
var _MARK_NAME_PREFIX = 'benchpress';
var _SET_TIMEOUT = new OpaqueToken('PerflogMetric.setTimeout');

var _MARK_NAME_FRAME_CAPUTRE = 'frameCapture';
// using 17ms as a somewhat looser threshold, instead of 16.6666ms
var _FRAME_TIME_SMOOTH_THRESHOLD = 17;

var _PROVIDERS = [
  bind(PerflogMetric)
      .toFactory(
          (driverExtension, setTimeout, microMetrics, forceGc, captureFrames, receivedData,
           requestCount) => new PerflogMetric(driverExtension, setTimeout, microMetrics, forceGc,
                                              captureFrames, receivedData, requestCount),
          [
            WebDriverExtension,
            _SET_TIMEOUT,
            Options.MICRO_METRICS,
            Options.FORCE_GC,
            Options.CAPTURE_FRAMES,
            Options.RECEIVED_DATA,
            Options.REQUEST_COUNT
          ]),
  provide(_SET_TIMEOUT, {useValue: (fn, millis) => TimerWrapper.setTimeout(fn, millis)})
];
开发者ID:0xJoKe,项目名称:angular,代码行数:30,代码来源:perflog_metric.ts


示例2: validate

  validate(completeSample: MeasureValues[]): MeasureValues[] {
    if (completeSample.length >= this._sampleSize) {
      var latestSample = ListWrapper.slice(completeSample, completeSample.length - this._sampleSize,
                                           completeSample.length);
      var xValues = [];
      var yValues = [];
      for (var i = 0; i < latestSample.length; i++) {
        // For now, we only use the array index as x value.
        // TODO(tbosch): think about whether we should use time here instead
        xValues.push(i);
        yValues.push(latestSample[i].values[this._metric]);
      }
      var regressionSlope = Statistic.calculateRegressionSlope(
          xValues, Statistic.calculateMean(xValues), yValues, Statistic.calculateMean(yValues));
      return regressionSlope >= 0 ? latestSample : null;
    } else {
      return null;
    }
  }
}

var _SAMPLE_SIZE = new OpaqueToken('RegressionSlopeValidator.sampleSize');
var _METRIC = new OpaqueToken('RegressionSlopeValidator.metric');
var _PROVIDERS = [
  bind(RegressionSlopeValidator)
      .toFactory((sampleSize, metric) => new RegressionSlopeValidator(sampleSize, metric),
                 [_SAMPLE_SIZE, _METRIC]),
  provide(_SAMPLE_SIZE, {useValue: 10}),
  provide(_METRIC, {useValue: 'scriptTime'})
];
开发者ID:0xJoKe,项目名称:angular,代码行数:30,代码来源:regression_slope_validator.ts


示例3: _printStringRow

    this._printStringRow(this._metricNames.map(metricName => {
      var samples = validSamples.map(measureValues => measureValues.values[metricName]);
      var mean = Statistic.calculateMean(samples);
      var cv = Statistic.calculateCoefficientOfVariation(samples, mean);
      var formattedMean = ConsoleReporter._formatNum(mean)
                              // Note: Don't use the unicode character for +- as it might cause
                              // hickups for consoles...
                              return NumberWrapper.isNaN(cv) ?
                              formattedMean :
                              `${formattedMean}+-${Math.floor(cv)}%`;
    }));
    return PromiseWrapper.resolve(null);
  }

  _printStringRow(parts: any[], fill = ' ') {
    this._print(
        parts.map(part => ConsoleReporter._lpad(part, this._columnWidth, fill)).join(' | '));
  }
}

var _PRINT = new OpaqueToken('ConsoleReporter.print');
var _COLUMN_WIDTH = new OpaqueToken('ConsoleReporter.columnWidth');
var _PROVIDERS = [
  bind(ConsoleReporter)
      .toFactory((columnWidth, sampleDescription, print) =>
                     new ConsoleReporter(columnWidth, sampleDescription, print),
                 [_COLUMN_WIDTH, SampleDescription, _PRINT]),
  provide(_COLUMN_WIDTH, {useValue: 18}),
  provide(_PRINT, {useValue: print})
];
开发者ID:0xJoKe,项目名称:angular,代码行数:30,代码来源:console_reporter.ts


示例4: CAPTURE_FRAMES

  static get CAPTURE_FRAMES() { return _CAPTURE_FRAMES; }
}

var _SAMPLE_ID = new OpaqueToken('Options.sampleId');
var _DEFAULT_DESCRIPTION = new OpaqueToken('Options.defaultDescription');
var _SAMPLE_DESCRIPTION = new OpaqueToken('Options.sampleDescription');
var _FORCE_GC = new OpaqueToken('Options.forceGc');
var _PREPARE = new OpaqueToken('Options.prepare');
var _EXECUTE = new OpaqueToken('Options.execute');
var _CAPABILITIES = new OpaqueToken('Options.capabilities');
var _USER_AGENT = new OpaqueToken('Options.userAgent');
var _MICRO_METRICS = new OpaqueToken('Options.microMetrics');
var _NOW = new OpaqueToken('Options.now');
var _WRITE_FILE = new OpaqueToken('Options.writeFile');
var _RECEIVED_DATA = new OpaqueToken('Options.receivedData');
var _REQUEST_COUNT = new OpaqueToken('Options.requestCount');
var _CAPTURE_FRAMES = new OpaqueToken('Options.frameCapture');

var _DEFAULT_PROVIDERS = [
  bind(_DEFAULT_DESCRIPTION)
      .toValue({}),
  provide(_SAMPLE_DESCRIPTION, {useValue: {}}),
  provide(_FORCE_GC, {useValue: false}),
  provide(_PREPARE, {useValue: false}),
  provide(_MICRO_METRICS, {useValue: {}}),
  provide(_NOW, {useValue: () => DateWrapper.now()}),
  provide(_RECEIVED_DATA, {useValue: false}),
  provide(_REQUEST_COUNT, {useValue: false}),
  provide(_CAPTURE_FRAMES, {useValue: false})
];
开发者ID:0xJoKe,项目名称:angular,代码行数:30,代码来源:common_options.ts


示例5: PROVIDERS

  // TODO(tbosch): use static values when our transpiler supports them
  static get PROVIDERS(): Provider[] { return _PROVIDERS; }
  // TODO(tbosch): use static values when our transpiler supports them
  static get SAMPLE_SIZE() { return _SAMPLE_SIZE; }

  _sampleSize: number;

  constructor(size) {
    super();
    this._sampleSize = size;
  }

  describe(): {[key: string]: any} { return {'sampleSize': this._sampleSize}; }

  validate(completeSample: MeasureValues[]): MeasureValues[] {
    if (completeSample.length >= this._sampleSize) {
      return ListWrapper.slice(completeSample, completeSample.length - this._sampleSize,
                               completeSample.length);
    } else {
      return null;
    }
  }
}

var _SAMPLE_SIZE = new OpaqueToken('SizeValidator.sampleSize');
var _PROVIDERS = [
  bind(SizeValidator)
      .toFactory((size) => new SizeValidator(size), [_SAMPLE_SIZE]),
  provide(_SAMPLE_SIZE, {useValue: 10})
];
开发者ID:0xJoKe,项目名称:angular,代码行数:30,代码来源:size_validator.ts


示例6: reportMeasureValues

    this._description = sampleDescription;
    this._path = path;
    this._writeFile = writeFile;
    this._now = now;
  }

  reportMeasureValues(measureValues: MeasureValues): Promise<any> {
    return PromiseWrapper.resolve(null);
  }

  reportSample(completeSample: MeasureValues[], validSample: MeasureValues[]): Promise<any> {
    var content = Json.stringify({
      'description': this._description,
      'completeSample': completeSample,
      'validSample': validSample
    });
    var filePath =
        `${this._path}/${this._description.id}_${DateWrapper.toMillis(this._now())}.json`;
    return this._writeFile(filePath, content);
  }
}

var _PATH = new OpaqueToken('JsonFileReporter.path');
var _PROVIDERS = [
  bind(JsonFileReporter)
      .toFactory((sampleDescription, path, writeFile, now) =>
                     new JsonFileReporter(sampleDescription, path, writeFile, now),
                 [SampleDescription, _PATH, Options.WRITE_FILE, Options.NOW]),
  provide(_PATH, {useValue: '.'})
];
开发者ID:0xJoKe,项目名称:angular,代码行数:30,代码来源:json_file_reporter.ts


示例7: OpaqueToken

import {topmost, Frame} from 'ui/frame';
import {Page} from 'ui/page';
import {provide, Provider, OpaqueToken} from '@angular/core/src/di';
import {device} from "platform";
import {NativeScriptAnimationDriver} from './animation-driver';
import {AnimationDriver} from "@angular/core/src/animation/animation_driver";

export const APP_ROOT_VIEW = new OpaqueToken('App Root View');
export const DEVICE = new OpaqueToken('platfrom device');

export const defaultPageProvider = provide(Page, { useFactory: getDefaultPage });

export function getDefaultPage(): Page {
    const frame = topmost();
    if (frame) {
        return frame.currentPage;
    } else {
        return null;
    }
}

export const defaultFrameProvider = provide(Frame, { useFactory: topmost });

export const defaultDeviceProvider = provide(DEVICE, { useValue: device });

export const defaultAnimationDriverProvider = provide(AnimationDriver, { useClass: NativeScriptAnimationDriver });
开发者ID:evenkeeler,项目名称:nativescript-angular,代码行数:26,代码来源:platform-providers.ts


示例8: OpaqueToken

import {topmost} from 'ui/frame';
import {Page} from 'ui/page';
import {provide, Provider, OpaqueToken} from '@angular/core/src/di';
import {Device, ScreenMetrics, device, screen} from "platform";

export const APP_ROOT_VIEW = new OpaqueToken('App Root View');
export const DEVICE = new OpaqueToken('platfrom device');

export const defaultPageProvider = provide(Page, { useFactory: getDefaultPage });

export function getDefaultPage(): Page {
    const frame = topmost();
    if (frame) {
        return frame.currentPage;
    } else {
        return null;
    }
}

export const defaultDeviceProvider = provide(DEVICE, { useValue: device });

开发者ID:AhmedRagheb,项目名称:nativescript-angular,代码行数:20,代码来源:platform-providers.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript di.Injector类代码示例发布时间:2022-05-28
下一篇:
TypeScript di.bind函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap