igv 2.15.11 → 2.15.13

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/dist/igv.js CHANGED
@@ -19246,7 +19246,7 @@
19246
19246
  */
19247
19247
 
19248
19248
  function _random(min, max) {
19249
- return Math.random() * (max - min) + min;
19249
+ return Math.random() * (max - min) + min
19250
19250
  }
19251
19251
 
19252
19252
  const IGVColor = {
@@ -19266,7 +19266,7 @@
19266
19266
  accumulation.pop();
19267
19267
  accumulation.push(IGVColor.rgbColor(16, 16, 16));
19268
19268
 
19269
- return accumulation;
19269
+ return accumulation
19270
19270
  },
19271
19271
 
19272
19272
  rgbToHex: function (rgb) {
@@ -19274,7 +19274,7 @@
19274
19274
  return (rgb && rgb.length === 4) ? "#" +
19275
19275
  ("0" + parseInt(rgb[1], 10).toString(16)).slice(-2) +
19276
19276
  ("0" + parseInt(rgb[2], 10).toString(16)).slice(-2) +
19277
- ("0" + parseInt(rgb[3], 10).toString(16)).slice(-2) : '';
19277
+ ("0" + parseInt(rgb[3], 10).toString(16)).slice(-2) : ''
19278
19278
  },
19279
19279
 
19280
19280
  hexToRgb: function (hex) {
@@ -19282,10 +19282,10 @@
19282
19282
  var cooked = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
19283
19283
 
19284
19284
  if (null === cooked) {
19285
- return undefined;
19285
+ return undefined
19286
19286
  }
19287
19287
 
19288
- return "rgb(" + parseInt(cooked[1], 16) + "," + parseInt(cooked[2], 16) + "," + parseInt(cooked[3], 16) + ")";
19288
+ return "rgb(" + parseInt(cooked[1], 16) + "," + parseInt(cooked[2], 16) + "," + parseInt(cooked[3], 16) + ")"
19289
19289
  },
19290
19290
 
