Skip to content

Commit

Permalink
Use at(-1)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Aug 9, 2024
1 parent 022b2d2 commit 9ee660a
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/bigbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class BigBed extends BBI {
const b = data
const dataView = new DataView(b.buffer, b.byteOffset, b.length)
let offset = 0
const _size = dataView.getUint16(offset, le)
// const _size = dataView.getUint16(offset, le)
offset += 2
const count = dataView.getUint16(offset, le)
offset += 2
Expand Down
14 changes: 1 addition & 13 deletions src/bigint-polyfill/polyfill.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getBigInt64, getBigUint64, setBigInt64, setBigUint64 } from './pure'
import { getBigInt64, getBigUint64 } from './pure'

if (!('getBigInt64' in DataView)) {
DataView.prototype.getBigInt64 = function (byteOffset, littleEndian) {
Expand All @@ -11,15 +11,3 @@ if (!('getBigUint64' in DataView)) {
return getBigUint64(this, byteOffset, littleEndian)
}
}

if (!('setBigInt64' in DataView)) {
DataView.prototype.setBigInt64 = function (byteOffset, value, littleEndian) {
setBigInt64(this, byteOffset, value, littleEndian)
}
}

if (!('setBigUint64' in DataView)) {
DataView.prototype.setBigUint64 = function (byteOffset, value, littleEndian) {
setBigUint64(this, byteOffset, value, littleEndian)
}
}
36 changes: 0 additions & 36 deletions src/bigint-polyfill/pure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,39 +40,3 @@ export function getBigUint64(
BigInt(a * littleEndianMask + b * bigEndianMask)
)
}

export function setBigInt64(
dataView: DataView,
byteOffset: number,
value: bigint,
littleEndian: boolean | undefined,
) {
const hi = Number(value >> BigInt32)
const lo = Number(value & BigInt(0xffffffff))

if (littleEndian) {
dataView.setInt32(byteOffset + 4, hi, littleEndian)
dataView.setUint32(byteOffset, lo, littleEndian)
} else {
dataView.setInt32(byteOffset, hi, littleEndian)
dataView.setUint32(byteOffset + 4, lo, littleEndian)
}
}

export function setBigUint64(
dataView: DataView,
byteOffset: number,
value: bigint,
littleEndian: boolean | undefined,
) {
const hi = Number(value >> BigInt32)
const lo = Number(value & BigInt(0xffffffff))

if (littleEndian) {
dataView.setUint32(byteOffset + 4, hi, littleEndian)
dataView.setUint32(byteOffset, lo, littleEndian)
} else {
dataView.setUint32(byteOffset, hi, littleEndian)
dataView.setUint32(byteOffset + 4, lo, littleEndian)
}
}
2 changes: 1 addition & 1 deletion src/range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class Range {
}

get max() {
return this.ranges[this.ranges.length - 1].max
return this.ranges.at(-1).max

Check failure on line 22 in src/range.ts

View workflow job for this annotation

GitHub Actions / Lint, build, and test on node 20.x and ubuntu-latest

Object is possibly 'undefined'.
}

public contains(pos: number) {
Expand Down

0 comments on commit 9ee660a

Please sign in to comment.