Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/angular2/src/core/change_detection/parser/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class RecursiveAstVisitor implements AstVisitor {
return this.visitAll(ast.args);
}
visitAll(asts: AST[]): any {
ListWrapper.forEach(asts, (ast) => { ast.visit(this); });
asts.forEach(ast => ast.visit(this));
return null;
}
}
Expand Down
3 changes: 1 addition & 2 deletions modules/angular2/src/core/compiler/selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ export class CssSelector {
res += ']';
}
}
ListWrapper.forEach(this.notSelectors,
(notSelector) => { res += ":not(" + notSelector.toString() + ")"; });
this.notSelectors.forEach(notSelector => res += `:not(${notSelector})`);
return res;
}
}
Expand Down
6 changes: 3 additions & 3 deletions modules/angular2/src/core/compiler/url_resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function _removeDotSegments(path: string): string {
var trailingSlash = path[path.length - 1] === '/' ? '/' : '';
var segments = path.split('/');

var out = [];
var out: string[] = [];
var up = 0;
for (var pos = 0; pos < segments.length; pos++) {
var segment = segments[pos];
Expand All @@ -223,7 +223,7 @@ function _removeDotSegments(path: string): string {
break;
case '..':
if (out.length > 0) {
ListWrapper.removeAt(out, out.length - 1);
out.pop();
} else {
up++;
}
Expand All @@ -235,7 +235,7 @@ function _removeDotSegments(path: string): string {

if (leadingSlash == '') {
while (up-- > 0) {
ListWrapper.insert(out, 0, '..');
out.unshift('..');
}

if (out.length === 0) out.push('.');
Expand Down
3 changes: 1 addition & 2 deletions modules/angular2/src/core/compiler/xhr_mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export class MockXHR extends XHR {
}

do {
var request = ListWrapper.removeAt(this._requests, 0);
this._processRequest(request);
this._processRequest(this._requests.shift());
} while (this._requests.length > 0);

this.verifyNoOustandingExpectations();
Expand Down
15 changes: 6 additions & 9 deletions modules/angular2/src/core/debug/debug_element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,8 @@ export class DebugElement {

var views = view.viewContainers[view.elementOffset + i];
if (isPresent(views)) {
ListWrapper.forEach(views.views, (nextView) => {
els = els.concat(this._getChildElements(nextView, null));
});
views.views.forEach(
(nextView) => { els = els.concat(this._getChildElements(nextView, null)); });
}
}
}
Expand All @@ -155,17 +154,15 @@ export class Scope {
var scope = [];
scope.push(debugElement);

ListWrapper.forEach(debugElement.children,
(child) => { scope = scope.concat(Scope.all(child)); });
debugElement.children.forEach(child => scope = scope.concat(Scope.all(child)));

ListWrapper.forEach(debugElement.componentViewChildren,
(child) => { scope = scope.concat(Scope.all(child)); });
debugElement.componentViewChildren.forEach(child => scope = scope.concat(Scope.all(child)));

return scope;
}
static light(debugElement: DebugElement): DebugElement[] {
var scope = [];
ListWrapper.forEach(debugElement.children, (child) => {
debugElement.children.forEach(child => {
scope.push(child);
scope = scope.concat(Scope.light(child));
});
Expand All @@ -175,7 +172,7 @@ export class Scope {
static view(debugElement: DebugElement): DebugElement[] {
var scope = [];

ListWrapper.forEach(debugElement.componentViewChildren, (child) => {
debugElement.componentViewChildren.forEach(child => {
scope.push(child);
scope = scope.concat(Scope.light(child));
});
Expand Down
4 changes: 2 additions & 2 deletions modules/angular2/src/core/di/binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,10 @@ function _createListOfBindings(flattenedBindings: Map<number, any>): any[] {
return MapWrapper.values(flattenedBindings);
}

function _normalizeBindings(bindings: Array<Type | Binding | any[]>,
function _normalizeBindings(bindings: Array<Type | Binding | BindingBuilder | any[]>,
res: Map<number, _NormalizedBinding | _NormalizedBinding[]>):
Map<number, _NormalizedBinding | _NormalizedBinding[]> {
ListWrapper.forEach(bindings, (b) => {
bindings.forEach(b => {
if (b instanceof Type) {
_normalizeBinding(bind(b).toClass(b), res);

Expand Down
11 changes: 3 additions & 8 deletions modules/angular2/src/core/directives/ng_class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ import {
KeyValueDiffers
} from 'angular2/src/core/change_detection';
import {Renderer} from 'angular2/src/core/render';
import {
ListWrapper,
StringMapWrapper,
isListLikeIterable
} from 'angular2/src/core/facade/collection';
import {StringMapWrapper, isListLikeIterable} from 'angular2/src/core/facade/collection';

/**
* Adds and removes CSS classes based on an {expression} value.
Expand Down Expand Up @@ -109,14 +105,13 @@ export class NgClass implements DoCheck, OnDestroy {
}

private _applyInitialClasses(isCleanup: boolean) {
ListWrapper.forEach(this._initialClasses,
(className) => { this._toggleClass(className, !isCleanup); });
this._initialClasses.forEach(className => this._toggleClass(className, !isCleanup));
}

private _applyClasses(rawClassVal, isCleanup: boolean) {
if (isPresent(rawClassVal)) {
if (isListLikeIterable(rawClassVal)) {
ListWrapper.forEach(rawClassVal, (className) => this._toggleClass(className, !isCleanup));
(<string[]>rawClassVal).forEach(className => this._toggleClass(className, !isCleanup));
} else {
StringMapWrapper.forEach(rawClassVal, (expVal, className) => {
if (expVal) this._toggleClass(className, !isCleanup);
Expand Down
4 changes: 1 addition & 3 deletions modules/angular2/src/core/dom/browser_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
return node;
}
insertBefore(el, node) { el.parentNode.insertBefore(node, el); }
insertAllBefore(el, nodes) {
ListWrapper.forEach(nodes, (n) => { el.parentNode.insertBefore(n, el); });
}
insertAllBefore(el, nodes) { nodes.forEach(n => el.parentNode.insertBefore(n, el)); }
insertAfter(el, node) { el.parentNode.insertBefore(node, el.nextSibling); }
setInnerHTML(el, value) { el.innerHTML = value; }
getText(el): string { return el.textContent; }
Expand Down
4 changes: 1 addition & 3 deletions modules/angular2/src/core/dom/parse5_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,7 @@ export class Parse5DomAdapter extends DomAdapter {
this.remove(node);
treeAdapter.insertBefore(el.parent, node, el);
}
insertAllBefore(el, nodes) {
ListWrapper.forEach(nodes, (n) => { this.insertBefore(el, n); });
}
insertAllBefore(el, nodes) { nodes.forEach(n => this.insertBefore(el, n)); }
insertAfter(el, node) {
if (el.nextSibling) {
this.insertBefore(el.nextSibling, node);
Expand Down
4 changes: 0 additions & 4 deletions modules/angular2/src/core/facade/collection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ class ListWrapper {
static find(List list, bool fn(item)) =>
list.firstWhere(fn, orElse: () => null);
static bool any(List list, bool fn(item)) => list.any(fn);
static void forEach(Iterable list, fn(item)) {
list.forEach(fn);
}

static void forEachWithIndex(List list, fn(item, index)) {
for (var i = 0; i < list.length; ++i) {
Expand Down Expand Up @@ -160,7 +157,6 @@ class ListWrapper {
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is removeAt still needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep because we can removeAt anywhere


static removeLast(List list) => list.removeLast();
static bool remove(List list, item) => list.remove(item);
static void clear(List l) {
l.clear();
Expand Down
6 changes: 0 additions & 6 deletions modules/angular2/src/core/facade/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,6 @@ export class ListWrapper {
static createFixedSize(size: number): any[] { return new Array(size); }
static createGrowableSize(size: number): any[] { return new Array(size); }
static clone<T>(array: T[]): T[] { return array.slice(0); }
static forEach<T>(array: T[], fn: (T) => void) {
for (var i = 0; i < array.length; i++) {
fn(array[i]);
}
}
static forEachWithIndex<T>(array: T[], fn: (T, number) => void) {
for (var i = 0; i < array.length; i++) {
fn(array[i], i);
Expand Down Expand Up @@ -234,7 +229,6 @@ export class ListWrapper {
list.splice(index, 1);
}
}
static removeLast<T>(list: T[]): T { return list.pop(); }
static remove<T>(list: T[], el: T): boolean {
var index = list.indexOf(el);
if (index > -1) {
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/src/core/forms/directives/ng_form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class NgForm extends ControlContainer implements Form {
}

_findContainer(path: string[]): ControlGroup {
ListWrapper.removeLast(path);
path.pop();
return ListWrapper.isEmpty(path) ? this.form : <ControlGroup>this.form.find(path);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class NgFormModel extends ControlContainer implements Form,
}

_updateDomValue() {
ListWrapper.forEach(this.directives, dir => {
this.directives.forEach(dir => {
var ctrl: any = this.form.find(dir.path);
dir.valueAccessor.writeValue(ctrl.value);
});
Expand Down
4 changes: 2 additions & 2 deletions modules/angular2/src/core/linker/view_pool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Inject, Injectable, OpaqueToken} from 'angular2/src/core/di';

import {ListWrapper, MapWrapper, Map} from 'angular2/src/core/facade/collection';
import {MapWrapper, Map} from 'angular2/src/core/facade/collection';
import {isPresent, isBlank, CONST_EXPR} from 'angular2/src/core/facade/lang';

import * as viewModule from './view';
Expand All @@ -19,7 +19,7 @@ export class AppViewPool {
getView(protoView: viewModule.AppProtoView): viewModule.AppView {
var pooledViews = this._pooledViewsPerProtoView.get(protoView);
if (isPresent(pooledViews) && pooledViews.length > 0) {
return ListWrapper.removeLast(pooledViews);
return pooledViews.pop();
}
return null;
}
Expand Down
10 changes: 5 additions & 5 deletions modules/angular2/src/core/render/dom/events/key_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ export class KeyEventsPlugin extends EventManagerPlugin {
}

static parseEventName(eventName: string): {[key: string]: string} {
var parts = eventName.toLowerCase().split('.');
var parts: string[] = eventName.toLowerCase().split('.');

var domEventName = ListWrapper.removeAt(parts, 0);
var domEventName = parts.shift();
if ((parts.length === 0) ||
!(StringWrapper.equals(domEventName, 'keydown') ||
StringWrapper.equals(domEventName, 'keyup'))) {
return null;
}

var key = KeyEventsPlugin._normalizeKey(ListWrapper.removeLast(parts));
var key = KeyEventsPlugin._normalizeKey(parts.pop());

var fullKey = '';
ListWrapper.forEach(modifierKeys, (modifierName) => {
modifierKeys.forEach(modifierName => {
if (ListWrapper.contains(parts, modifierName)) {
ListWrapper.remove(parts, modifierName);
fullKey += modifierName + '.';
Expand All @@ -78,7 +78,7 @@ export class KeyEventsPlugin extends EventManagerPlugin {
} else if (StringWrapper.equals(key, '.')) {
key = 'dot'; // because '.' is used as a separator in event names
}
ListWrapper.forEach(modifierKeys, (modifierName) => {
modifierKeys.forEach(modifierName => {
if (modifierName != key) {
var modifierGetter = StringMapWrapper.get(modifierKeyGetters, modifierName);
if (modifierGetter(event)) {
Expand Down
7 changes: 3 additions & 4 deletions modules/angular2/src/http/url_search_params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function paramParser(rawParams: string = ''): Map<string, string[]> {
var map = new Map<string, string[]>();
if (rawParams.length > 0) {
var params: string[] = StringWrapper.split(rawParams, new RegExp('&'));
ListWrapper.forEach(params, (param: string) => {
params.forEach((param: string) => {
var split: string[] = StringWrapper.split(param, new RegExp('='));
var key = split[0];
var val = split[1];
Expand Down Expand Up @@ -127,9 +127,8 @@ export class URLSearchParams {

toString(): string {
var paramsList = [];
MapWrapper.forEach(this.paramsMap, (values, k) => {
ListWrapper.forEach(values, v => { paramsList.push(k + '=' + v); });
});
MapWrapper.forEach(this.paramsMap,
(values, k) => { values.forEach(v => paramsList.push(k + '=' + v)); });
return paramsList.join('&');
}

Expand Down
4 changes: 2 additions & 2 deletions modules/angular2/src/router/path_recognizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from 'angular2/src/core/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';

import {Map, MapWrapper, StringMapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
import {Map, MapWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection';

import {RouteHandler} from './route_handler';
import {Url, RootUrl, serializeParams} from './url_parser';
Expand All @@ -35,7 +35,7 @@ class TouchMap {
getUnused(): {[key: string]: any} {
var unused: {[key: string]: any} = StringMapWrapper.create();
var keys = StringMapWrapper.keys(this.keys);
ListWrapper.forEach(keys, (key) => { unused[key] = StringMapWrapper.get(this.map, key); });
keys.forEach(key => unused[key] = StringMapWrapper.get(this.map, key));
return unused;
}
}
Expand Down
3 changes: 2 additions & 1 deletion modules/angular2/src/router/route_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ export class RouteRegistry {
var annotation = annotations[i];

if (annotation instanceof RouteConfig) {
ListWrapper.forEach(annotation.configs, (config) => this.config(component, config));
let routeCfgs: RouteDefinition[] = annotation.configs;
routeCfgs.forEach(config => this.config(component, config));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/src/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ export class Router {
}

if (rest[rest.length - 1] == '') {
ListWrapper.removeLast(rest);
rest.pop();
}

if (rest.length < 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ObservableWrapper,
EventEmitter
} from "angular2/src/core/facade/async";
import {ListWrapper, StringMapWrapper, MapWrapper} from "angular2/src/core/facade/collection";
import {StringMapWrapper, MapWrapper} from "angular2/src/core/facade/collection";
import {Serializer} from "angular2/src/web_workers/shared/serializer";
import {Injectable} from "angular2/src/core/di";
import {Type, StringWrapper} from "angular2/src/core/facade/lang";
Expand Down Expand Up @@ -58,7 +58,7 @@ export class ClientMessageBroker {
runOnService(args: UiArguments, returnType: Type): Promise<any> {
var fnArgs = [];
if (isPresent(args.args)) {
ListWrapper.forEach(args.args, (argument) => {
args.args.forEach(argument => {
if (argument.type != null) {
fnArgs.push(this._serializer.serialize(argument.value, argument.type));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class RenderViewWithFragmentsStore {
this._lookupByView.set(view.viewRef, startIndex);
startIndex++;

ListWrapper.forEach(view.fragmentRefs, (ref) => {
view.fragmentRefs.forEach(ref => {
this._lookupByIndex.set(startIndex, ref);
this._lookupByView.set(ref, startIndex);
startIndex++;
Expand Down
8 changes: 3 additions & 5 deletions modules/angular2/src/web_workers/shared/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "angular2/src/core/facade/lang";
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';

import {ListWrapper, Map, StringMapWrapper, MapWrapper} from "angular2/src/core/facade/collection";
import {Map, StringMapWrapper, MapWrapper} from "angular2/src/core/facade/collection";
import {
RenderProtoViewRef,
RenderViewRef,
Expand Down Expand Up @@ -52,9 +52,7 @@ export class Serializer {
return null;
}
if (isArray(obj)) {
var serializedObj = [];
ListWrapper.forEach(obj, (val) => { serializedObj.push(this.serialize(val, type)); });
return serializedObj;
return (<any[]>obj).map(v => this.serialize(v, type));
}
if (type == PRIMITIVE) {
return obj;
Expand All @@ -80,7 +78,7 @@ export class Serializer {
}
if (isArray(map)) {
var obj: any[] = [];
ListWrapper.forEach(map, (val) => { obj.push(this.deserialize(val, type, data)); });
(<any[]>map).forEach(val => obj.push(this.deserialize(val, type, data)));
return obj;
}
if (type == PRIMITIVE) {
Expand Down
Loading