19291
19291
  /**
@@ -19313,25 +19313,25 @@
19313
19313
  switch (i % 6) {
19314
19314
  case 0:
19315
19315
  r = v, g = t, b = p;
19316
- break;
19316
+ break
19317
19317
  case 1:
19318
19318
  r = q, g = v, b = p;
19319
- break;
19319
+ break
19320
19320
  case 2:
19321
19321
  r = p, g = v, b = t;
19322
- break;
19322
+ break
19323
19323
  case 3:
19324
19324
  r = p, g = q, b = v;
19325
- break;
19325
+ break
19326
19326
  case 4:
19327
19327
  r = t, g = p, b = v;
19328
- break;
19328
+ break
19329
19329
  case 5:
19330
19330
  r = v, g = p, b = q;
19331
- break;
19331
+ break
19332
19332
  }
19333
19333
 
19334
- return [Math.floor(r * 255), Math.floor(g * 255), Math.floor(b * 255)];
19334
+ return [Math.floor(r * 255), Math.floor(g * 255), Math.floor(b * 255)]
19335
19335
  },
19336
19336
 
19337
19337
  /**
@@ -19363,16 +19363,16 @@
19363
19363
  b = IGVColor.hue2rgb(p, q, h - 1 / 3);
19364
19364
  }
19365
19365
 
19366
- return [r * 255, g * 255, b * 255];
19366
+ return [r * 255, g * 255, b * 255]
19367
19367
  },
19368
19368
 
19369
19369
  hue2rgb: (p, q, t) => {
19370
19370
  if (t < 0) t += 1;
19371
19371
  if (t > 1) t -= 1;
19372
- if (t < 1 / 6) return p + (q - p) * 6 * t;
19373
- if (t < 1 / 2) return q;
19374
- if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
19375
- return p;
19372
+ if (t < 1 / 6) return p + (q - p) * 6 * t
19373
+ if (t < 1 / 2) return q
19374
+ if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6
19375
+ return p
19376
19376
  },
19377
19377
 
19378
19378
  rgbaColor: function (r, g, b, a) {
@@ -19382,7 +19382,7 @@
19382
19382
  b = IGVMath.clamp(b, 0, 255);
19383
19383
  a = IGVMath.clamp(a, 0.0, 1.0);
19384
19384
 
19385
- return "rgba(" + r + "," + g + "," + b + "," + a + ")";
19385
+ return "rgba(" + r + "," + g + "," + b + "," + a + ")"
19386
19386
  },
19387
19387
 
19388
19388
  rgbColor: function (r, g, b) {
@@ -19391,14 +19391,14 @@
19391
19391
  g = IGVMath.clamp(g, 0, 255);
19392
19392
  b = IGVMath.clamp(b, 0, 255);
19393
19393
 
19394
- return "rgb(" + r + "," + g + "," + b + ")";
19394
+ return "rgb(" + r + "," + g + "," + b + ")"
19395
19395
  },
19396
19396
 
19397
19397
  greyScale: function (value) {
19398
19398
 
19399
19399
  var grey = IGVMath.clamp(value, 0, 255);
19400
19400
 
19401
- return "rgb(" + grey + "," + grey + "," + grey + ")";
19401
+ return "rgb(" + grey + "," + grey + "," + grey + ")"
19402
19402
  },
19403
19403
 
19404
19404
  randomGrey: function (min, max) {
@@ -19408,7 +19408,7 @@
19408
19408
 
19409
19409
  var g = Math.round(_random(min, max)).toString(10);
19410
19410
 
19411
- return "rgb(" + g + "," + g + "," + g + ")";
19411
+ return "rgb(" + g + "," + g + "," + g + ")"
19412
19412
  },
19413
19413
 
19414
19414
  randomRGB: function (min, max) {
@@ -19420,7 +19420,7 @@
19420
19420
  var g = Math.round(_random(min, max)).toString(10);
19421
19421
  var b = Math.round(_random(min, max)).toString(10);
19422
19422
 
19423
- return "rgb(" + r + "," + g + "," + b + ")";
19423
+ return "rgb(" + r + "," + g + "," + b + ")"
19424
19424
  },
19425
19425
 
19426
19426
  randomRGBConstantAlpha: function (min, max, alpha) {
@@ -19432,12 +19432,12 @@
19432
19432
  var g = Math.round(_random(min, max)).toString(10);
19433
19433
  var b = Math.round(_random(min, max)).toString(10);
19434
19434
 
19435
- return "rgba(" + r + "," + g + "," + b + "," + alpha + ")";
19435
+ return "rgba(" + r + "," + g + "," + b + "," + alpha + ")"
19436
19436
  },
19437
19437
 
19438
19438
  addAlpha: function (color, alpha) {
19439
19439
 
19440
- if(color === "0" || color === ".") {
19440
+ if (color === "0" || color === ".") {
19441
19441
  color = "rgb(0,0,0)";
19442
19442
  } else {
19443
19443
  const c = this.colorNameToHex(color);
@@ -19450,7 +19450,7 @@
19450
19450
 
19451
19451
  if (color.startsWith("rgba")) {
19452
19452
  const idx = color.lastIndexOf(",");
19453
- return color.substring(0, idx+1) + alpha.toString() + ")";
19453
+ return color.substring(0, idx + 1) + alpha.toString() + ")"
19454
19454
  }
19455
19455
 
19456
19456
  if (isHex) {
@@ -19458,38 +19458,37 @@
19458
19458
  }
19459
19459
 
19460
19460
  if (color.startsWith("rgb")) {
19461
- return color.replace("rgb", "rgba").replace(")", ", " + alpha + ")");
19461
+ return color.replace("rgb", "rgba").replace(")", ", " + alpha + ")")
19462
19462
  } else {
19463
19463
  console.log(color + " is not an rgb style string");
19464
- return color;
19464
+ return color
19465
19465
  }
19466
19466
  },
19467
19467
 
19468
19468
  rgbComponents: function (color) {
19469
19469
 
19470
- if(color === "0" || color === ".") {
19471
- return [0,0,0];
19470
+ if (color === "0" || color === ".") {
19471
+ return [0, 0, 0]
19472
19472
  }
19473
19473
  const isHex = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(color);
19474
19474
  if (isHex) {
19475
19475
  color = IGVColor.hexToRgb(color);
19476
19476
  } else {
19477
- if(!color.startsWith("rgb")) {
19477
+ if (!color.startsWith("rgb")) {
19478
19478
  const hex = this.colorNameToHex(color);
19479
19479
  color = this.hexToRgb(hex);
19480
19480
  }
19481
19481
  }
19482
19482
 
19483
19483
  if (color.startsWith("rgb(")) {
19484
- return color.substring(4, color.length-1).split(",").map(s => Number.parseInt(s.trim()));
19485
- } else if (color.startsWith("rgba(")) {
19486
- return color.substring(5, color.length-1).split(",").map((s, i) => {
19484
+ return color.substring(4, color.length - 1).split(",").map(s => Number.parseInt(s.trim()))
19485
+ } else if (color.startsWith("rgba(")) {
19486
+ return color.substring(5, color.length - 1).split(",").map((s, i) => {
19487
19487
  s = s.trim();
19488
19488
  return i === 3 ? Number.parseFloat(s) : Number.parseInt(s)
19489
- });
19490
- }
19491
- else {
19492
- throw Error("Unrecognized color string: color");
19489
+ })
19490
+ } else {
19491
+ throw Error("Unrecognized color string: color")
19493
19492
  }
19494
19493
  },
19495
19494
 
@@ -19506,19 +19505,46 @@
19506
19505
  g = Math.floor(alpha * src[1] + (1 - alpha) * dest[1]),
19507
19506
  b = Math.floor(alpha * src[2] + (1 - alpha) * dest[2]);
19508
19507
 
19509
- return "rgb(" + r + "," + g + "," + b + ")";
19508
+ return "rgb(" + r + "," + g + "," + b + ")"
19510
19509
 
19511
19510
  },
19512
19511
 
19513
-
19512
+ /**
19513
+ * Return a color represented by the string. If the string is not a recognized color format return the
19514
+ * string itself. This function exists for backward compatibility, createColorStringSafe is preferredz
19515
+ * @param str
19516
+ */
19514
19517
  createColorString: function (str) {
19518
+ // Excel will quote color strings, strip all quotes
19519
+ const color = this.createColorStringSafe(str);
19520
+ return color ? color : str
19521
+ },
19522
+
19523
+ /**
19524
+ * If str is a recognized color format return a string encoding the color
19525
+ * @param str
19526
+ */
19527
+ createColorStringSafe: function (str) {
19515
19528
  // Excel will quote color strings, strip all quotes
19516
19529
  str = stripQuotes$1(str);
19517
19530
 
19518
- if (str.includes(",")) {
19519
- return str.startsWith("rgb") ? str : "rgb(" + str + ")";
19520
- } else {
19521
- return str;
19531
+ if (str.startsWith('rgb(') && str.endsWith(')')) {
19532
+ return str
19533
+ }
19534
+ if (str.startsWith('#') && str.length < 8) {
19535
+ return str
19536
+ }
19537
+
19538
+ // See if string is a recognized web color
19539
+ const hex = this.colorNameToHex(str);
19540
+ if (hex) {
19541
+ return hex
19542
+ }
19543
+
19544
+ // UCSC format (e.g. 0,0,255)
19545
+ const tokens = str.split(",");
19546
+ if (tokens.length === 3 && isColorComponent(tokens[0]) && isColorComponent(tokens[1]) && isColorComponent(tokens[2])) {
19547
+ return `rgb(${str})`
19522
19548
  }
19523
19549
  },
19524
19550
 
@@ -19526,8 +19552,8 @@
19526
19552
 
19527
19553
  let src;
19528
19554
  let hexColor = this.colorNameToHex(color);
19529
- if(hexColor) {
19530
- src = IGVColor.hexToRgb(hexColor);
19555
+ if (hexColor) {
19556
+ src = IGVColor.hexToRgb(hexColor);
19531
19557
  } else {
19532
19558
  src = color.startsWith('rgb(') ? color : IGVColor.hexToRgb(color);
19533
19559
  }
@@ -19538,7 +19564,7 @@
19538
19564
  const g = Math.max(0, Math.min(255, Number.parseInt(components[1].trim()) + amt));
19539
19565
  const b = Math.max(0, Math.min(255, Number.parseInt(components[2].trim()) + amt));
19540
19566
 
19541
- return 'rgb(' + r.toString() + ',' + g.toString() + ',' + b.toString() + ')';
19567
+ return 'rgb(' + r.toString() + ',' + g.toString() + ',' + b.toString() + ')'
19542
19568
 
19543
19569
  },
19544
19570
 
@@ -19697,10 +19723,15 @@
19697
19723
  "lightslategrey": "#778899",
19698
19724
  "slategrey": "#708090"
19699
19725
  };
