X Tutup
Skip to content

Commit b6537ad

Browse files
committed
refactor(ListWrapper): get ride of ListWrapper.join
1 parent 62e14dc commit b6537ad

File tree

10 files changed

+16
-29
lines changed

10 files changed

+16
-29
lines changed

modules/angular2/src/core/change_detection/codegen_name_util.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ export class CodegenNameUtil {
109109
}
110110
}
111111
var assignmentsCode =
112-
ListWrapper.isEmpty(assignments) ? '' : `${ListWrapper.join(assignments, '=')} = false;`;
113-
return `var ${ListWrapper.join(declarations, ',')};${assignmentsCode}`;
112+
ListWrapper.isEmpty(assignments) ? '' : `${assignments.join('=')} = false;`;
113+
return `var ${declarations.join(',')};${assignmentsCode}`;
114114
}
115115

116116
/**
@@ -169,20 +169,16 @@ export class CodegenNameUtil {
169169

170170
// At least one assignment.
171171
fields.push(`${this._utilName}.uninitialized;`);
172-
return ListWrapper.join(fields, ' = ');
172+
return fields.join(' = ');
173173
}
174174

175175
/**
176176
* Generates statements destroying all pipe variables.
177177
*/
178178
genPipeOnDestroy(): string {
179-
return ListWrapper.join(
180-
ListWrapper.map(
181-
ListWrapper.filter(this._records, (r) => { return r.isPipeRecord(); }),
182-
(r) => {
183-
return `${this._utilName}.callPipeOnDestroy(${this.getPipeName(r.selfIndex)});`;
184-
}),
185-
'\n');
179+
return ListWrapper.filter(this._records, (r) => { return r.isPipeRecord(); })
180+
.map(r => `${this._utilName}.callPipeOnDestroy(${this.getPipeName(r.selfIndex)});`)
181+
.join('\n');
186182
}
187183

188184
getPipeName(idx: number): string {

modules/angular2/src/core/change_detection/proto_change_detector.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,7 @@ function _arrayFn(length: number): Function {
314314
}
315315

316316
function _mapPrimitiveName(keys: any[]) {
317-
var stringifiedKeys =
318-
ListWrapper.join(ListWrapper.map(keys, (k) => isString(k) ? `"${k}"` : `${k}`), ", ");
317+
var stringifiedKeys = keys.map(k => isString(k) ? `"${k}"` : `${k}`).join(', ');
319318
return `mapFn([${stringifiedKeys}])`;
320319
}
321320

modules/angular2/src/core/compiler/xhr_mock.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,9 @@ import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptio
55
import {PromiseCompleter, PromiseWrapper, Promise} from 'angular2/src/core/facade/async';
66

77
export class MockXHR extends XHR {
8-
private _expectations: _Expectation[];
8+
private _expectations: _Expectation[] = [];
99
private _definitions = new Map<string, string>();
10-
private _requests: _PendingRequest[];
11-
12-
constructor() {
13-
super();
14-
this._expectations = [];
15-
this._requests = [];
16-
}
10+
private _requests: _PendingRequest[] = [];
1711

1812
get(url: string): Promise<string> {
1913
var request = new _PendingRequest(url);
@@ -50,7 +44,7 @@ export class MockXHR extends XHR {
5044
urls.push(expectation.url);
5145
}
5246

53-
throw new BaseException(`Unsatisfied requests: ${ListWrapper.join(urls, ', ')}`);
47+
throw new BaseException(`Unsatisfied requests: ${urls.join(', ')}`);
5448
}
5549

5650
private _processRequest(request: _PendingRequest) {

modules/angular2/src/core/debug/debug_element_view_listener.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var _nextId = 0;
2020

2121
function _setElementId(element, indices: number[]) {
2222
if (isPresent(element)) {
23-
DOM.setData(element, NG_ID_PROPERTY, ListWrapper.join(indices, NG_ID_SEPARATOR));
23+
DOM.setData(element, NG_ID_PROPERTY, indices.join(NG_ID_SEPARATOR));
2424
}
2525
}
2626

modules/angular2/src/core/dom/parse5_adapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,15 @@ export class Parse5DomAdapter extends DomAdapter {
356356
var index = classList.indexOf(classname);
357357
if (index == -1) {
358358
classList.push(classname);
359-
element.attribs["class"] = element.className = ListWrapper.join(classList, " ");
359+
element.attribs["class"] = element.className = classList.join(" ");
360360
}
361361
}
362362
removeClass(element, classname: string) {
363363
var classList = this.classList(element);
364364
var index = classList.indexOf(classname);
365365
if (index > -1) {
366366
classList.splice(index, 1);
367-
element.attribs["class"] = element.className = ListWrapper.join(classList, " ");
367+
element.attribs["class"] = element.className = classList.join(" ");
368368
}
369369
}
370370
hasClass(element, classname: string): boolean {

modules/angular2/src/core/facade/collection.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ class ListWrapper {
167167
l.clear();
168168
}
169169

170-
static String join(List l, String s) => l.join(s);
171170
static bool isEmpty(Iterable list) => list.isEmpty;
172171
static void fill(List l, value, [int start = 0, int end]) {
173172
l.fillRange(_startOffset(l, start), _endOffset(l, end), value);

modules/angular2/src/core/facade/collection.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ export class ListWrapper {
245245
return false;
246246
}
247247
static clear(list: any[]) { list.length = 0; }
248-
static join(list: any[], s: string): string { return list.join(s); }
249248
static isEmpty(list: any[]): boolean { return list.length == 0; }
250249
static fill(list: any[], value: any, start: number = 0, end: number = null) {
251250
list.fill(value, start, end === null ? list.length : end);

modules/angular2/src/core/forms/directives/shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function setUpControl(control: Control, dir: NgControl): void {
4242
}
4343

4444
function _throwError(dir: NgControl, message: string): void {
45-
var path = ListWrapper.join(dir.path, " -> ");
45+
var path = dir.path.join(" -> ");
4646
throw new BaseException(`${message} '${path}'`);
4747
}
4848

modules/angular2/src/http/url_search_params.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export class URLSearchParams {
130130
MapWrapper.forEach(this.paramsMap, (values, k) => {
131131
ListWrapper.forEach(values, v => { paramsList.push(k + '=' + v); });
132132
});
133-
return ListWrapper.join(paramsList, '&');
133+
return paramsList.join('&');
134134
}
135135

136136
delete (param: string): void { MapWrapper.delete(this.paramsMap, param); }

modules/angular2/src/test_lib/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class Log {
2121

2222
clear(): void { this._result = []; }
2323

24-
result(): string { return ListWrapper.join(this._result, "; "); }
24+
result(): string { return this._result.join("; "); }
2525
}
2626

2727

0 commit comments

Comments
 (0)
X Tutup