refactor(RegExpWrapper): remove the facade (#10512)
This commit is contained in:

committed by
Alex Rickabaugh

parent
b4613ab2d2
commit
83e2d3d1cb
@ -9,12 +9,12 @@
|
||||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
|
||||
import {NumberFormatStyle, NumberFormatter} from '../facade/intl';
|
||||
import {NumberWrapper, RegExpWrapper, Type, isBlank, isNumber, isPresent, isString} from '../facade/lang';
|
||||
import {NumberWrapper, Type, isBlank, isNumber, isPresent, isString} from '../facade/lang';
|
||||
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
|
||||
var defaultLocale: string = 'en-US';
|
||||
const _NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(\-(\d+))?)?$/g;
|
||||
const _NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(\-(\d+))?)?$/;
|
||||
|
||||
function formatNumber(
|
||||
pipe: Type, value: number | string, style: NumberFormatStyle, digits: string,
|
||||
@ -36,8 +36,8 @@ function formatNumber(
|
||||
}
|
||||
|
||||
if (isPresent(digits)) {
|
||||
var parts = RegExpWrapper.firstMatch(_NUMBER_FORMAT_REGEXP, digits);
|
||||
if (!parts) {
|
||||
var parts = digits.match(_NUMBER_FORMAT_REGEXP);
|
||||
if (parts === null) {
|
||||
throw new Error(`${digits} is not a valid digit info for number pipes`);
|
||||
}
|
||||
if (isPresent(parts[1])) { // min integer digits
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
import {RegExpWrapper, StringWrapper, isBlank, isFunction, isNumber, isString} from '../facade/lang';
|
||||
import {StringWrapper, isBlank, isFunction, isNumber, isString} from '../facade/lang';
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
|
||||
/**
|
||||
@ -61,7 +61,7 @@ export class ReplacePipe implements PipeTransform {
|
||||
}
|
||||
|
||||
if (isFunction(replacement)) {
|
||||
const rgxPattern = isString(pattern) ? RegExpWrapper.create(pattern) : pattern;
|
||||
const rgxPattern = isString(pattern) ? new RegExp(pattern, 'g') : pattern;
|
||||
|
||||
return StringWrapper.replaceAllMapped(
|
||||
input, rgxPattern, <(m: string[]) => string>replacement);
|
||||
|
Reference in New Issue
Block a user