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


TypeScript RegExpWrapper.firstMatch方法代码示例

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


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

示例1: _format

 static _format(value: number, style: NumberFormatStyle, digits: string, currency: string = null,
                currencyAsSymbol: boolean = false): string {
   if (isBlank(value)) return null;
   if (!isNumber(value)) {
     throw new InvalidPipeArgumentException(NumberPipe, value);
   }
   var minInt = 1, minFraction = 0, maxFraction = 3;
   if (isPresent(digits)) {
     var parts = RegExpWrapper.firstMatch(_re, digits);
     if (isBlank(parts)) {
       throw new BaseException(`${digits} is not a valid digit info for number pipes`);
     }
     if (isPresent(parts[1])) {  // min integer digits
       minInt = NumberWrapper.parseIntAutoRadix(parts[1]);
     }
     if (isPresent(parts[3])) {  // min fraction digits
       minFraction = NumberWrapper.parseIntAutoRadix(parts[3]);
     }
     if (isPresent(parts[5])) {  // max fraction digits
       maxFraction = NumberWrapper.parseIntAutoRadix(parts[5]);
     }
   }
   return NumberFormatter.format(value, defaultLocale, style, {
     minimumIntegerDigits: minInt,
     minimumFractionDigits: minFraction,
     maximumFractionDigits: maxFraction,
     currency: currency,
     currencyAsSymbol: currencyAsSymbol
   });
 }
开发者ID:beta3000,项目名称:hola-angular2,代码行数:30,代码来源:number_pipe.ts

示例2: isPresent

 return StringWrapper.replaceAllMapped(cssText, _cssImportRe, (m) => {
   var url = isPresent(m[1]) ? m[1] : m[2];
   var schemeMatch = RegExpWrapper.firstMatch(_urlWithSchemaRe, url);
   if (isPresent(schemeMatch) && schemeMatch[1] != 'package') {
     // Do not attempt to resolve non-package absolute URLs with URI scheme
     return m[0];
   }
   foundUrls.push(resolver.resolve(baseUrl, url));
   return '';
 });
开发者ID:jianliao,项目名称:angular-upgrade-demo,代码行数:10,代码来源:style_url_resolver.ts

示例3: 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:hankduan,项目名称:angular,代码行数:38,代码来源:json_file_reporter_spec.ts

示例4: _split

/**
 * Splits a URI into its component parts.
 *
 * Each component can be accessed via the component indices; for example:
 * <pre>
 * goog.uri.utils.split(someStr)[goog.uri.utils.CompontentIndex.QUERY_DATA];
 * </pre>
 *
 * @param {string} uri The URI string to examine.
 * @return {!Array.<string|undefined>} Each component still URI-encoded.
 *     Each component that is present will contain the encoded value, whereas
 *     components that are not present will be undefined or empty, depending
 *     on the browser's regular expression implementation.  Never null, since
 *     arbitrary strings may still look like path names.
 */
function _split(uri: string): Array<string | any> {
  return RegExpWrapper.firstMatch(_splitRe, uri);
}
开发者ID:chiragjraval,项目名称:AdvisroySystemPOC,代码行数:18,代码来源:url_resolver.ts

示例5: isStyleUrlResolvable

export function isStyleUrlResolvable(url: string): boolean {
  if (isBlank(url) || url.length === 0 || url[0] == '/') return false;
  var schemeMatch = RegExpWrapper.firstMatch(_urlWithSchemaRe, url);
  return isBlank(schemeMatch) || schemeMatch[1] == 'package';
}
开发者ID:beta3000,项目名称:hola-angular2,代码行数:5,代码来源:style_url_resolver.ts

示例6: BaseException

    events.forEach((event) => {
      var ph = event['ph'];
      var name = event['name'];
      var microIterations = 1;
      var microIterationsMatch = RegExpWrapper.firstMatch(_MICRO_ITERATIONS_REGEX, name);
      if (isPresent(microIterationsMatch)) {
        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')) {
            frameTimestamps.push(event['ts']);
            if (frameTimestamps.length >= 2) {
              frameTimes.push(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;
            }
          }
        }
      }
    });
开发者ID:hankduan,项目名称:angular,代码行数:86,代码来源:perflog_metric.ts


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