refactor: misc (#9308)

This commit is contained in:
Victor Berchet
2016-06-17 10:57:50 -07:00
committed by GitHub
parent 5e3ccbcea9
commit 7498050421
19 changed files with 157 additions and 259 deletions

View File

@ -1,13 +1,11 @@
import {Pipe, PipeTransform} from '@angular/core';
import {BaseException} from '../facade/exceptions';
import {NumberFormatStyle, NumberFormatter} from '../facade/intl';
import {NumberWrapper, RegExpWrapper, Type, isBlank, isNumber, isPresent} from '../facade/lang';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
var defaultLocale: string = 'en-US';
var _re = RegExpWrapper.create('^(\\d+)?\\.((\\d+)(\\-(\\d+))?)?$');
const _NUMBER_REGEXP = /^(\d+)?\.((\d+)(\-(\d+))?)?$'/g;
/**
* Internal function to format numbers used by Decimal, Percent and Date pipes.
@ -21,7 +19,7 @@ function formatNumber(
}
var minInt = 1, minFraction = 0, maxFraction = 3;
if (isPresent(digits)) {
var parts = RegExpWrapper.firstMatch(_re, digits);
var parts = RegExpWrapper.firstMatch(_NUMBER_REGEXP, digits);
if (isBlank(parts)) {
throw new BaseException(`${digits} is not a valid digit info for number pipes`);
}