Skip to content

Commit

Permalink
lint-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoo11 committed Aug 2, 2019
1 parent 890de1d commit 7356e71
Show file tree
Hide file tree
Showing 60 changed files with 242 additions and 274 deletions.
20 changes: 10 additions & 10 deletions benchmark/cruds/1-cruds.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import {HandsOnEngine} from "../../src";
import {sheet as Sb} from "../sheets/01-simple-big";
import {sheet as Bs} from "../sheets/06-big-sum";
import {batch} from "./operations";
import {HandsOnEngine} from '../../src'
import {sheet as Sb} from '../sheets/01-simple-big'
import {sheet as Bs} from '../sheets/06-big-sum'
import {batch} from './operations'

function start() {
let engine = HandsOnEngine.buildFromArray(Sb(10000))
let dimensions = engine.getSheetsDimensions().get("Sheet1")!
console.log("\n== Simple big ==", dimensions)
let dimensions = engine.getSheetsDimensions().get('Sheet1')!
console.log('\n== Simple big ==', dimensions)
batch(engine)

engine = HandsOnEngine.buildFromArray(Sb(100000))
dimensions = engine.getSheetsDimensions().get("Sheet1")!
console.log("\n== Simple big ==", dimensions)
dimensions = engine.getSheetsDimensions().get('Sheet1')!
console.log('\n== Simple big ==', dimensions)
batch(engine)

engine = HandsOnEngine.buildFromArray(Bs(100000))
dimensions = engine.getSheetsDimensions().get("Sheet1")!
console.log("\n== Big sum ==", dimensions)
dimensions = engine.getSheetsDimensions().get('Sheet1')!
console.log('\n== Big sum ==', dimensions)
batch(engine)
}

Expand Down
18 changes: 9 additions & 9 deletions benchmark/cruds/2-matrix.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import {Config, HandsOnEngine} from "../../src";
import {sheet} from "../sheets/14-numeric-matrix";
import {batch} from "./operations";
import {Config, HandsOnEngine} from '../../src'
import {sheet} from '../sheets/14-numeric-matrix'
import {batch} from './operations'

function start() {
let engine = HandsOnEngine.buildFromArray(sheet(1000, 1000), new Config({
matrixDetection: false
matrixDetection: false,
}))
let dimensions = engine.getSheetsDimensions().get("Sheet1")!
console.log("\n== Matrix - detection off ==", dimensions)
let dimensions = engine.getSheetsDimensions().get('Sheet1')!
console.log('\n== Matrix - detection off ==', dimensions)

batch(engine)

engine = HandsOnEngine.buildFromArray(sheet(1000, 1000), new Config({
matrixDetectionThreshold: 1,
matrixDetection: true
matrixDetection: true,
}))
dimensions = engine.getSheetsDimensions().get("Sheet1")!
console.log("\n== Matrix - detection on ==", dimensions)
dimensions = engine.getSheetsDimensions().get('Sheet1')!
console.log('\n== Matrix - detection on ==', dimensions)

batch(engine)
}
Expand Down
31 changes: 15 additions & 16 deletions benchmark/cruds/operations.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
import {HandsOnEngine} from "../../src";

import {HandsOnEngine} from '../../src'

export function addColumns(engine: HandsOnEngine) {
let dimensions = getDimensions(engine)
measure("Add column at the beginning", () => engine.addColumns(0, 0, 1))
measure('Add column at the beginning', () => engine.addColumns(0, 0, 1))
dimensions = getDimensions(engine)
measure("Add column in the middle ", () => engine.addColumns(0, half(dimensions.width), 1))
measure('Add column in the middle ', () => engine.addColumns(0, half(dimensions.width), 1))
dimensions = getDimensions(engine)
measure("Add column at the end ", () => engine.addColumns(0, dimensions.width - 1, 1))
measure('Add column at the end ', () => engine.addColumns(0, dimensions.width - 1, 1))
}

export function addRows(engine: HandsOnEngine) {
let dimensions = getDimensions(engine)
measure("Add row at the beginning", () => engine.addRows(0, 0, 1))
measure('Add row at the beginning', () => engine.addRows(0, 0, 1))
dimensions = getDimensions(engine)
measure("Add row in the middle ", () => engine.addRows(0, half(dimensions.height), 1))
measure('Add row in the middle ', () => engine.addRows(0, half(dimensions.height), 1))
dimensions = getDimensions(engine)
measure("Add row at the end ", () => engine.addRows(0, dimensions.height - 1, 1))
measure('Add row at the end ', () => engine.addRows(0, dimensions.height - 1, 1))
}