19700
- return definedColorNames[colorName];
19726
+ return definedColorNames[colorName]
19701
19727
  }
19702
19728
  };
19703
19729
 
19730
+ function isColorComponent(str) {
19731
+ const num = Number.parseInt(str);
19732
+ return !Number.isNaN(num) && num >= 0 && num <= 255
19733
+ }
19734
+
19704
19735
  // Support for oauth token based authorization
19705
19736
  // This class supports explicit setting of an oauth token either globally or for specific hosts.
19706
19737
  //
@@ -19927,7 +19958,7 @@
19927
19958
 
19928
19959
  // Note: callback is added when accessToken is requested
19929
19960
  const codeClientConfig = {
19930
- client_id: config.client_id,
19961
+ client_id: config.client_id || config.clientId,
19931
19962
  scope: config.scope || 'https://www.googleapis.com/auth/userinfo.profile',
19932
19963
  state: config.state || 'igv',
19933
19964
  error: (err) => {
@@ -20007,7 +20038,7 @@
20007
20038
 
20008
20039
  function getScopeForURL(url) {
20009
20040
  if (isGoogleDriveURL(url)) {
20010
- return "https://www.googleapis.com/auth/drive.readonly"
20041
+ return "https://www.googleapis.com/auth/drive.file"
20011
20042
  } else if (isGoogleStorageURL(url)) {
20012
20043
  return "https://www.googleapis.com/auth/devstorage.read_only"
20013
20044
  } else {
@@ -20243,6 +20274,24 @@
20243
20274
  }
20244
20275
  }
20245
20276
 
20277
+ /**
20278
+ * A wrapper around loadArrayBuffer that inflates gzipped data
20279
+ * @param url
20280
+ * @param options
20281
+ * @returns {Promise<Uint8Array>}
20282
+ */
20283
+ async loadByteArray(url, options) {
20284
+ const arraybuffer = await this.loadArrayBuffer(url, options);
20285
+ let plain;
20286
+ if (isgzipped(arraybuffer)) {
20287
+ plain = ungzip_blocks(arraybuffer);
20288
+ } else {
20289
+ plain = new Uint8Array(arraybuffer);
20290
+ }
20291
+ return plain
20292
+ }
20293
+
20294
+
20246
20295
  async loadJson(url, options) {
20247
20296
  options = options || {};
20248
20297
  const method = options.method || (options.sendData ? "POST" : "GET");
@@ -20413,7 +20462,7 @@
20413
20462
  }
20414
20463
  } else if (xhr.status === 416) {
20415
20464
  handleError(Error(`416 Unsatisfiable Range`));
20416
- } else if ((typeof gapi !== "undefined") &&
20465
+ } else if (isInitialized() &&
20417
20466
  ((xhr.status === 404 || xhr.status === 401 || xhr.status === 403) &&
20418
20467
  isGoogleURL(url)) &&
20419
20468
  !options.retries) {
@@ -25622,7 +25671,7 @@
25622
25671
  }
25623
25672
  };
