Skip to content

Commit

Permalink
Remove longfn
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Dec 18, 2024
1 parent 485842f commit dd8f0fd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"@gmod/bgzf-filehandle": "^2.0.1",
"crc": "^4.3.2",
"generic-filehandle2": "^1.0.0",
"longfn": "^1.3.1",
"quick-lru": "^4.0.0"
},
"devDependencies": {
Expand Down
16 changes: 16 additions & 0 deletions src/long.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const TWO_PWR_16_DBL = 1 << 16
export const TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL

export function longFromBytesToUnsigned(source: Uint8Array, i = 0) {
const low =
source[i] |
(source[i + 1] << 8) |
(source[i + 2] << 16) |
(source[i + 3] << 24)
const high =
source[i + 4] |
(source[i + 5] << 8) |
(source[i + 6] << 16) |
(source[i + 7] << 24)
return (high >>> 0) * TWO_PWR_32_DBL + (low >>> 0)
}
4 changes: 2 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fromBytesLE, toNumber } from 'longfn'
import Chunk from './chunk'
import { longFromBytesToUnsigned } from './long'
import VirtualOffset from './virtualOffset'

export function timeout(ms: number) {
Expand Down Expand Up @@ -105,7 +105,7 @@ export function optimizeChunks(chunks: Chunk[], lowest?: VirtualOffset) {

export function parsePseudoBin(bytes: Uint8Array, offset: number) {
return {
lineCount: toNumber(fromBytesLE(bytes.subarray(offset, offset + 8), true)),
lineCount: longFromBytesToUnsigned(bytes, offset),
}
}

Expand Down
18 changes: 6 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,11 @@
integrity sha512-6PQTJv+uxAb8XE/oL2Uh4EmFJpn65YOTSqGn8HLNXrWRlW1Clp1Oze6biHeRCMonLwEx4oH4bPeyjdcMnNP8pw==

"@gmod/bgzf-filehandle@^2.0.1":
version "2.0.3"
resolved "https://registry.yarnpkg.com/@gmod/bgzf-filehandle/-/bgzf-filehandle-2.0.3.tgz#398e3ea61f332e1b0ec8ccd5aa22aed14770393f"
integrity sha512-vwQWopYxTTuVxJx8WvjNLQM30mkRdMpoPJzg+n4C0UdI7ZR8c0R5szzyUaZPFJnRbQDJhTC3HJE3EILXptJAYQ==
version "2.0.4"
resolved "https://registry.yarnpkg.com/@gmod/bgzf-filehandle/-/bgzf-filehandle-2.0.4.tgz#64f88ff6ad48efaf69641e796db87f24bf5da9ab"
integrity sha512-MV1V3X2uF0vqN93dkEhL8TUiJMTHyaJQFuLZttKAl8vH5utN2gKJf/3PTW8f7r5X+GgyftuTcfIpHHD5+3mJiQ==
dependencies:
generic-filehandle2 "^1.0.0"
longfn "^1.3.1"
pako "^1.0.11"

"@humanfs/core@^0.19.1":
Expand Down Expand Up @@ -1270,9 +1269,9 @@ globals@^14.0.0:
integrity sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==

globals@^15.9.0:
version "15.13.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-15.13.0.tgz#bbec719d69aafef188ecd67954aae76a696010fc"
integrity sha512-49TewVEz0UxZjr1WYYsWpPrhyC/B/pA8Bq0fUmet2n+eR7yn0IvNzNaoBwnK6mdkzcN+se7Ez9zUgULTz2QH4g==
version "15.14.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-15.14.0.tgz#b8fd3a8941ff3b4d38f3319d433b61bbb482e73f"
integrity sha512-OkToC372DtlQeje9/zHIo5CT8lRP/FUgEOKBEhU4e0abL7J7CD24fD9ohiLN5hagG/kWCYj4K5oaxxtj2Z0Dig==

graphemer@^1.4.0:
version "1.4.0"
Expand Down Expand Up @@ -1527,11 +1526,6 @@ lodash.merge@^4.6.2:
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==

longfn@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/longfn/-/longfn-1.3.1.tgz#1655fef1034bcb9f7b7911a4afb493d4acc8751d"
integrity sha512-sFNpfHBvO+mK6bSMr//CGeeXCJX4nKaBJ9M7QsJkzZT8ez+z12lkzRlyZibjdtjLHlfYPv9rmwHGGuwJOglFFQ==

loupe@^3.1.0, loupe@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/loupe/-/loupe-3.1.2.tgz#c86e0696804a02218f2206124c45d8b15291a240"
Expand Down

0 comments on commit dd8f0fd

Please sign in to comment.