Skip to content

Commit

Permalink
Remove some unused "renameReference" code in static/dynamic blocks (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Sep 11, 2023
1 parent 3b33630 commit 60acfea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 41 deletions.
34 changes: 10 additions & 24 deletions packages/core/util/blockTypes.ts
@@ -1,3 +1,5 @@
import { sum } from '.'

type Func<T> = (value: BaseBlock, index: number, array: BaseBlock[]) => T

export class BlockSet {
Expand Down Expand Up @@ -39,16 +41,17 @@ export class BlockSet {

get totalWidthPx() {
return this.blocks.length > 0
? this.blocks.map(blocks => blocks.widthPx).reduce((a, b) => a + b)
? sum(this.blocks.map(blocks => blocks.widthPx))
: 0
}

get totalWidthPxWithoutBorders() {
return this.blocks.length > 0
? this.blocks
.filter(block => block.variant !== 'boundary')
.map(blocks => blocks.widthPx)
.reduce((a, b) => a + b)
? sum(
this.blocks
.filter(block => block.variant !== 'boundary')
.map(blocks => blocks.widthPx),
)
: 0
}

Expand All @@ -61,9 +64,7 @@ export class BlockSet {
}

get totalBp() {
return this.contentBlocks
.map(block => block.end - block.start)
.reduce((a, b) => a + b, 0)
return sum(this.contentBlocks.map(block => block.end - block.start))
}
}

Expand Down Expand Up @@ -94,7 +95,7 @@ export class BaseBlock {
* a block that should be shown as filled with data
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(data: any) {
constructor(data: Record<string, any>) {
Object.assign(this, data)
this.assemblyName = data.assemblyName
this.refName = data.refName
Expand All @@ -104,21 +105,6 @@ export class BaseBlock {
this.offsetPx = data.offsetPx
}

/**
* rename the reference sequence of this block and return a new one
*
* @param refName -
* @returns either a new block with a renamed reference sequence,
* or the same block, if the ref name is not actually different
*/
renameReference(refName: string) {
if (this.refName && refName !== this.refName) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return new (this.constructor as any)({ ...this, refName })
}
return this
}

toRegion() {
return {
refName: this.refName,
Expand Down
21 changes: 4 additions & 17 deletions plugins/dotplot-view/src/DotplotView/blockTypes.ts
@@ -1,3 +1,5 @@
import { sum } from '@jbrowse/core/util'

type Func<T> = (value: BaseBlock, index: number, array: BaseBlock[]) => T

export class BlockSet {
Expand Down Expand Up @@ -35,7 +37,7 @@ export class BlockSet {

get totalWidthPx() {
return this.blocks.length
? this.blocks.map(blocks => blocks.widthPx).reduce((a, b) => a + b)
? sum(this.blocks.map(blocks => blocks.widthPx))
: 0
}

Expand Down Expand Up @@ -69,7 +71,7 @@ export class BaseBlock {
* a block that should be shown as filled with data
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(data: any) {
constructor(data: Record<string, any>) {
Object.assign(this, data)
this.assemblyName = data.assemblyName
this.refName = data.refName
Expand All @@ -78,21 +80,6 @@ export class BaseBlock {
this.key = data.key
}

/**
* rename the reference sequence of this block and return a new one
*
* @param refName -
* @returns either a new block with a renamed reference sequence,
* or the same block, if the ref name is not actually different
*/
renameReference(refName: string) {
if (this.refName && refName !== this.refName) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return new (this.constructor as any)({ ...this, refName })
}
return this
}

toRegion() {
return {
refName: this.refName,
Expand Down

0 comments on commit 60acfea

Please sign in to comment.