export function removeColumns(engine: HandsOnEngine) {
let dimensions = getDimensions(engine)
measure("Remove column at the beginning", () => engine.removeColumns(0, 0, 0))
measure('Remove column at the beginning', () => engine.removeColumns(0, 0, 0))
dimensions = getDimensions(engine)
measure("Remove column in the middle ", () => engine.removeColumns(0, half(dimensions.width), half(dimensions.width)))
measure('Remove column in the middle ', () => engine.removeColumns(0, half(dimensions.width), half(dimensions.width)))
dimensions = getDimensions(engine)
measure("Remove column at the end ", () => engine.removeColumns(0, dimensions.width - 1, dimensions.width - 1))
measure('Remove column at the end ', () => engine.removeColumns(0, dimensions.width - 1, dimensions.width - 1))
}

export function removeRows(engine: HandsOnEngine) {
let dimensions = getDimensions(engine)
measure("Remove row at the beginning", () => engine.removeRows(0, 0, 0))
measure('Remove row at the beginning', () => engine.removeRows(0, 0, 0))
dimensions = getDimensions(engine)
measure("Remove row in the middle ", () => engine.removeRows(0, half(dimensions.height), half(dimensions.height)))
measure('Remove row in the middle ', () => engine.removeRows(0, half(dimensions.height), half(dimensions.height)))
dimensions = getDimensions(engine)
measure("Remove row at the end ", () => engine.removeRows(0, dimensions.height - 1, dimensions.height - 1))
measure('Remove row at the end ', () => engine.removeRows(0, dimensions.height - 1, dimensions.height - 1))
}

