From 2e118aba789afb40d6b596625e89cd008773999f Mon Sep 17 00:00:00 2001 From: Brian Hulette Date: Thu, 11 Jan 2018 17:02:44 -0500 Subject: [PATCH] linter --- js/src/Arrow.ts | 2 -- js/src/predicate.ts | 26 +++++++++++++------------- js/src/table.ts | 13 +++++++------ 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/js/src/Arrow.ts b/js/src/Arrow.ts index ed9ff577bb1e5..926ee88720bf0 100644 --- a/js/src/Arrow.ts +++ b/js/src/Arrow.ts @@ -87,8 +87,6 @@ export { FixedSizeListVector, }; - - /* These exports are needed for the closure umd targets */ try { const Arrow = eval('exports'); diff --git a/js/src/predicate.ts b/js/src/predicate.ts index dbfc7479ffbb0..2b0be44d472dc 100644 --- a/js/src/predicate.ts +++ b/js/src/predicate.ts @@ -1,29 +1,29 @@ -import { Vector } from "./vector/vector"; -import { DictionaryVector } from "./vector/dictionary"; +import { Vector } from './vector/vector'; +import { DictionaryVector } from './vector/dictionary'; export type ValueFunc = (idx: number, cols: Vector[]) => T|null; export type PredicateFunc = (idx: number, cols: Vector[]) => boolean; export abstract class Value { eq(other: Value|T): Predicate { - if (!(other instanceof Value)) other = new Literal(other); + if (!(other instanceof Value)) { other = new Literal(other); } return new Equals(this, other); } lteq(other: Value|T): Predicate { - if (!(other instanceof Value)) other = new Literal(other); + if (!(other instanceof Value)) { other = new Literal(other); } return new LTeq(this, other); } gteq(other: Value|T): Predicate { - if (!(other instanceof Value)) other = new Literal(other); + if (!(other instanceof Value)) { other = new Literal(other); } return new GTeq(this, other); } } -class Literal extends Value { +class Literal extends Value { constructor(public v: T) { super(); } } -class Col extends Value { +class Col extends Value { vector: Vector; colidx: number; @@ -39,9 +39,9 @@ class Col extends Value { break; } } - if (this.colidx < 0) throw new Error(`Failed to bind Col "${this.name}"`) + if (this.colidx < 0) { throw new Error(`Failed to bind Col "${this.name}"`); } } - this.vector = cols[this.colidx] + this.vector = cols[this.colidx]; return this.vector.get.bind(this.vector); } @@ -55,7 +55,7 @@ export abstract class Predicate { ands(): Predicate[] { return [this]; } } -abstract class ComparisonPredicate extends Predicate { +abstract class ComparisonPredicate extends Predicate { constructor(public readonly left: Value, public readonly right: Value) { super(); } @@ -94,7 +94,7 @@ class And extends CombinationPredicate { const right = this.right.bind(cols); return (idx: number, cols: Vector[]) => left(idx, cols) && right(idx, cols); } - ands() : Predicate[] { return this.left.ands().concat(this.right.ands()); } + ands(): Predicate[] { return this.left.ands().concat(this.right.ands()); } } class Or extends CombinationPredicate { @@ -121,7 +121,7 @@ class Equals extends ComparisonPredicate { const col_func = col.bind(cols); if (col.vector instanceof DictionaryVector) { // Assume that there is only one key with the value `lit.v` - let key = -1 + let key = -1; for (; ++key < col.vector.data.length;) { if (col.vector.data.get(key) === lit.v) { break; @@ -138,7 +138,7 @@ class Equals extends ComparisonPredicate { } else { return (idx: number) => { return (col.vector as DictionaryVector).getKey(idx) === key; - } + }; } } else { return (idx: number, cols: Vector[]) => col_func(idx, cols) == lit.v; diff --git a/js/src/table.ts b/js/src/table.ts index 4ab34192376f8..613699f0b66b1 100644 --- a/js/src/table.ts +++ b/js/src/table.ts @@ -86,12 +86,13 @@ export class Table implements DataFrame { } get(idx: number): TableRow { let batch = 0; - while (idx > this.lengths[batch] && batch < this.lengths.length) + while (idx > this.lengths[batch] && batch < this.lengths.length) { idx -= this.lengths[batch++]; + } - if (batch === this.lengths.length) throw new Error("Overflow") + if (batch === this.lengths.length) { throw new Error('Overflow'); } - else return new TableRow(this.batches[batch], idx); + return new TableRow(this.batches[batch], idx); } filter(predicate: Predicate): DataFrame { return new FilteredDataFrame(this, predicate); @@ -105,7 +106,7 @@ export class Table implements DataFrame { // yield all indices for (let idx = -1; ++idx < length;) { - next(idx, columns) + next(idx, columns); } } } @@ -149,7 +150,7 @@ class FilteredDataFrame implements DataFrame { // yield all indices for (let idx = -1; ++idx < length;) { - if (predicate(idx, columns)) next(idx, columns); + if (predicate(idx, columns)) { next(idx, columns); } } } } @@ -171,7 +172,7 @@ class FilteredDataFrame implements DataFrame { // yield all indices for (let idx = -1; ++idx < length;) { - if (predicate(idx, columns)) ++sum; + if (predicate(idx, columns)) { ++sum; } } } return sum;