當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript lang.isPresent函數代碼示例

本文整理匯總了TypeScript中@angular/facade/src/lang.isPresent函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isPresent函數的具體用法?TypeScript isPresent怎麽用?TypeScript isPresent使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了isPresent函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: sample

  sample({id, execute, prepare, microMetrics, providers, userMetrics}: {
    id: string,
    execute?: any,
    prepare?: any,
    microMetrics?: any,
    providers?: any,
    userMetrics?: any
  }): Promise<SampleState> {
    var sampleProviders = [
      _DEFAULT_PROVIDERS, this._defaultProviders, {provide: Options.SAMPLE_ID, useValue: id},
      {provide: Options.EXECUTE, useValue: execute}
    ];
    if (isPresent(prepare)) {
      sampleProviders.push({provide: Options.PREPARE, useValue: prepare});
    }
    if (isPresent(microMetrics)) {
      sampleProviders.push({provide: Options.MICRO_METRICS, useValue: microMetrics});
    }
    if (isPresent(userMetrics)) {
      sampleProviders.push({provide: Options.USER_METRICS, useValue: userMetrics});
    }
    if (isPresent(providers)) {
      sampleProviders.push(providers);
    }

    var inj = ReflectiveInjector.resolveAndCreate(sampleProviders);
    var adapter = inj.get(WebDriverAdapter);

    return Promise
        .all([adapter.capabilities(), adapter.executeScript('return window.navigator.userAgent;')])
        .then((args) => {
          var capabilities = args[0];
          var userAgent = args[1];

          // This might still create instances twice. We are creating a new injector with all the
          // providers.
          // Only WebDriverAdapter is reused.
          // TODO vsavkin consider changing it when toAsyncFactory is added back or when child
          // injectors are handled better.
          var injector = ReflectiveInjector.resolveAndCreate([
            sampleProviders, {provide: Options.CAPABILITIES, useValue: capabilities},
            {provide: Options.USER_AGENT, useValue: userAgent},
            {provide: WebDriverAdapter, useValue: adapter}
          ]);

          var sampler = injector.get(Sampler);
          return sampler.sample();
        });
  }
開發者ID:xavier268,項目名稱:angular,代碼行數:49,代碼來源:runner.ts

示例2: it

 it('should write all data into a file', inject([AsyncTestCompleter], (async) => {
      createReporter({
        sampleId: 'someId',
        descriptions: [{'a': 2}],
        path: 'somePath',
        metrics: {'script': 'script time'}
      })
          .reportSample(
              [mv(0, 0, {'a': 3, 'b': 6})],
              [mv(0, 0, {'a': 3, 'b': 6}), mv(1, 1, {'a': 5, 'b': 9})]);
      var regExp = /somePath\/someId_\d+\.json/g;
      expect(isPresent(RegExpWrapper.firstMatch(regExp, loggedFile['filename']))).toBe(true);
      var parsedContent = Json.parse(loggedFile['content']);
      expect(parsedContent).toEqual({
        'description':
            {'id': 'someId', 'description': {'a': 2}, 'metrics': {'script': 'script time'}},
        'completeSample': [
          {'timeStamp': '1970-01-01T00:00:00.000Z', 'runIndex': 0, 'values': {'a': 3, 'b': 6}}
        ],
        'validSample': [
          {'timeStamp': '1970-01-01T00:00:00.000Z', 'runIndex': 0, 'values': {'a': 3, 'b': 6}}, {
            'timeStamp': '1970-01-01T00:00:00.001Z',
            'runIndex': 1,
            'values': {'a': 5, 'b': 9}
          }
        ]
      });
      async.done();
    }));
開發者ID:chong999,項目名稱:angular,代碼行數:29,代碼來源:json_file_reporter_spec.ts

示例3: timeEnd

 timeEnd(name: string, restartName: string = null): Promise<any> {
   var script = `console.timeEnd('${name}');`;
   if (isPresent(restartName)) {
     script += `console.time('${restartName}');`;
   }
   return this._driver.executeScript(script);
 }
開發者ID:xavier268,項目名稱:angular,代碼行數:7,代碼來源:ios_driver_extension.ts

示例4: bindAction

 bindAction('#reset-btn', () => {
   this._getScrollDiv().scrollTop = 0;
   var existingMarker = this._locateFinishedMarker();
   if (isPresent(existingMarker)) {
     DOM.removeChild(document.body, existingMarker);
   }
 });
開發者ID:Jake-Church,項目名稱:angular,代碼行數:7,代碼來源:app.ts

示例5: loop

 return this._iterate(lastState).then((newState) => {
   if (isPresent(newState.validSample)) {
     return newState;
   } else {
     return loop(newState);
   }
 });
開發者ID:chong999,項目名稱:angular,代碼行數:7,代碼來源:sampler.ts

示例6: timeEnd

 timeEnd(name: string, restartName: string = null): Promise<any> {
   var script = 'window.markEnd("' + name + '");';
   if (isPresent(restartName)) {
     script += 'window.markStart("' + restartName + '");';
   }
   return this._driver.executeScript(script);
 }
開發者ID:Jake-Church,項目名稱:angular,代碼行數:7,代碼來源:firefox_driver_extension.ts

示例7: _findStartingNode

function _findStartingNode(segment: UrlSegment, node: TreeNode<UrlSegment>): TreeNode<UrlSegment> {
  if (node.value === segment) return node;
  for (var c of node.children) {
    let r = _findStartingNode(segment, c);
    if (isPresent(r)) return r;
  }
  return null;
}
開發者ID:davewragg,項目名稱:angular,代碼行數:8,代碼來源:link.ts

