@gmod/bam 2.0.0 → 2.0.2

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/htsget.ts CHANGED
@@ -18,7 +18,7 @@ async function concat(arr: HtsgetChunk[], opts?: Record<string, any>) {
18
18
  } else {
19
19
  //remove referer header, it is not even allowed to be specified
20
20
  // @ts-expect-error
21
- //eslint-disable-next-line @typescript-eslint/no-unused-vars
21
+
22
22
  const { referer, ...rest } = headers
23
23
  const res = await fetch(url, {
24
24
  ...opts,
package/src/record.ts CHANGED
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-empty-function */
2
1
  import Constants from './constants'
3
2
 
4
3
  const SEQRET_DECODER = '=ACMGRSVTWYHKDBN'.split('')
@@ -8,7 +7,7 @@ const CIGAR_DECODER = 'MIDNSHP=X???????'.split('')
8
7
  * Class of each BAM record returned by this API.
9
8
  */
10
9
  export default class BamRecord {
11
- private data = {} as { [key: string]: any }
10
+ private data = {} as Record<string, any>
12
11
  private bytes: { start: number; end: number; byteArray: Buffer }
13
12
  private _id: number
14
13
  private _tagOffset: number | undefined
@@ -84,12 +83,12 @@ export default class BamRecord {
84
83
  tags = tags.concat(this._tagList || [])
85
84
 
86
85
  for (const k of Object.keys(this.data)) {
87
- if (k[0] !== '_' && k !== 'next_seq_id') {
86
+ if (!k.startsWith('_') && k !== 'next_seq_id') {
88
87
  tags.push(k)
89
88
  }
90
89
  }
91
90
 
92
- const seen: { [key: string]: boolean } = {}
91
+ const seen: Record<string, boolean> = {}
93
92
  return tags.filter(t => {
94
93
  if (
95
94
  (t in this.data && this.data[t] === undefined) ||
@@ -494,8 +493,6 @@ export default class BamRecord {
494
493
  }
495
494
  }
496
495
 
497
- _flags() {}
498
-
499
496
  length_on_ref() {
500
497
  if (this.data.length_on_ref) {
501
498
  return this.data.length_on_ref
@@ -606,9 +603,9 @@ export default class BamRecord {
606
603
  }
607
604
 
608
605
  toJSON() {
609
- const data: { [key: string]: any } = {}
606
+ const data: Record<string, any> = {}
610
607
  for (const k of Object.keys(this)) {
611
- if (k.charAt(0) === '_' || k === 'bytes') {
608
+ if (k.startsWith('_') || k === 'bytes') {
612
609
  continue
613
610
  }
614
611
  //@ts-ignore
package/src/sam.ts CHANGED
@@ -7,7 +7,9 @@ export function parseHeaderText(text: string) {
7
7
  data.push({
8
8
  tag: tag.slice(1),
9
9
  data: fields.map(f => {
10
- const [fieldTag, value] = f.split(':', 2)
10
+ const r = f.indexOf(':')
11
+ const fieldTag = f.slice(0, r)
12
+ const value = f.slice(r + 1)
11
13
  return { tag: fieldTag, value }
12
14
  }),
13
15
  })
package/src/util.ts CHANGED
@@ -75,7 +75,7 @@ export interface BaseOpts {
75
75
  }
76
76
 
77
77
  export function makeOpts(obj: AbortSignal | BaseOpts = {}): BaseOpts {
78
- return 'aborted' in obj ? ({ signal: obj } as BaseOpts) : (obj as BaseOpts)
78
+ return 'aborted' in obj ? ({ signal: obj } as BaseOpts) : obj
79
79
  }
80
80
 
81
81
  export function optimizeChunks(chunks: Chunk[], lowest?: VirtualOffset) {
@@ -140,7 +140,7 @@ export function parseNameBytes(
140
140
  let currRefId = 0
141
141
  let currNameStart = 0
142
142
  const refIdToName = []
143
- const refNameToId: { [key: string]: number } = {}
143
+ const refNameToId: Record<string, number> = {}
144
144
  for (let i = 0; i < namesBytes.length; i += 1) {
145
145
  if (!namesBytes[i]) {
146
146
  if (currNameStart < i) {