@gmod/tabix 3.5.7 → 3.6.0

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 CHANGED
@@ -102,18 +102,19 @@ opening the file directly.
102
102
 
103
103
  ### `new TabixIndexedFile(args)`
104
104
 
105
- | Arg | Type | Description |
106
- | ---------------- | -------------------- | ------------------------------------------------------------------------------------------- |
107
- | `path` | `string?` | Local file path |
108
- | `url` | `string?` | Remote URL |
109
- | `filehandle` | `GenericFilehandle?` | Custom filehandle (from [generic-filehandle2](https://github.com/GMOD/generic-filehandle2)) |
110
- | `tbiPath` | `string?` | TBI index path (defaults to `path + '.tbi'`) |
111
- | `tbiUrl` | `string?` | TBI index URL |
112
- | `tbiFilehandle` | `GenericFilehandle?` | TBI index filehandle |
113
- | `csiPath` | `string?` | CSI index path |
114
- | `csiUrl` | `string?` | CSI index URL |
115
- | `csiFilehandle` | `GenericFilehandle?` | CSI index filehandle |
116
- | `chunkCacheSize` | `number?` | Chunk LRU cache budget, in _decompressed_ bytes (default 100 MiB) |
105
+ | Arg | Type | Description |
106
+ | ------------------------- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
107
+ | `path` | `string?` | Local file path |
108
+ | `url` | `string?` | Remote URL |
109
+ | `filehandle` | `GenericFilehandle?` | Custom filehandle (from [generic-filehandle2](https://github.com/GMOD/generic-filehandle2)) |
110
+ | `tbiPath` | `string?` | TBI index path (defaults to `path + '.tbi'`) |
111
+ | `tbiUrl` | `string?` | TBI index URL |
112
+ | `tbiFilehandle` | `GenericFilehandle?` | TBI index filehandle |
113
+ | `csiPath` | `string?` | CSI index path |
114
+ | `csiUrl` | `string?` | CSI index URL |
115
+ | `csiFilehandle` | `GenericFilehandle?` | CSI index filehandle |
116
+ | `chunkCacheSize` | `number?` | Chunk LRU cache budget, in _decompressed_ bytes (default 1 GiB). A retention bound, not a bound on peak memory. Size it to hold several queries: below one query's working set the hit rate drops to zero while the memory is retained anyway |
117
+ | `chunkCacheIdleTimeoutMs` | `number?` | Drop a cached chunk once nothing has read it for this long (default 3 minutes, `0` disables). The only thing that lowers the cache while nothing is happening, and what makes the budget above a peak rather than a resting level |
117
118
 
118
119
  ### `getLines(refName, start, end, opts)`
119
120
 
@@ -136,11 +136,11 @@ export default abstract class IndexFile {
136
136
  * duplicate parse rather than a recursion whose depth depends on how the
137
137
  * aborts interleave.
138
138
  *
139
- * A retry rather than the reference count `chunkCache` gets from
140
- * `@gmod/abortable-promise-cache`, because the index is parsed once for the
141
- * life of the object: there is no repeated waste to recover, and this is a
142
- * dozen lines against restructuring the memo. `@gmod/bam`'s `IndexFile` and
143
- * `@gmod/cram`'s `CraiIndex` make the same split for the same reason.
139
+ * A retry rather than the reference count `ChunkCache` uses, because the
140
+ * index is parsed once for the life of the object: there is no repeated waste
141
+ * to recover, and this is a dozen lines against restructuring the memo.
142
+ * `@gmod/bam`'s `IndexFile` and `@gmod/cram`'s `CraiIndex` make the same
143
+ * split for the same reason.
144
144
  *
145
145
  * @internal
146
146
  */
package/dist/indexFile.js CHANGED
@@ -75,6 +75,8 @@ class IndexFile {
75
75
  }
76
76
  return (0, util_ts_1.optimizeChunks)(chunks, this.lowestOffset(ba, min, indexData));
77
77
  }
78
+ // SYNC: ~/src/gmod/bam-js/src/indexFile.ts parse — same owner-signal
79
+ // tracking and one-attempt retry, and the same reasoning below.
78
80
  /**
79
81
  * Parse the index, or join the parse already running.
80
82
  *
@@ -93,11 +95,11 @@ class IndexFile {
93
95
  * duplicate parse rather than a recursion whose depth depends on how the
94
96
  * aborts interleave.
95
97
  *
96
- * A retry rather than the reference count `chunkCache` gets from
97
- * `@gmod/abortable-promise-cache`, because the index is parsed once for the
98
- * life of the object: there is no repeated waste to recover, and this is a
99
- * dozen lines against restructuring the memo. `@gmod/bam`'s `IndexFile` and
100
- * `@gmod/cram`'s `CraiIndex` make the same split for the same reason.
98
+ * A retry rather than the reference count `ChunkCache` uses, because the
99
+ * index is parsed once for the life of the object: there is no repeated waste
100
+ * to recover, and this is a dozen lines against restructuring the memo.
101
+ * `@gmod/bam`'s `IndexFile` and `@gmod/cram`'s `CraiIndex` make the same
102
+ * split for the same reason.
101
103
  *
102
104
  * @internal
103
105
  */
@@ -124,28 +126,19 @@ class IndexFile {
124
126
  this.parseP = pending;
125
127
  this.parseSignal = opts.signal;
126
128
  // Drop a rejection rather than keeping it, so one transient failure does not
127
- // poison the index for the lifetime of the file. Identity-checked so a retry
128
- // started after this settles is not cleared by the attempt it replaced.
129
- //
130
- // Written as one try/catch rather than `.then(onFulfilled, onRejected)`
131
- // because `unicorn/prefer-then-catch` rewrites the two-argument form to
132
- // `.then(...).catch(...)`, which is not the same thing — that catch would
133
- // also swallow anything the fulfilment handler threw.
134
- void (async () => {
135
- let failed = false;
136
- try {
137
- await pending;
138
- }
139
- catch {
140
- failed = true;
129
+ // poison the index for the lifetime of the file. Both branches are
130
+ // identity-checked so a retry started after this settles is not cleared by
131
+ // the attempt it already replaced.
132
+ pending.then(() => {
133
+ if (this.parseP === pending) {
134
+ this.parseSignal = undefined;
141
135
  }
136
+ }, () => {
142
137
  if (this.parseP === pending) {
143
- if (failed) {
144
- this.parseP = undefined;
145
- }
138
+ this.parseP = undefined;
146
139
  this.parseSignal = undefined;
147
140
  }
148
- })();
141
+ });
149
142
  return pending;
150
143
  }
151
144
  /** @internal */
@@ -1 +1 @@
1
- {"version":3,"file":"indexFile.js","sourceRoot":"","sources":["../src/indexFile.ts"],"names":[],"mappings":";;AAAA,2DAA6C;AAE7C,uCAA0D;AAiD1D,MAA8B,SAAS;IAC9B,UAAU,CAAmB;IAC5B,MAAM,CAAqB;IACnC;;;;;OAKG;IACK,WAAW,CAAc;IAEjC,YAAY,EAAE,UAAU,EAAqC;QAC3D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAyBD;;;OAGG;IACO,KAAK,CAAC,cAAc,CAAC,IAAa;QAC1C,MAAM,GAAG,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