@gmod/bbi 2.0.4 → 3.0.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/src/bbi.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Parser } from 'binary-parser'
2
2
  import { LocalFile, RemoteFile, GenericFilehandle } from 'generic-filehandle'
3
- import { Observable, Observer } from 'rxjs'
4
- import { reduce } from 'rxjs/operators'
3
+ import { firstValueFrom, Observable, Observer } from 'rxjs'
4
+ import { toArray } from 'rxjs/operators'
5
5
  import { BlockView } from './blockView'
6
6
 
7
7
  const BIG_WIG_MAGIC = -2003829722
@@ -367,12 +367,10 @@ export abstract class BBI {
367
367
  opts: RequestOptions & { scale?: number; basesPerSpan?: number } = {
368
368
  scale: 1,
369
369
  },
370
- ): Promise<Feature[]> {
370
+ ) {
371
371
  const ob = await this.getFeatureStream(refName, start, end, opts)
372
372
 
373
- const ret = await ob
374
- .pipe(reduce((acc, curr) => acc.concat(curr)))
375
- .toPromise()
376
- return ret || []
373
+ const ret = await firstValueFrom(ob.pipe(toArray()))
374
+ return ret.flat()
377
375
  }
378
376
  }
package/src/bigbed.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Parser } from 'binary-parser'
2
- import { Observable, merge } from 'rxjs'
2
+ import { Observable, merge, firstValueFrom } from 'rxjs'
3
3
  import { map, reduce } from 'rxjs/operators'
4
4
  import AbortablePromiseCache from 'abortable-promise-cache'
5
5
  import QuickLRU from 'quick-lru'
@@ -216,10 +216,7 @@ export class BigBed extends BBI {
216
216
  * @param opts - a SearchOptions argument with optional signal
217
217
  * @return a Promise for an array of Feature
218
218
  */
219
- public async searchExtraIndex(
220
- name: string,
221
- opts: RequestOptions = {},
222
- ): Promise<Feature[]> {
219
+ public async searchExtraIndex(name: string, opts: RequestOptions = {}) {
223
220
  const blocks = await this.searchExtraIndexBlocks(name, opts)
224
221
  if (!blocks.length) {
225
222
  return []
@@ -238,7 +235,7 @@ export class BigBed extends BBI {
238
235
  }),
239
236
  )
240
237
  })
241
- const ret = await merge(...res).toPromise()
238
+ const ret = await firstValueFrom(merge(...res))
242
239
  return ret.filter(f => f.rest?.split('\t')[(f.field || 0) - 3] === name)
243
240
  }
244
241
  }