cleanup(router): fix tslint errors

This commit is contained in:
vsavkin
2016-06-08 11:13:41 -07:00
parent 8a1cdc2dd5
commit 6988a550ea
20 changed files with 439 additions and 371 deletions

View File

@ -1,4 +1,4 @@
export function shallowEqual(a: {[x:string]:any}, b: {[x:string]:any}): boolean {
export function shallowEqual(a: {[x: string]: any}, b: {[x: string]: any}): boolean {
var k1 = Object.keys(a);
var k2 = Object.keys(b);
if (k1.length != k2.length) {
@ -24,12 +24,12 @@ export function flatten<T>(a: T[][]): T[] {
return target;
}
export function first<T>(a: T[]): T | null {
export function first<T>(a: T[]): T|null {
return a.length > 0 ? a[0] : null;
}
export function and(bools: boolean[]): boolean {
return bools.reduce((a,b) => a && b, true);
return bools.reduce((a, b) => a && b, true);
}
export function merge<V>(m1: {[key: string]: V}, m2: {[key: string]: V}): {[key: string]: V} {
@ -50,7 +50,8 @@ export function merge<V>(m1: {[key: string]: V}, m2: {[key: string]: V}): {[key:
return m;
}
export function forEach<K, V>(map: {[key: string]: V}, callback: /*(V, K) => void*/ Function): void {
export function forEach<K, V>(
map: {[key: string]: V}, callback: /*(V, K) => void*/ Function): void {
for (var prop in map) {
if (map.hasOwnProperty(prop)) {
callback(map[prop], prop);

View File

@ -6,7 +6,7 @@ export class Tree<T> {
get root(): T { return this._root.value; }
parent(t: T): T | null {
parent(t: T): T|null {
const p = this.pathFromRoot(t);
return p.length > 1 ? p[p.length - 2] : null;
}
@ -16,7 +16,7 @@ export class Tree<T> {
return n ? n.children.map(t => t.value) : [];
}
firstChild(t: T): T | null {
firstChild(t: T): T|null {
const n = findNode(t, this._root);
return n && n.children.length > 0 ? n.children[0].value : null;
}
@ -34,7 +34,7 @@ export class Tree<T> {
contains(tree: Tree<T>): boolean { return contains(this._root, tree._root); }
}
function findNode<T>(expected: T, c: TreeNode<T>): TreeNode<T> | null {
function findNode<T>(expected: T, c: TreeNode<T>): TreeNode<T>|null {
if (expected === c.value) return c;
for (let cc of c.children) {
const r = findNode(expected, cc);