Skip to content

Commit 57051f0

Browse files
vicbIgorMinar
authored andcommitted
refactor: remove most facades (angular#12399)
1 parent e319cfe commit 57051f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+204
-444
lines changed

modules/@angular/benchpress/src/validator/regression_slope_validator.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@
88

99
import {Inject, Injectable, OpaqueToken} from '@angular/core';
1010

11-
import {ListWrapper} from '../facade/collection';
1211
import {MeasureValues} from '../measure_values';
1312
import {Statistic} from '../statistic';
1413
import {Validator} from '../validator';
1514

16-
17-
1815
/**
1916
* A validator that checks the regression slope of a specific metric.
2017
* Waits for the regression slope to be >=0.
@@ -40,17 +37,17 @@ export class RegressionSlopeValidator extends Validator {
4037

4138
validate(completeSample: MeasureValues[]): MeasureValues[] {
4239
if (completeSample.length >= this._sampleSize) {
43-
var latestSample = ListWrapper.slice(
44-
completeSample, completeSample.length - this._sampleSize, completeSample.length);
45-
var xValues: number[] = [];
46-
var yValues: number[] = [];
47-
for (var i = 0; i < latestSample.length; i++) {
40+
const latestSample =
41+
completeSample.slice(completeSample.length - this._sampleSize, completeSample.length);
42+
const xValues: number[] = [];
43+
const yValues: number[] = [];
44+
for (let i = 0; i < latestSample.length; i++) {
4845
// For now, we only use the array index as x value.
4946
// TODO(tbosch): think about whether we should use time here instead
5047
xValues.push(i);
5148
yValues.push(latestSample[i].values[this._metric]);
5249
}
53-
var regressionSlope = Statistic.calculateRegressionSlope(
50+
const regressionSlope = Statistic.calculateRegressionSlope(
5451
xValues, Statistic.calculateMean(xValues), yValues, Statistic.calculateMean(yValues));
5552
return regressionSlope >= 0 ? latestSample : null;
5653
} else {

modules/@angular/benchpress/src/validator/size_validator.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88

99
import {Inject, Injectable, OpaqueToken} from '@angular/core';
1010

11-
import {ListWrapper} from '../facade/collection';
1211
import {MeasureValues} from '../measure_values';
1312
import {Validator} from '../validator';
1413

15-
16-
1714
/**
1815
* A validator that waits for the sample to have a certain size.
1916
*/
@@ -28,8 +25,7 @@ export class SizeValidator extends Validator {
2825

2926
validate(completeSample: MeasureValues[]): MeasureValues[] {
3027
if (completeSample.length >= this._sampleSize) {
31-
return ListWrapper.slice(
32-
completeSample, completeSample.length - this._sampleSize, completeSample.length);
28+
return completeSample.slice(completeSample.length - this._sampleSize, completeSample.length);
3329
} else {
3430
return null;
3531
}

modules/@angular/benchpress/src/webdriver/ios_driver_extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class IOsDriverExtension extends WebDriverExtension {
6262
var startTime = record['startTime'];
6363
var endTime = record['endTime'];
6464

65-
if (type === 'FunctionCall' && (isBlank(data) || data['scriptName'] !== 'InjectedScript')) {
65+
if (type === 'FunctionCall' && (data == null || data['scriptName'] !== 'InjectedScript')) {
6666
events.push(createStartEvent('script', startTime));
6767
endEvent = createEndEvent('script', endTime);
6868
} else if (type === 'Time') {

modules/@angular/benchpress/test/reporter/console_reporter_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function main() {
2828
if (!descriptions) {
2929
descriptions = [];
3030
}
31-
if (isBlank(sampleId)) {
31+
if (sampleId == null) {
3232
sampleId = 'null';
3333
}
3434
var providers: Provider[] = [

modules/@angular/benchpress/test/validator/regression_slope_validator_spec.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import {describe, expect, it} from '@angular/core/testing/testing_internal';
1010

1111
import {MeasureValues, ReflectiveInjector, RegressionSlopeValidator} from '../../index';
12-
import {ListWrapper} from '../../src/facade/collection';
1312

1413
export function main() {
1514
describe('regression slope validator', () => {
@@ -44,17 +43,15 @@ export function main() {
4443
it('should return the last sampleSize runs when the regression slope is ==0', () => {
4544
createValidator({size: 2, metric: 'script'});
4645
var sample = [mv(0, 0, {'script': 1}), mv(1, 1, {'script': 1}), mv(2, 2, {'script': 1})];
47-
expect(validator.validate(ListWrapper.slice(sample, 0, 2)))
48-
.toEqual(ListWrapper.slice(sample, 0, 2));
49-
expect(validator.validate(sample)).toEqual(ListWrapper.slice(sample, 1, 3));
46+
expect(validator.validate(sample.slice(0, 2))).toEqual(sample.slice(0, 2));
47+
expect(validator.validate(sample)).toEqual(sample.slice(1, 3));
5048
});
5149

5250
it('should return the last sampleSize runs when the regression slope is >0', () => {
5351
createValidator({size: 2, metric: 'script'});
5452
var sample = [mv(0, 0, {'script': 1}), mv(1, 1, {'script': 2}), mv(2, 2, {'script': 3})];
55-
expect(validator.validate(ListWrapper.slice(sample, 0, 2)))
56-
.toEqual(ListWrapper.slice(sample, 0, 2));
57-
expect(validator.validate(sample)).toEqual(ListWrapper.slice(sample, 1, 3));
53+
expect(validator.validate(sample.slice(0, 2))).toEqual(sample.slice(0, 2));
54+
expect(validator.validate(sample)).toEqual(sample.slice(1, 3));
5855
});
5956

6057
});

modules/@angular/benchpress/test/validator/size_validator_spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import {describe, expect, it} from '@angular/core/testing/testing_internal';
1010

1111
import {MeasureValues, ReflectiveInjector, SizeValidator} from '../../index';
12-
import {ListWrapper} from '../../src/facade/collection';
1312

1413
export function main() {
1514
describe('size validator', () => {
@@ -37,9 +36,8 @@ export function main() {
3736
it('should return the last sampleSize runs when it has at least the given size', () => {
3837
createValidator(2);
3938
var sample = [mv(0, 0, {'a': 1}), mv(1, 1, {'b': 2}), mv(2, 2, {'c': 3})];
40-
expect(validator.validate(ListWrapper.slice(sample, 0, 2)))
41-
.toEqual(ListWrapper.slice(sample, 0, 2));
42-
expect(validator.validate(sample)).toEqual(ListWrapper.slice(sample, 1, 3));
39+
expect(validator.validate(sample.slice(0, 2))).toEqual(sample.slice(0, 2));
40+
expect(validator.validate(sample)).toEqual(sample.slice(1, 3));
4341
});
4442

4543
});

modules/@angular/compiler-cli/test/static_reflector_spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import {StaticReflector, StaticReflectorHost, StaticSymbol} from '@angular/compiler-cli/src/static_reflector';
1010
import {HostListener, animate, group, keyframes, sequence, state, style, transition, trigger} from '@angular/core';
11-
import {ListWrapper} from '@angular/facade/src/collection';
1211
import {MetadataCollector} from '@angular/tsc-wrapped';
1312
import * as ts from 'typescript';
1413

@@ -474,7 +473,7 @@ class MockReflectorHost implements StaticReflectorHost {
474473

475474
function resolvePath(pathParts: string[]): string {
476475
let result: string[] = [];
477-
ListWrapper.forEachWithIndex(pathParts, (part, index) => {
476+
pathParts.forEach((part, index) => {
478477
switch (part) {
479478
case '':
480479
case '.':

modules/@angular/compiler/src/animation/animation_parser.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {CompileAnimationAnimateMetadata, CompileAnimationEntryMetadata, CompileAnimationGroupMetadata, CompileAnimationKeyframesSequenceMetadata, CompileAnimationMetadata, CompileAnimationSequenceMetadata, CompileAnimationStateDeclarationMetadata, CompileAnimationStateTransitionMetadata, CompileAnimationStyleMetadata, CompileAnimationWithStepsMetadata, CompileDirectiveMetadata} from '../compile_metadata';
10-
import {ListWrapper, StringMapWrapper} from '../facade/collection';
10+
import {StringMapWrapper} from '../facade/collection';
1111
import {isBlank, isPresent} from '../facade/lang';
1212
import {ParseError} from '../parse_util';
1313
import {ANY_STATE, FILL_STYLE_FLAG} from '../private_import_core';
@@ -180,8 +180,7 @@ function _normalizeStyleMetadata(
180180
var normalizedStyles: {[key: string]: string | number}[] = [];
181181
entry.styles.forEach(styleEntry => {
182182
if (typeof styleEntry === 'string') {
183-
ListWrapper.addAll(
184-
normalizedStyles, _resolveStylesFromState(<string>styleEntry, stateStyles, errors));
183+
normalizedStyles.push(..._resolveStylesFromState(<string>styleEntry, stateStyles, errors));
185184
} else {
186185
normalizedStyles.push(<{[key: string]: string | number}>styleEntry);
187186
}
@@ -346,12 +345,12 @@ function _parseAnimationKeyframes(
346345
});
347346

348347
if (doSortKeyframes) {
349-
ListWrapper.sort(rawKeyframes, (a, b) => a[0] <= b[0] ? -1 : 1);
348+
rawKeyframes.sort((a, b) => a[0] <= b[0] ? -1 : 1);
350349
}
351350

352351
var firstKeyframe = rawKeyframes[0];
353352
if (firstKeyframe[0] != _INITIAL_KEYFRAME) {
354-
ListWrapper.insert(rawKeyframes, 0, firstKeyframe = [_INITIAL_KEYFRAME, {}]);
353+
rawKeyframes.splice(0, 0, firstKeyframe = [_INITIAL_KEYFRAME, {}]);
355354
}
356355

357356
var firstKeyframeStyles = firstKeyframe[1];
@@ -421,7 +420,7 @@ function _parseTransitionAnimation(
421420
steps.push(new AnimationStepAst(startingStyles, [], 0, 0, ''));
422421
} else {
423422
var innerStep = <AnimationStepAst>innerAst;
424-
ListWrapper.addAll(innerStep.startingStyles.styles, previousStyles);
423+
innerStep.startingStyles.styles.push(...previousStyles);
425424
}
426425
previousStyles = null;
427426
}

modules/@angular/compiler/src/animation/styles_collection.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {ListWrapper} from '../facade/collection';
109
import {isPresent} from '../facade/lang';
1110

1211
export class StylesCollectionEntry {
@@ -37,7 +36,7 @@ export class StylesCollection {
3736
}
3837
}
3938

40-
ListWrapper.insert(entries, insertionIndex, tuple);
39+
entries.splice(insertionIndex, 0, tuple);
4140
}
4241

4342
getByIndex(property: string, index: number): StylesCollectionEntry {

modules/@angular/compiler/src/compile_metadata.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import {ChangeDetectionStrategy, SchemaMetadata, Type, ViewEncapsulation} from '@angular/core';
1010

1111
import {ListWrapper, MapWrapper} from './facade/collection';
12-
import {isPresent, normalizeBlank, normalizeBool} from './facade/lang';
12+
import {isPresent} from './facade/lang';
1313
import {LifecycleHooks} from './private_import_core';
1414
import {CssSelector} from './selector';
1515
import {sanitizeIdentifier, splitAtColon} from './util';
@@ -23,7 +23,6 @@ function unimplemented(): any {
2323
// group 2: "event" from "(event)"
2424
// group 3: "@trigger" from "@trigger"
2525
const HOST_REG_EXP = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))|(\@[-\w]+)$/;
26-
const UNDEFINED = new Object();
2726

2827
export abstract class CompileMetadataWithIdentifier {
2928
get identifier(): CompileIdentifierMetadata { return <CompileIdentifierMetadata>unimplemented(); }
@@ -125,12 +124,12 @@ export class CompileDiDependencyMetadata {
125124
token?: CompileTokenMetadata,
126125
value?: any
127126
} = {}) {
128-
this.isAttribute = normalizeBool(isAttribute);
129-
this.isSelf = normalizeBool(isSelf);
130-
this.isHost = normalizeBool(isHost);
131-
this.isSkipSelf = normalizeBool(isSkipSelf);
132-
this.isOptional = normalizeBool(isOptional);
133-
this.isValue = normalizeBool(isValue);
127+
this.isAttribute = !!isAttribute;
128+
this.isSelf = !!isSelf;
129+
this.isHost = !!isHost;
130+
this.isSkipSelf = !!isSkipSelf;
131+
this.isOptional = !!isOptional;
132+
this.isValue = !!isValue;
134133
this.query = query;
135134
this.viewQuery = viewQuery;
136135
this.token = token;
@@ -161,8 +160,8 @@ export class CompileProviderMetadata {
161160
this.useValue = useValue;
162161
this.useExisting = useExisting;
163162
this.useFactory = useFactory;
164-
this.deps = normalizeBlank(deps);
165-
this.multi = normalizeBool(multi);
163+
this.deps = deps || null;
164+
this.multi = !!multi;
166165
}
167166
}
168167

@@ -192,7 +191,7 @@ export class CompileTokenMetadata implements CompileMetadataWithIdentifier {
192191
{value?: any, identifier?: CompileIdentifierMetadata, identifierIsInstance?: boolean}) {
193192
this.value = value;
194193
this.identifier = identifier;
195-
this.identifierIsInstance = normalizeBool(identifierIsInstance);
194+
this.identifierIsInstance = !!identifierIsInstance;
196195
}
197196

198197
get reference(): any {
@@ -227,7 +226,7 @@ export class CompileTypeMetadata extends CompileIdentifierMetadata {
227226
lifecycleHooks?: LifecycleHooks[];
228227
} = {}) {
229228
super({reference: reference, name: name, moduleUrl: moduleUrl, prefix: prefix, value: value});
230-
this.isHost = normalizeBool(isHost);
229+
this.isHost = !!isHost;
231230
this.diDeps = _normalizeArray(diDeps);
232231
this.lifecycleHooks = _normalizeArray(lifecycleHooks);
233232
}
@@ -248,8 +247,8 @@ export class CompileQueryMetadata {
248247
read?: CompileTokenMetadata
249248
} = {}) {
250249
this.selectors = selectors;
251-
this.descendants = normalizeBool(descendants);
252-
this.first = normalizeBool(first);
250+
this.descendants = !!descendants;
251+
this.first = !!first;
253252
this.propertyName = propertyName;
254253
this.read = read;
255254
}
@@ -303,9 +302,9 @@ export class CompileTemplateMetadata {
303302
this.styles = _normalizeArray(styles);
304303
this.styleUrls = _normalizeArray(styleUrls);
305304
this.externalStylesheets = _normalizeArray(externalStylesheets);
306-
this.animations = isPresent(animations) ? ListWrapper.flatten(animations) : [];
305+
this.animations = animations ? ListWrapper.flatten(animations) : [];
307306
this.ngContentSelectors = ngContentSelectors || [];
308-
if (isPresent(interpolation) && interpolation.length != 2) {
307+
if (interpolation && interpolation.length != 2) {
309308
throw new Error(`'interpolation' should have a start and an end symbol.`);
310309
}
311310
this.interpolation = interpolation;
@@ -375,7 +374,7 @@ export class CompileDirectiveMetadata implements CompileMetadataWithIdentifier {
375374

376375
return new CompileDirectiveMetadata({
377376
type,
378-
isComponent: normalizeBool(isComponent), selector, exportAs, changeDetection,
377+
isComponent: !!isComponent, selector, exportAs, changeDetection,
379378
inputs: inputsMap,
380379
outputs: outputsMap,
381380
hostListeners,
@@ -503,7 +502,7 @@ export class CompilePipeMetadata implements CompileMetadataWithIdentifier {
503502
} = {}) {
504503
this.type = type;
505504
this.name = name;
506-
this.pure = normalizeBool(pure);
505+
this.pure = !!pure;
507506
}
508507
get identifier(): CompileIdentifierMetadata { return this.type; }
509508
}

0 commit comments

Comments
 (0)