25624
25673
 
25625
- const _version = "2.15.11";
25674
+ const _version = "2.15.13";
25626
25675
  function version() {
25627
25676
  return _version
25628
25677
  }
@@ -41916,11 +41965,7 @@
41916
41965
  if (name === undefined) name = feature.id || feature.ID;
41917
41966
  if (!name || name === '.') return
41918
41967
 
41919
-
41920
- let pixelXOffset = options.pixelXOffset || 0;
41921
- const t1 = Math.max(featureX, -pixelXOffset);
41922
- const t2 = Math.min(featureX1, -pixelXOffset + options.viewportWidth);
41923
- let centerX = (t1 + t2) / 2;
41968
+ let centerX = (featureX + featureX1) / 2;
41924
41969
 
41925
41970
  let transform;
41926
41971
  if (this.displayMode === "COLLAPSED" && this.labelDisplayMode === "SLANT") {
@@ -51296,6 +51341,13 @@
51296
51341
  }
51297
51342
  }
51298
51343
 
51344
+ var __defProp = Object.defineProperty;
51345
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
51346
+ var __publicField = (obj, key, value) => {
51347
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
51348
+ return value;
51349
+ };
51350
+
51299
51351
  // esm/core.js
51300
51352
  async function _unpack_struct_from_async(structure, async_buf, offset = 0) {
51301
51353
  var output = /* @__PURE__ */ new Map();
@@ -51412,7 +51464,7 @@
51412
51464
  return big_endian;
51413
51465
  }