示例8: createMetric

 function createMetric(
     perfLogs, perfLogFeatures,
     {microMetrics, forceGc, captureFrames, receivedData, requestCount}: {
       microMetrics?: {[key: string]: string},
       forceGc?: boolean,
       captureFrames?: boolean,
       receivedData?: boolean,
       requestCount?: boolean
     } = {}): Metric {
   commandLog = [];
   if (isBlank(perfLogFeatures)) {
     perfLogFeatures =
         new PerfLogFeatures({render: true, gc: true, frameCapture: true, userTiming: true});
   }
   if (isBlank(microMetrics)) {
     microMetrics = StringMapWrapper.create();
   }
   var providers: Provider[] = [
     Options.DEFAULT_PROVIDERS, PerflogMetric.PROVIDERS,
     {provide: Options.MICRO_METRICS, useValue: microMetrics}, {
       provide: PerflogMetric.SET_TIMEOUT,
       useValue: (fn, millis) => {
         commandLog.push(['setTimeout', millis]);
         fn();
       },
     },
     {
       provide: WebDriverExtension,
       useValue: new MockDriverExtension(perfLogs, commandLog, perfLogFeatures)
     }
   ];
   if (isPresent(forceGc)) {
     providers.push({provide: Options.FORCE_GC, useValue: forceGc});
   }
   if (isPresent(captureFrames)) {
     providers.push({provide: Options.CAPTURE_FRAMES, useValue: captureFrames});
   }
   if (isPresent(receivedData)) {
     providers.push({provide: Options.RECEIVED_DATA, useValue: receivedData});
   }
   if (isPresent(requestCount)) {
     providers.push({provide: Options.REQUEST_COUNT, useValue: requestCount});
   }
   return ReflectiveInjector.resolveAndCreate(providers).get(PerflogMetric);
 }
開發者ID:xavier268,項目名稱:angular,代碼行數:45,代碼來源:perflog_metric_spec.ts

示例9: _processAsPostChrome44Event

 private _processAsPostChrome44Event(event, categories) {
   var name = event['name'];
   var args = event['args'];
   if (this._isEvent(categories, name, ['devtools.timeline', 'v8'], 'MajorGC')) {
     var normArgs = {
       'majorGc': true,
       'usedHeapSize': isPresent(args['usedHeapSizeAfter']) ? args['usedHeapSizeAfter'] :
                                                              args['usedHeapSizeBefore']
     };
     return normalizeEvent(event, {'name': 'gc', 'args': normArgs});
   } else if (this._isEvent(categories, name, ['devtools.timeline', 'v8'], 'MinorGC')) {
     var normArgs = {
       'majorGc': false,
       'usedHeapSize': isPresent(args['usedHeapSizeAfter']) ? args['usedHeapSizeAfter'] :
                                                              args['usedHeapSizeBefore']
     };
     return normalizeEvent(event, {'name': 'gc', 'args': normArgs});
   } else if (
       this._isEvent(categories, name, ['devtools.timeline', 'v8'], 'FunctionCall') &&
       (isBlank(args) || isBlank(args['data']) ||
        (!StringWrapper.equals(args['data']['scriptName'], 'InjectedScript') &&
         !StringWrapper.equals(args['data']['scriptName'], '')))) {
     return normalizeEvent(event, {'name': 'script'});
   } else if (this._isEvent(
                  categories, name, ['devtools.timeline', 'blink'], 'UpdateLayoutTree')) {
     return normalizeEvent(event, {'name': 'render'});
   } else if (
       this._isEvent(categories, name, ['devtools.timeline'], 'UpdateLayerTree') ||
       this._isEvent(categories, name, ['devtools.timeline'], 'Layout') ||
       this._isEvent(categories, name, ['devtools.timeline'], 'Paint')) {
     return normalizeEvent(event, {'name': 'render'});
   } else if (this._isEvent(categories, name, ['devtools.timeline'], 'ResourceReceivedData')) {
     let normArgs = {'encodedDataLength': args['data']['encodedDataLength']};
     return normalizeEvent(event, {'name': 'receivedData', 'args': normArgs});
   } else if (this._isEvent(categories, name, ['devtools.timeline'], 'ResourceSendRequest')) {
     let data = args['data'];
     let normArgs = {'url': data['url'], 'method': data['requestMethod']};
     return normalizeEvent(event, {'name': 'sendRequest', 'args': normArgs});
   } else if (this._isEvent(categories, name, ['blink.user_timing'], 'navigationStart')) {
     return normalizeEvent(event, {'name': name});
   }
   return null;  // nothing useful in this event
 }
開發者ID:chong999,項目名稱:angular,代碼行數:43,代碼來源:chrome_driver_extension.ts

示例10: _report

 /** @internal */
 private _report(state: SampleState, metricValues: {[key: string]: any}): Promise<SampleState> {
   var measureValues = new MeasureValues(state.completeSample.length, this._now(), metricValues);
   var completeSample = state.completeSample.concat([measureValues]);
   var validSample = this._validator.validate(completeSample);
   var resultPromise = this._reporter.reportMeasureValues(measureValues);
   if (isPresent(validSample)) {
     resultPromise =
         resultPromise.then((_) => this._reporter.reportSample(completeSample, validSample));
   }
   return resultPromise.then((_) => new SampleState(completeSample, validSample));
 }
開發者ID:chong999,項目名稱:angular,代碼行數:12,代碼來源:sampler.ts


注:本文中的@angular/facade/src/lang.isPresent函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。