@gmod/hic 1.2.1 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -14
- package/dist/bufferedFile.d.ts +2 -2
- package/dist/bufferedFile.js +5 -5
- package/dist/bufferedFile.js.map +1 -1
- package/dist/hicFile.d.ts +9 -10
- package/dist/hicFile.js +167 -174
- package/dist/hicFile.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/lru.js +0 -2
- package/dist/lru.js.map +1 -1
- package/dist/normalizationVector.d.ts +2 -2
- package/dist/normalizationVector.js +2 -2
- package/dist/normalizationVector.js.map +1 -1
- package/dist/reader.js +4 -2
- package/dist/reader.js.map +1 -1
- package/dist/types.d.ts +8 -2
- package/esm/bufferedFile.d.ts +2 -2
- package/esm/bufferedFile.js +5 -5
- package/esm/bufferedFile.js.map +1 -1
- package/esm/hicFile.d.ts +9 -10
- package/esm/hicFile.js +167 -174
- package/esm/hicFile.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/lru.js +0 -2
- package/esm/lru.js.map +1 -1
- package/esm/normalizationVector.d.ts +2 -2
- package/esm/normalizationVector.js +2 -2
- package/esm/normalizationVector.js.map +1 -1
- package/esm/reader.js +4 -2
- package/esm/reader.js.map +1 -1
- package/esm/types.d.ts +8 -2
- package/package.json +11 -8
- package/src/bufferedFile.ts +10 -6
- package/src/hicFile.ts +227 -188
- package/src/index.ts +1 -0
- package/src/lru.ts +0 -2
- package/src/normalizationVector.ts +3 -3
- package/src/reader.ts +5 -3
- package/src/types.ts +13 -2
package/src/index.ts
CHANGED
package/src/lru.ts
CHANGED
|
@@ -65,8 +65,6 @@ export default class LRU<K, V> {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
// Used to evict a rejected in-flight promise so the next caller retries
|
|
69
|
-
// rather than resolving against a cached failure forever.
|
|
70
68
|
delete(key: K) {
|
|
71
69
|
const existing = this.map.get(key)
|
|
72
70
|
if (existing !== undefined) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BinaryParser from './binary.ts'
|
|
2
2
|
|
|
3
|
-
import type { Reader } from './types.ts'
|
|
3
|
+
import type { BaseOpts, Reader } from './types.ts'
|
|
4
4
|
|
|
5
5
|
const DOUBLE = 8
|
|
6
6
|
|
|
@@ -25,7 +25,7 @@ export default class NormalizationVector {
|
|
|
25
25
|
this.dataType = dataType
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
async getValues(start: number, end: number) {
|
|
28
|
+
async getValues(start: number, end: number, opts?: BaseOpts) {
|
|
29
29
|
// The read below clamps to `nValues`, so the cache can never cover past it.
|
|
30
30
|
// Compare against the clamped bound or a request that runs off the end of
|
|
31
31
|
// the vector — reachable when the assembly's refseq is longer than the size
|
|
@@ -52,7 +52,7 @@ export default class NormalizationVector {
|
|
|
52
52
|
// region pair, on every fetch, for as long as the view stays there.
|
|
53
53
|
const data =
|
|
54
54
|
n > 0
|
|
55
|
-
? await this.file.read(startPosition, n * this.dataType)
|
|
55
|
+
? await this.file.read(startPosition, n * this.dataType, opts)
|
|
56
56
|
: new ArrayBuffer(0)
|
|
57
57
|
const parser = new BinaryParser(new DataView(data))
|
|
58
58
|
const values = new Float64Array(n)
|
package/src/reader.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { Reader } from './types.ts'
|
|
1
|
+
import type { BaseOpts, Reader } from './types.ts'
|
|
2
2
|
import type { GenericFilehandle } from 'generic-filehandle2'
|
|
3
3
|
|
|
4
4
|
export function readerFromFilehandle(filehandle: GenericFilehandle): Reader {
|
|
5
5
|
return {
|
|
6
|
-
async read(position: number, length: number) {
|
|
7
|
-
const buf = await filehandle.read(length, position
|
|
6
|
+
async read(position: number, length: number, opts?: BaseOpts) {
|
|
7
|
+
const buf = await filehandle.read(length, position, {
|
|
8
|
+
signal: opts?.signal,
|
|
9
|
+
})
|
|
8
10
|
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)
|
|
9
11
|
},
|
|
10
12
|
}
|
package/src/types.ts
CHANGED
|
@@ -4,9 +4,20 @@
|
|
|
4
4
|
* reads past the end to discover whether a file carries normalization data at
|
|
5
5
|
* all. `generic-filehandle2` handles behave this way (a remote 416 included),
|
|
6
6
|
* and `readerFromFilehandle` adapts one to this shape.
|
|
7
|
+
*
|
|
8
|
+
* A reader that ignores `opts.signal` still cancels, only later: the parser
|
|
9
|
+
* checks the signal when a fetch of blocks lands.
|
|
7
10
|
*/
|
|
8
11
|
export interface Reader {
|
|
9
|
-
read: (
|
|
12
|
+
read: (
|
|
13
|
+
position: number,
|
|
14
|
+
length: number,
|
|
15
|
+
opts?: BaseOpts,
|
|
16
|
+
) => Promise<ArrayBuffer>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface BaseOpts {
|
|
20
|
+
signal?: AbortSignal
|
|
10
21
|
}
|
|
11
22
|
|
|
12
23
|
/**
|
|
@@ -30,7 +41,7 @@ export type ProgressCallback = (current: number, total: number) => void
|
|
|
30
41
|
* belongs to the operation a caller is waiting on, and a file-wide callback
|
|
31
42
|
* could not say which of several concurrent fetches it was describing.
|
|
32
43
|
*/
|
|
33
|
-
export interface ProgressOpts {
|
|
44
|
+
export interface ProgressOpts extends BaseOpts {
|
|
34
45
|
onProgress?: ProgressCallback
|
|
35
46
|
}
|
|
36
47
|
|