Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Hulette committed Jan 12, 2018
1 parent a788db3 commit 2e118ab
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
2 changes: 0 additions & 2 deletions js/src/Arrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ export {
FixedSizeListVector,
};



/* These exports are needed for the closure umd targets */
try {
const Arrow = eval('exports');
Expand Down
26 changes: 13 additions & 13 deletions js/src/predicate.ts
Original file line number Diff line number Diff line change
@@ -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<T> = (idx: number, cols: Vector[]) => T|null;
export type PredicateFunc = (idx: number, cols: Vector[]) => boolean;

export abstract class Value<T> {
eq(other: Value<T>|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>|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>|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<T=any> extends Value<T> {
class Literal<T= any> extends Value<T> {
constructor(public v: T) { super(); }
}

class Col<T=any> extends Value<T> {
class Col<T= any> extends Value<T> {
vector: Vector<T>;
colidx: number;

Expand All @@ -39,9 +39,9 @@ class Col<T=any> extends Value<T> {
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);
}

Expand All @@ -55,7 +55,7 @@ export abstract class Predicate {
ands(): Predicate[] { return [this]; }
}

abstract class ComparisonPredicate<T=any> extends Predicate {
abstract class ComparisonPredicate<T= any> extends Predicate {
constructor(public readonly left: Value<T>, public readonly right: Value<T>) {
super();
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
Expand All @@ -138,7 +138,7 @@ class Equals extends ComparisonPredicate {
} else {
return (idx: number) => {
return (col.vector as DictionaryVector<any>).getKey(idx) === key;
}
};
}
} else {
return (idx: number, cols: Vector[]) => col_func(idx, cols) == lit.v;
Expand Down
13 changes: 7 additions & 6 deletions js/src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -105,7 +106,7 @@ export class Table implements DataFrame {

// yield all indices
for (let idx = -1; ++idx < length;) {
next(idx, columns)
next(idx, columns);
}
}
}
Expand Down Expand Up @@ -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); }
}
}
}
Expand All @@ -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;
Expand Down

0 comments on commit 2e118ab

Please sign in to comment.