51414
51466
  async unpack_from_async(fmt, async_buf, offset) {
51415
- var offset = Number(offset || 0);
51467
+ offset = Number.parseInt(offset || 0);
51416
51468
  const total_size = this.calcsize(fmt);
51417
51469
  const local_buffer = await async_buf.slice(offset, offset + total_size);
51418
51470
  let local_offset = 0;
@@ -51439,7 +51491,7 @@
51439
51491
  return output;
51440
51492
  }
51441
51493
  unpack_from(fmt, buffer, offset) {
51442
- var offset = Number(offset || 0);
51494
+ offset = Number.parseInt(offset || 0);
51443
51495
  const total_size = this.calcsize(fmt);
51444
51496
  const local_buffer = buffer.slice(offset, offset + total_size);
51445
51497
  let local_offset = 0;
@@ -51477,7 +51529,7 @@
51477
51529
  const left = BigInt(this.getUint32(byteOffset, littleEndian));
51478
51530
  const right = BigInt(this.getUint32(byteOffset + 4, littleEndian));
51479
51531
  let combined = littleEndian ? left + (right << 32n) : (left << 32n) + right;
51480
- return Number(combined);
51532
+ return Number.parseInt(combined);
51481
51533
  }
51482
51534
  getInt64(byteOffset, littleEndian) {
51483
51535
  var low, high;
@@ -51489,7 +51541,7 @@
51489
51541
  low = this.getUint32(byteOffset + 4, false);
51490
51542
  }
51491
51543
  let combined = BigInt(low) + (BigInt(high) << 32n);
51492
- return Number(combined);
51544
+ return Number.parseInt(combined);
51493
51545
  }
51494
51546
  getString(byteOffset, littleEndian, length) {
51495
51547
  const str_buffer = this.buffer.slice(byteOffset, byteOffset + length);
@@ -53942,14 +53994,17 @@
53942
53994
  }
53943
53995
  };
53944
53996
  var BTreeV1 = class extends AbstractBTree {
53945
- B_LINK_NODE = /* @__PURE__ */ new Map([
53946
- ["signature", "4s"],
53947
- ["node_type", "B"],
53948
- ["node_level", "B"],
53949
- ["entries_used", "H"],
53950
- ["left_sibling", "Q"],
53951
- ["right_sibling", "Q"]
53952
- ]);
53997
+ constructor() {
53998
+ super(...arguments);
53999
+ __publicField(this, "B_LINK_NODE", /* @__PURE__ */ new Map([
54000
+ ["signature", "4s"],
54001
+ ["node_type", "B"],
54002
+ ["node_level", "B"],
54003
+ ["entries_used", "H"],
54004
+ ["left_sibling", "Q"],
54005
+ ["right_sibling", "Q"]
54006
+ ]));
54007
+ }
53953
54008
  async _read_node_header(offset, node_level) {
53954
54009
  let node = await _unpack_struct_from_async(this.B_LINK_NODE, this.fh, offset);
53955
54010
  if (node_level != null) {
@@ -53961,9 +54016,9 @@
53961
54016
  }
53962
54017
  };
53963
54018
  var BTreeV1Groups = class extends BTreeV1 {
53964
- NODE_TYPE = 0;
53965
54019
  constructor(fh, offset) {
53966
54020
  super(fh, offset);
54021
+ __publicField(this, "NODE_TYPE", 0);
53967
54022
  this.ready = this.init();
53968
54023
  }
53969
54024
  async _read_node(offset, node_level) {
@@ -53995,9 +54050,9 @@
53995
54050
  }
53996
54051
  };
53997
54052
  var BTreeV1RawDataChunks = class extends BTreeV1 {
53998
- NODE_TYPE = 1;
53999
54053
  constructor(fh, offset, dims) {
54000
54054
  super(fh, offset);
54055
+ __publicField(this, "NODE_TYPE", 1);
54001
54056
  this.dims = dims;
54002
54057
  this.ready = this.init();
54003
54058
  }
@@ -54036,7 +54091,7 @@
54036
54091
  if (size != 8) {
54037
54092
  throw "NotImplementedError('Unsupported Reference type')";
54038
54093
  }
54039
- var dtype = "<u8";
54094
+ dtype = "<u8";
54040
54095
  item_getter = "getUint64";
54041
54096
  item_big_endian = false;
54042
54097
  item_size = 8;
@@ -54143,26 +54198,26 @@
54143
54198
  }
54144
54199
  };