export function batch(engine: HandsOnEngine) {
Expand All @@ -49,7 +48,7 @@ function half(num: number) {
}

function getDimensions(engine: HandsOnEngine) {
return engine.getSheetsDimensions().get("Sheet1")!
return engine.getSheetsDimensions().get('Sheet1')!
}

function measure<T>(name: String, func: () => T): { time: number, result: T } {
Expand All @@ -58,5 +57,5 @@ function measure<T>(name: String, func: () => T): { time: number, result: T } {
const end = Date.now()
const time = end - start
console.log(`${name}: ${time} ms`)
return { time: time, result: result}
return { time, result}
}
6 changes: 3 additions & 3 deletions benchmark/sheets/14-numeric-matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ export function sheet(rows: number = 10000, cols: number = 100) {
const sheet = []

let x = 0
for (let i=0; i<rows; ++i) {
for (let i = 0; i < rows; ++i) {
const row = []
for (let j=0; j<cols; ++j) {
row.push("" + x)
for (let j = 0; j < cols; ++j) {
row.push('' + x)
++x
}
sheet.push(row)
Expand Down
12 changes: 6 additions & 6 deletions src/AbsoluteCellRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class AbsoluteCellRange {
} else if (prefixRange.isVerticalPrefixOf(this)) {
return this.withStart(simpleCellAddress(this.start.sheet, this.start.col, this.start.row + prefixRange.height()))
} else {
throw Error("Not a prefix")
throw Error('Not a prefix')
}
}

Expand All @@ -210,14 +210,14 @@ export class AbsoluteCellRange {
return (otherRange.start.row === this.start.row) &&
(otherRange.end.row >= this.end.row) &&
(otherRange.start.col === this.start.col) &&
(otherRange.end.col === this.end.col);
(otherRange.end.col === this.end.col)
}

public isHorizontalPrefixOf(otherRange: AbsoluteCellRange): boolean {
return (otherRange.start.col === this.start.col) &&
(otherRange.end.col >= this.end.col) &&
(otherRange.start.row === this.start.row) &&
(otherRange.end.row === this.end.row);
(otherRange.end.row === this.end.row)
}

public withoutSuffix(suffixRange: AbsoluteCellRange): AbsoluteCellRange {
Expand All @@ -226,7 +226,7 @@ export class AbsoluteCellRange {
} else if (suffixRange.isVerticalSuffixOf(this)) {
return this.withEnd(simpleCellAddress(this.end.sheet, this.end.col, this.end.row - suffixRange.height()))
} else {
throw Error("Not a suffix")
throw Error('Not a suffix')
}
}

Expand All @@ -238,14 +238,14 @@ export class AbsoluteCellRange {
return (otherRange.end.row === this.end.row) &&
(otherRange.start.row <= this.start.row) &&
(otherRange.start.col === this.start.col) &&
(otherRange.end.col === this.end.col);
(otherRange.end.col === this.end.col)
}

public isHorizontalSuffixOf(otherRange: AbsoluteCellRange): boolean {
return (otherRange.end.col === this.end.col) &&
(otherRange.start.col <= this.start.col) &&
(otherRange.start.row === this.start.row) &&
(otherRange.end.row === this.end.row);
(otherRange.end.row === this.end.row)
}

public includesRow(row: number) {
Expand Down
2 changes: 1 addition & 1 deletion src/Config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {GPUInternalMode, GPUMode} from 'gpu.js'
import {TranslationPackage, enGB} from './i18n'
import {enGB, TranslationPackage} from './i18n'

type PossibleGPUMode = GPUMode | GPUInternalMode

Expand Down
14 changes: 7 additions & 7 deletions src/DependencyGraph/AddressMapping.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {CellValue, SheetCellAddress, SimpleCellAddress, EmptyValue, simpleCellAddress} from '../Cell'
import {AbsoluteCellRange} from '../AbsoluteCellRange'
import {CellValue, EmptyValue, SheetCellAddress, SimpleCellAddress, simpleCellAddress} from '../Cell'
import {Sheet} from '../GraphBuilder'
import {EmptyCellVertex, MatrixVertex} from './'
import {CellVertex} from './Vertex'
import { MatrixVertex, EmptyCellVertex } from './'
import {AbsoluteCellRange} from '../AbsoluteCellRange'

/**
* Interface for mapping from sheet addresses to vertices.
Expand Down Expand Up @@ -181,8 +181,8 @@ export class SparseStrategy implements IAddressMappingStrategy {
}

public* getEntries(sheet: number): IterableIterator<[SimpleCellAddress, CellVertex | null]> {
for (const [colNumber,col] of this.mapping) {
for (const [rowNumber,value] of col) {
for (const [colNumber, col] of this.mapping) {
for (const [rowNumber, value] of col) {
yield [simpleCellAddress(sheet, colNumber, rowNumber), value]
}
}
Expand Down Expand Up @@ -290,8 +290,8 @@ export class DenseStrategy implements IAddressMappingStrategy {
}

public* getEntries(sheet: number): IterableIterator<[SimpleCellAddress, CellVertex | null]> {
for (let y=0; y<this.height; ++y) {
for (let x=0; x<this.width; ++x) {
for (let y = 0; y < this.height; ++y) {
for (let x = 0; x < this.width; ++x) {
yield [simpleCellAddress(sheet, x, y), this.mapping[y][x]]
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/DependencyGraph/DependencyGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import assert from 'assert'
import {AbsoluteCellRange} from '../AbsoluteCellRange'
import {CellValue, simpleCellAddress, SimpleCellAddress} from '../Cell'
import {CellDependency} from '../CellDependency'
import {filterWith, map} from '../generatorUtils'
import {findSmallerRange} from '../interpreter/plugin/SumprodPlugin'
import {absolutizeDependencies, Ast, AstNodeType, CellAddress, collectDependencies, ParserWithCaching} from '../parser'
import {absolutizeDependencies, Ast, AstNodeType, CellAddress, collectDependencies} from '../parser'
import {CellVertex, EmptyCellVertex, FormulaCellVertex, MatrixVertex, RangeVertex, ValueCellVertex, Vertex} from './'
import {AddressMapping} from './AddressMapping'
import {Graph, TopSortResult} from './Graph'
import {MatrixMapping} from './MatrixMapping'
import {RangeMapping} from './RangeMapping'
import {SheetMapping} from './SheetMapping'
import {CellVertex, EmptyCellVertex, FormulaCellVertex, MatrixVertex, RangeVertex, ValueCellVertex, Vertex} from './'
import {filterWith, map} from "../generatorUtils";

export class DependencyGraph {
private recentlyChangedVertices: Set<Vertex> = new Set()
Expand Down Expand Up @@ -218,7 +218,7 @@ export class DependencyGraph {

public ensureNoMatrixInRange(range: AbsoluteCellRange) {
if (this.matrixMapping.isMatrixInRange(range)) {
throw Error("It is not possible to move / replace cells with matrix")
throw Error('It is not possible to move / replace cells with matrix')
}
}

Expand All @@ -233,7 +233,7 @@ export class DependencyGraph {
if (sourceVertex !== null) {
this.addressMapping.setCell(targetAddress, sourceVertex)
let emptyVertex = null
for (let adjacentNode of this.graph.adjacentNodes(sourceVertex)) {
for (const adjacentNode of this.graph.adjacentNodes(sourceVertex)) {
if (adjacentNode instanceof RangeVertex && !sourceRange.containsRange(adjacentNode.range)) {
emptyVertex = emptyVertex || this.fetchOrCreateEmptyCell(sourceAddress)
this.graph.addEdge(emptyVertex, adjacentNode)
Expand All @@ -249,7 +249,7 @@ export class DependencyGraph {
if (sourceVertex === null) {
this.addressMapping.removeCell(targetAddress)
}
for (let adjacentNode of this.graph.adjacentNodes(targetVertex)) {
for (const adjacentNode of this.graph.adjacentNodes(targetVertex)) {
sourceVertex = sourceVertex || this.fetchOrCreateEmptyCell(targetAddress)
this.graph.addEdge(sourceVertex, adjacentNode)
}
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyGraph/FormulaCellVertex.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Ast} from '../parser'
import {CellValue, SimpleCellAddress} from '../Cell'
import {Ast} from '../parser'

/**
* Represents vertex which keeps formula
Expand Down
5 changes: 2 additions & 3 deletions src/DependencyGraph/Graph.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {EmptyCellVertex} from "./EmptyCellVertex";

export interface TopSortResult<T> { sorted: T[], cycled: T[] }
/**
Expand All @@ -8,11 +7,11 @@ export class Graph<T> {
/** Set with nodes in graph. */
public nodes: Set<T>

public specialNodes: Set<T>

/** Nodes adjacency mapping. */
private edges: Map<T, Set<T>>

public specialNodes: Set<T>

constructor() {
this.nodes = new Set()
this.edges = new Map()
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyGraph/MatrixMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class MatrixMapping {
}, this.matrixMapping.entries()[Symbol.iterator]())
}

public truncateMatricesByRows(sheet: number, startRow: number, endRow: number): Array<MatrixVertex> {
public truncateMatricesByRows(sheet: number, startRow: number, endRow: number): MatrixVertex[] {
const verticesToRemove = Array<MatrixVertex>()
for (const [key, matrix] of this.numericMatricesInRows(sheet, startRow, endRow)) {
matrix.removeRows(sheet, startRow, endRow)
Expand All @@ -78,7 +78,7 @@ export class MatrixMapping {
return verticesToRemove
}

public truncateMatricesByColumns(sheet: number, startColumn: number, endColumn: number): Array<MatrixVertex> {
public truncateMatricesByColumns(sheet: number, startColumn: number, endColumn: number): MatrixVertex[] {
const verticesToRemove = Array<MatrixVertex>()
for (const [key, matrix] of this.numericMatricesInColumns(sheet, startColumn, endColumn)) {
matrix.removeColumns(sheet, startColumn, endColumn)
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyGraph/MatrixVertex.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {AbsoluteCellRange} from '../AbsoluteCellRange'
import {IMatrix, Matrix, NotComputedMatrix} from '../Matrix'
import {CellError, CellValue, SimpleCellAddress} from '../Cell'
import {IMatrix, Matrix, NotComputedMatrix} from '../Matrix'
import {Ast} from '../parser'

export class MatrixVertex {
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyGraph/RangeMapping.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {AbsoluteCellRange} from '../AbsoluteCellRange'
import {SimpleCellAddress} from '../Cell'
import {RangeVertex} from './'
import {AbsoluteCellRange} from "../AbsoluteCellRange";

/**
* Mapping from address ranges to range vertices
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyGraph/RangeVertex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type CriterionCache = Map<string, [CellValue, CriterionLambda]>
/**
* Represents vertex bound to range
*/
export class RangeVertex {
export class RangeVertex {
/** Cache for associative aggregate functions. */
private functionCache: Map<string, CellValue>

Expand Down
2 changes: 1 addition & 1 deletion src/DependencyGraph/ValueCellVertex.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {CellError, CellValue} from '../Cell'
import {CellError} from '../Cell'

type ValueCellVertexValue = number | boolean | string | CellError

Expand Down
2 changes: 1 addition & 1 deletion src/DependencyGraph/Vertex.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {FormulaCellVertex, EmptyCellVertex, MatrixVertex, ValueCellVertex, RangeVertex} from './'
import {EmptyCellVertex, FormulaCellVertex, MatrixVertex, RangeVertex, ValueCellVertex} from './'

/**
* Represents vertex which keeps values of one or more cells
Expand Down
9 changes: 1 addition & 8 deletions src/GraphBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@

import {CellError, ErrorType, simpleCellAddress, SimpleCellAddress} from './Cell'
import {CellDependency} from './CellDependency'
import {Config} from './Config'
import {DependencyGraph} from './DependencyGraph'
import {
FormulaCellVertex,
MatrixVertex,
ValueCellVertex,
Vertex,
} from './DependencyGraph'
import {DependencyGraph, FormulaCellVertex, MatrixVertex, ValueCellVertex, Vertex} from './DependencyGraph'
import {GraphBuilderMatrixHeuristic} from './GraphBuilderMatrixHeuristic'
import {checkMatrixSize, MatrixSizeCheck} from './Matrix'
import {isFormula, isMatrix, ParserWithCaching, ProcedureAst} from './parser'
Expand Down
Loading

0 comments on commit 7356e71

Please sign in to comment.