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,8 +1,6 @@
import {ChangeDetectorRef, Injectable, OnDestroy, Pipe, WrappedValue} from '@angular/core';
import {ChangeDetectorRef, OnDestroy, Pipe, WrappedValue} from '@angular/core';
import {EventEmitter, Observable, ObservableWrapper} from '../facade/async';
import {isBlank, isPresent, isPromise} from '../facade/lang';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
interface SubscriptionStrategy {
@ -63,7 +61,6 @@ var __unused: Promise<any>; // avoid unused import when Promise union types are
* @stable
*/
@Pipe({name: 'async', pure: false})
@Injectable()
export class AsyncPipe implements OnDestroy {
/** @internal */
_latestValue: Object = null;

View File

@ -1,12 +1,9 @@
import {Injectable, Pipe, PipeTransform} from '@angular/core';
import {Pipe, PipeTransform} from '@angular/core';
import {isDate, isNumber, isString, DateWrapper, isBlank,} from '../facade/lang';
import {DateFormatter} from '../facade/intl';
import {StringMapWrapper} from '../facade/collection';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
// TODO: move to a global configurable location along with other i18n components.
var defaultLocale: string = 'en-US';
@ -80,7 +77,6 @@ var defaultLocale: string = 'en-US';
* @experimental
*/
@Pipe({name: 'date', pure: true})
@Injectable()
export class DatePipe implements PipeTransform {
/** @internal */
static _ALIASES: {[key: string]: String} = {

View File

@ -1,10 +1,8 @@
import {Pipe, PipeTransform} from '@angular/core';
import {RegExpWrapper, StringWrapper, isPresent, isStringMap} from '../facade/lang';
import {StringWrapper, isPresent, isStringMap} from '../facade/lang';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
var interpolationExp: RegExp = RegExpWrapper.create('#');
const _INTERPOLATION_REGEXP: RegExp = /#/g;
/**
*
@ -51,6 +49,6 @@ export class I18nPluralPipe implements PipeTransform {
key = value === 0 || value === 1 ? `=${value}` : 'other';
valueStr = isPresent(value) ? value.toString() : '';
return StringWrapper.replaceAll(pluralMap[key], interpolationExp, valueStr);
return StringWrapper.replaceAll(pluralMap[key], _INTERPOLATION_REGEXP, valueStr);
}
}

View File

@ -1,8 +1,6 @@
import {Pipe, PipeTransform} from '@angular/core';
import {StringMapWrapper} from '../facade/collection';
import {isStringMap} from '../facade/lang';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';

View File

@ -1,7 +1,5 @@
import {Pipe, PipeTransform} from '@angular/core';
import {isBlank, isString} from '../facade/lang';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';

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`);
}

View File

@ -1,7 +1,5 @@
import {Injectable, Pipe, PipeTransform} from '@angular/core';
import {Pipe, PipeTransform} from '@angular/core';
import {RegExpWrapper, StringWrapper, isBlank, isFunction, isNumber, isString} from '../facade/lang';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
/**
@ -35,7 +33,6 @@ import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
*/
@Pipe({name: 'replace'})
@Injectable()
export class ReplacePipe implements PipeTransform {
transform(value: any, pattern: string|RegExp, replacement: Function|string): any {
if (isBlank(value)) {

View File

@ -1,8 +1,6 @@
import {Pipe, PipeTransform} from '@angular/core';
import {ListWrapper} from '../facade/collection';
import {StringWrapper, isArray, isBlank, isString} from '../facade/lang';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
/**

View File

@ -1,10 +1,7 @@
import {Pipe, PipeTransform} from '@angular/core';
import {isBlank, isString} from '../facade/lang';
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
/**
* Implements uppercase transforms to text.
*