54145
54200
  var BTreeV2 = class extends AbstractBTree {
54146
- B_TREE_HEADER = /* @__PURE__ */ new Map([
54147
- ["signature", "4s"],
54148
- ["version", "B"],
54149
- ["node_type", "B"],
54150
- ["node_size", "I"],
54151
- ["record_size", "H"],
54152
- ["depth", "H"],
54153
- ["split_percent", "B"],
54154
- ["merge_percent", "B"],
54155
- ["root_address", "Q"],
54156
- ["root_nrecords", "H"],
54157
- ["total_nrecords", "Q"]
54158
- ]);
54159
- B_LINK_NODE = /* @__PURE__ */ new Map([
54160
- ["signature", "4s"],
54161
- ["version", "B"],
54162
- ["node_type", "B"]
54163
- ]);
54164
54201
  constructor(fh, offset) {
54165
54202
  super(fh, offset);
54203
+ __publicField(this, "B_TREE_HEADER", /* @__PURE__ */ new Map([
54204
+ ["signature", "4s"],
54205
+ ["version", "B"],
54206
+ ["node_type", "B"],
54207
+ ["node_size", "I"],
54208
+ ["record_size", "H"],
54209
+ ["depth", "H"],
54210
+ ["split_percent", "B"],
54211
+ ["merge_percent", "B"],
54212
+ ["root_address", "Q"],
54213
+ ["root_nrecords", "H"],
54214
+ ["total_nrecords", "Q"]
54215
+ ]));
54216
+ __publicField(this, "B_LINK_NODE", /* @__PURE__ */ new Map([
54217
+ ["signature", "4s"],
54218
+ ["version", "B"],
54219
+ ["node_type", "B"]
54220
+ ]));
54166
54221
  this.ready = this.init();
54167
54222
  }
54168
54223
  async _read_root_node() {
@@ -54288,7 +54343,10 @@
54288
54343
  }
54289
54344
  };
54290
54345
  var BTreeV2GroupNames = class extends BTreeV2 {
54291
- NODE_TYPE = 5;
54346
+ constructor() {
54347
+ super(...arguments);
54348
+ __publicField(this, "NODE_TYPE", 5);
54349
+ }
54292
54350
  async _parse_record(buf, offset, size) {
54293
54351
  let namehash = (await struct.unpack_from_async("<I", buf, offset))[0];
54294
54352
  offset += 4;
@@ -54297,7 +54355,10 @@
54297
54355
  }
54298
54356
  };
54299
54357
  var BTreeV2GroupOrders = class extends BTreeV2 {
54300
- NODE_TYPE = 6;
54358
+ constructor() {
54359
+ super(...arguments);
54360
+ __publicField(this, "NODE_TYPE", 6);
54361
+ }
54301
54362
  async _parse_record(buf, offset, size) {
54302
54363
  let creationorder = (await struct.unpack_from_async("<Q", buf, offset))[0];
54303
54364
  offset += 8;
@@ -55731,8 +55792,11 @@
55731
55792
  }
55732
55793
  async getValue(data) {
55733
55794
  const dtype = await this.dtype;
55734
- if (dtype.startsWith("S")) {
55735
- return (await data).map((s) => s.substr(0, s.indexOf("\0")));
55795
+ if ((typeof dtype === "string" || dtype instanceof String) && dtype.startsWith("S")) {
55796
+ return (await data).map((s) => {
55797
+ let idx = s.indexOf("\0");
55798
+ return idx >= 0 ? s.substring(0, idx) : s;
55799
+ });
55736
55800
  } else {
55737
55801
  return data;
55738
55802
  }