refactor(ListWrapper): get ride of ListWrapper.join

This commit is contained in:
Victor Berchet 2015-10-06 17:11:10 -07:00
parent 62e14dc529
commit b6537ad609
10 changed files with 16 additions and 29 deletions

View File

@ -109,8 +109,8 @@ export class CodegenNameUtil {
}
}
var assignmentsCode =
ListWrapper.isEmpty(assignments) ? '' : `${ListWrapper.join(assignments, '=')} = false;`;
return `var ${ListWrapper.join(declarations, ',')};${assignmentsCode}`;
ListWrapper.isEmpty(assignments) ? '' : `${assignments.join('=')} = false;`;
return `var ${declarations.join(',')};${assignmentsCode}`;
}
/**
@ -169,20 +169,16 @@ export class CodegenNameUtil {
// At least one assignment.
fields.push(`${this._utilName}.uninitialized;`);
return ListWrapper.join(fields, ' = ');
return fields.join(' = ');
}
/**
* Generates statements destroying all pipe variables.
*/
genPipeOnDestroy(): string {
return ListWrapper.join(
ListWrapper.map(
ListWrapper.filter(this._records, (r) => { return r.isPipeRecord(); }),
(r) => {
return `${this._utilName}.callPipeOnDestroy(${this.getPipeName(r.selfIndex)});`;
}),
'\n');
return ListWrapper.filter(this._records, (r) => { return r.isPipeRecord(); })
.map(r => `${this._utilName}.callPipeOnDestroy(${this.getPipeName(r.selfIndex)});`)
.join('\n');
}
getPipeName(idx: number): string {

View File

@ -314,8 +314,7 @@ function _arrayFn(length: number): Function {
}
function _mapPrimitiveName(keys: any[]) {
var stringifiedKeys =
ListWrapper.join(ListWrapper.map(keys, (k) => isString(k) ? `"${k}"` : `${k}`), ", ");
var stringifiedKeys = keys.map(k => isString(k) ? `"${k}"` : `${k}`).join(', ');
return `mapFn([${stringifiedKeys}])`;
}

View File

@ -5,15 +5,9 @@ import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptio
import {PromiseCompleter, PromiseWrapper, Promise} from 'angular2/src/core/facade/async';
export class MockXHR extends XHR {
private _expectations: _Expectation[];
private _expectations: _Expectation[] = [];
private _definitions = new Map<string, string>();
private _requests: _PendingRequest[];
constructor() {
super();
this._expectations = [];
this._requests = [];
}
private _requests: _PendingRequest[] = [];
get(url: string): Promise<string> {
var request = new _PendingRequest(url);
@ -50,7 +44,7 @@ export class MockXHR extends XHR {
urls.push(expectation.url);
}
throw new BaseException(`Unsatisfied requests: ${ListWrapper.join(urls, ', ')}`);
throw new BaseException(`Unsatisfied requests: ${urls.join(', ')}`);
}
private _processRequest(request: _PendingRequest) {

View File

@ -20,7 +20,7 @@ var _nextId = 0;
function _setElementId(element, indices: number[]) {
if (isPresent(element)) {
DOM.setData(element, NG_ID_PROPERTY, ListWrapper.join(indices, NG_ID_SEPARATOR));
DOM.setData(element, NG_ID_PROPERTY, indices.join(NG_ID_SEPARATOR));
}
}

View File

@ -356,7 +356,7 @@ export class Parse5DomAdapter extends DomAdapter {
var index = classList.indexOf(classname);
if (index == -1) {
classList.push(classname);
element.attribs["class"] = element.className = ListWrapper.join(classList, " ");
element.attribs["class"] = element.className = classList.join(" ");
}
}
removeClass(element, classname: string) {
@ -364,7 +364,7 @@ export class Parse5DomAdapter extends DomAdapter {
var index = classList.indexOf(classname);
if (index > -1) {
classList.splice(index, 1);
element.attribs["class"] = element.className = ListWrapper.join(classList, " ");
element.attribs["class"] = element.className = classList.join(" ");
}
}
hasClass(element, classname: string): boolean {

View File

@ -167,7 +167,6 @@ class ListWrapper {
l.clear();
}
static String join(List l, String s) => l.join(s);
static bool isEmpty(Iterable list) => list.isEmpty;
static void fill(List l, value, [int start = 0, int end]) {
l.fillRange(_startOffset(l, start), _endOffset(l, end), value);

View File

@ -245,7 +245,6 @@ export class ListWrapper {
return false;
}
static clear(list: any[]) { list.length = 0; }
static join(list: any[], s: string): string { return list.join(s); }
static isEmpty(list: any[]): boolean { return list.length == 0; }
static fill(list: any[], value: any, start: number = 0, end: number = null) {
list.fill(value, start, end === null ? list.length : end);

View File

@ -42,7 +42,7 @@ export function setUpControl(control: Control, dir: NgControl): void {
}
function _throwError(dir: NgControl, message: string): void {
var path = ListWrapper.join(dir.path, " -> ");
var path = dir.path.join(" -> ");
throw new BaseException(`${message} '${path}'`);
}

View File

@ -130,7 +130,7 @@ export class URLSearchParams {
MapWrapper.forEach(this.paramsMap, (values, k) => {
ListWrapper.forEach(values, v => { paramsList.push(k + '=' + v); });
});
return ListWrapper.join(paramsList, '&');
return paramsList.join('&');
}
delete (param: string): void { MapWrapper.delete(this.paramsMap, param); }

View File

@ -21,7 +21,7 @@ export class Log {
clear(): void { this._result = []; }
result(): string { return ListWrapper.join(this._result, "; "); }
result(): string { return this._result.join("; "); }
}