@exini/dicom-streams-js 3.0.7 → 3.0.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exini/dicom-streams-js",
3
- "version": "3.0.7",
3
+ "version": "3.0.8",
4
4
  "description": "Streaming parsing and processing of DICOM data",
5
5
  "main": "node/index.js",
6
6
  "browser": "web/index.js",
package/web/index.js CHANGED
@@ -6515,18 +6515,23 @@ var ThrowTypeError = $gOPD
6515
6515
  : throwTypeError;
6516
6516
 
6517
6517
  var hasSymbols = __webpack_require__(/*! has-symbols */ "./node_modules/has-symbols/index.js")();
6518
+ var hasProto = __webpack_require__(/*! has-proto */ "./node_modules/has-proto/index.js")();
6518
6519
 
6519
- var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
6520
+ var getProto = Object.getPrototypeOf || (
6521
+ hasProto
6522
+ ? function (x) { return x.__proto__; } // eslint-disable-line no-proto
6523
+ : null
6524
+ );
6520
6525
 
6521
6526
  var needsEval = {};
6522
6527
 
6523
- var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array);
6528
+ var TypedArray = typeof Uint8Array === 'undefined' || !getProto ? undefined : getProto(Uint8Array);
6524
6529
 
6525
6530
  var INTRINSICS = {
6526
6531
  '%AggregateError%': typeof AggregateError === 'undefined' ? undefined : AggregateError,
6527
6532
  '%Array%': Array,
6528
6533
  '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer,
6529
- '%ArrayIteratorPrototype%': hasSymbols ? getProto([][Symbol.iterator]()) : undefined,
6534
+ '%ArrayIteratorPrototype%': hasSymbols && getProto ? getProto([][Symbol.iterator]()) : undefined,
6530
6535
  '%AsyncFromSyncIteratorPrototype%': undefined,
6531
6536
  '%AsyncFunction%': needsEval,
6532
6537
  '%AsyncGenerator%': needsEval,
@@ -6556,10 +6561,10 @@ var INTRINSICS = {
6556
6561
  '%Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array,
6557
6562
  '%isFinite%': isFinite,
6558
6563
  '%isNaN%': isNaN,
6559
- '%IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined,
6564
+ '%IteratorPrototype%': hasSymbols && getProto ? getProto(getProto([][Symbol.iterator]())) : undefined,
6560
6565
  '%JSON%': typeof JSON === 'object' ? JSON : undefined,
6561
6566
  '%Map%': typeof Map === 'undefined' ? undefined : Map,
6562
- '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()),
6567
+ '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols || !getProto ? undefined : getProto(new Map()[Symbol.iterator]()),
6563
6568
  '%Math%': Math,
6564
6569
  '%Number%': Number,
6565
6570
  '%Object%': Object,
@@ -6572,10 +6577,10 @@ var INTRINSICS = {
6572
6577
  '%Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect,
6573
6578
  '%RegExp%': RegExp,
6574
6579
  '%Set%': typeof Set === 'undefined' ? undefined : Set,
6575
- '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols ? undefined : getProto(new Set()[Symbol.iterator]()),
6580
+ '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols || !getProto ? undefined : getProto(new Set()[Symbol.iterator]()),
6576
6581
  '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer,
6577
6582
  '%String%': String,
6578
- '%StringIteratorPrototype%': hasSymbols ? getProto(''[Symbol.iterator]()) : undefined,
6583
+ '%StringIteratorPrototype%': hasSymbols && getProto ? getProto(''[Symbol.iterator]()) : undefined,
6579
6584
  '%Symbol%': hasSymbols ? Symbol : undefined,
6580
6585
  '%SyntaxError%': $SyntaxError,
6581
6586
  '%ThrowTypeError%': ThrowTypeError,
@@ -6591,12 +6596,14 @@ var INTRINSICS = {
6591
6596
  '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet
6592
6597
  };
6593
6598
 
6594
- try {
6595
- null.error; // eslint-disable-line no-unused-expressions
6596
- } catch (e) {
6597
- // https://github.com/tc39/proposal-shadowrealm/pull/384#issuecomment-1364264229
6598
- var errorProto = getProto(getProto(e));
6599
- INTRINSICS['%Error.prototype%'] = errorProto;
6599
+ if (getProto) {
6600
+ try {
6601
+ null.error; // eslint-disable-line no-unused-expressions
6602
+ } catch (e) {
6603
+ // https://github.com/tc39/proposal-shadowrealm/pull/384#issuecomment-1364264229
6604
+ var errorProto = getProto(getProto(e));
6605
+ INTRINSICS['%Error.prototype%'] = errorProto;
6606
+ }
6600
6607
  }
6601
6608
 
6602
6609
  var doEval = function doEval(name) {
@@ -6614,7 +6621,7 @@ var doEval = function doEval(name) {
6614
6621
  }
6615
6622
  } else if (name === '%AsyncIteratorPrototype%') {
6616
6623
  var gen = doEval('%AsyncGenerator%');
6617
- if (gen) {
6624
+ if (gen && getProto) {
6618
6625
  value = getProto(gen.prototype);
6619
6626
  }
6620
6627
  }
@@ -6887,6 +6894,28 @@ hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBu
6887
6894
  module.exports = hasPropertyDescriptors;
6888
6895
 
6889
6896
 
6897
+ /***/ }),
6898
+
6899
+ /***/ "./node_modules/has-proto/index.js":
6900
+ /*!*****************************************!*\
6901
+ !*** ./node_modules/has-proto/index.js ***!
6902
+ \*****************************************/
6903
+ /***/ ((module) => {
6904
+
6905
+ "use strict";
6906
+
6907
+
6908
+ var test = {
6909
+ foo: {}
6910
+ };
6911
+
6912
+ var $Object = Object;
6913
+
6914
+ module.exports = function hasProto() {
6915
+ return { __proto__: test }.foo === test.foo && !({ __proto__: null } instanceof $Object);
6916
+ };
6917
+
6918
+
6890
6919
  /***/ }),
6891
6920
 
6892
6921
  /***/ "./node_modules/has-symbols/index.js":
@@ -7443,63 +7472,10 @@ module.exports = function shimNumberIsNaN() {
7443
7472
  "use strict";
7444
7473
 
7445
7474
 
7446
- var forEach = __webpack_require__(/*! for-each */ "./node_modules/for-each/index.js");
7447
- var availableTypedArrays = __webpack_require__(/*! available-typed-arrays */ "./node_modules/available-typed-arrays/index.js");
7448
- var callBound = __webpack_require__(/*! call-bind/callBound */ "./node_modules/call-bind/callBound.js");
7449
-
7450
- var $toString = callBound('Object.prototype.toString');
7451
- var hasToStringTag = __webpack_require__(/*! has-tostringtag/shams */ "./node_modules/has-tostringtag/shams.js")();
7452
- var gOPD = __webpack_require__(/*! gopd */ "./node_modules/gopd/index.js");
7453
-
7454
- var g = typeof globalThis === 'undefined' ? __webpack_require__.g : globalThis;
7455
- var typedArrays = availableTypedArrays();
7456
-
7457
- var $indexOf = callBound('Array.prototype.indexOf', true) || function indexOf(array, value) {
7458
- for (var i = 0; i < array.length; i += 1) {
7459
- if (array[i] === value) {
7460
- return i;
7461
- }
7462
- }
7463
- return -1;
7464
- };
7465
- var $slice = callBound('String.prototype.slice');
7466
- var toStrTags = {};
7467
- var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof');
7468
- if (hasToStringTag && gOPD && getPrototypeOf) {
7469
- forEach(typedArrays, function (typedArray) {
7470
- var arr = new g[typedArray]();
7471
- if (Symbol.toStringTag in arr) {
7472
- var proto = getPrototypeOf(arr);
7473
- var descriptor = gOPD(proto, Symbol.toStringTag);
7474
- if (!descriptor) {
7475
- var superProto = getPrototypeOf(proto);
7476
- descriptor = gOPD(superProto, Symbol.toStringTag);
7477
- }
7478
- toStrTags[typedArray] = descriptor.get;
7479
- }
7480
- });
7481
- }
7482
-
7483
- var tryTypedArrays = function tryAllTypedArrays(value) {
7484
- var anyTrue = false;
7485
- forEach(toStrTags, function (getter, typedArray) {
7486
- if (!anyTrue) {
7487
- try {
7488
- anyTrue = getter.call(value) === typedArray;
7489
- } catch (e) { /**/ }
7490
- }
7491
- });
7492
- return anyTrue;
7493
- };
7475
+ var whichTypedArray = __webpack_require__(/*! which-typed-array */ "./node_modules/which-typed-array/index.js");
7494
7476
 
7495
7477
  module.exports = function isTypedArray(value) {
7496
- if (!value || typeof value !== 'object') { return false; }
7497
- if (!hasToStringTag || !(Symbol.toStringTag in value)) {
7498
- var tag = $slice($toString(value), 8, -1);
7499
- return $indexOf(typedArrays, tag) > -1;
7500
- }
7501
- if (!gOPD) { return false; }
7502
- return tryTypedArrays(value);
7478
+ return !!whichTypedArray(value);
7503
7479
  };
7504
7480
 
7505
7481
 
@@ -20178,9 +20154,7 @@ class ByteParser {
20178
20154
  }
20179
20155
  doParse(remainingRecursions) {
20180
20156
  if (remainingRecursions === 0) {
20181
- this.fail(new Error("Parsing logic didn't produce result. Aborting processing to avoid infinite cycles. " +
20182
- 'In the unlikely case that the parsing logic needs more recursion, override ' +
20183
- 'ParsingLogic.recursionLimit.'));
20157
+ this.fail(new Error("Parsing logic didn't produce result. Aborting processing to avoid infinite cycles."));
20184
20158
  }
20185
20159
  else {
20186
20160
  const doRecurse = this.doParseInner();
@@ -20217,7 +20191,7 @@ class CharacterSets {
20217
20191
  static fromBytes(specificCharacterSetBytes) {
20218
20192
  return !specificCharacterSetBytes || specificCharacterSetBytes.length === 0
20219
20193
  ? exports.defaultCharacterSet
20220
- : new CharacterSets(specificCharacterSetBytes.toString());
20194
+ : new CharacterSets(specificCharacterSetBytes.toString().trim());
20221
20195
  }
20222
20196
  static encode(s) {
20223
20197
  return Buffer.from(s, 'utf8');
@@ -34427,17 +34401,23 @@ class Value {
34427
34401
  if (vr === vr_1.VR.FD) {
34428
34402
  return parseFD(this.bytes, bigEndian).map((v) => v.toString());
34429
34403
  }
34404
+ if (vr === vr_1.VR.SS) {
34405
+ return parseSS(this.bytes, bigEndian).map((v) => v.toString());
34406
+ }
34430
34407
  if (vr === vr_1.VR.SL) {
34431
34408
  return parseSL(this.bytes, bigEndian).map((v) => v.toString());
34432
34409
  }
34433
- if (vr === vr_1.VR.SS) {
34434
- return parseSS(this.bytes, bigEndian).map((v) => v.toString());
34410
+ if (vr === vr_1.VR.SV) {
34411
+ return parseSV(this.bytes, bigEndian).map((v) => v.toString());
34412
+ }
34413
+ if (vr === vr_1.VR.US) {
34414
+ return parseUS(this.bytes, bigEndian).map((v) => v.toString());
34435
34415
  }
34436
34416
  if (vr === vr_1.VR.UL) {
34437
34417
  return parseUL(this.bytes, bigEndian).map((v) => v.toString());
34438
34418
  }
34439
- if (vr === vr_1.VR.US) {
34440
- return parseUS(this.bytes, bigEndian).map((v) => v.toString());
34419
+ if (vr === vr_1.VR.UV) {
34420
+ return parseSV(this.bytes, bigEndian).map((v) => v.toString());
34441
34421
  }
34442
34422
  if (vr === vr_1.VR.OB) {
34443
34423
  return [this.bytes.length + ' bytes'];
@@ -34445,48 +34425,32 @@ class Value {
34445
34425
  if (vr === vr_1.VR.OW) {
34446
34426
  return [this.bytes.length / 2 + ' words'];
34447
34427
  }
34428
+ if (vr === vr_1.VR.OL) {
34429
+ return [this.bytes.length / 4 + ' longs'];
34430
+ }
34431
+ if (vr === vr_1.VR.OV) {
34432
+ return [this.bytes.length / 8 + ' very longs'];
34433
+ }
34448
34434
  if (vr === vr_1.VR.OF) {
34449
- return [parseFL(this.bytes, bigEndian).join(' ')];
34435
+ return [this.bytes.length / 4 + ' floats'];
34450
34436
  }
34451
34437
  if (vr === vr_1.VR.OD) {
34452
- return [parseFD(this.bytes, bigEndian).join(' ')];
34438
+ return [this.bytes.length / 8 + ' doubles'];
34453
34439
  }
34454
- if (vr === vr_1.VR.ST || vr === vr_1.VR.LT || vr === vr_1.VR.UT || vr === vr_1.VR.UR) {
34455
- return [trimPadding(characterSets.decode(this.bytes, vr), vr.paddingByte)];
34440
+ if (vr === vr_1.VR.ST || vr === vr_1.VR.LT || vr === vr_1.VR.UT) {
34441
+ return [trimTrailing(characterSets.decode(this.bytes, vr), vr.paddingByte)];
34456
34442
  }
34457
- if (vr === vr_1.VR.DA || vr === vr_1.VR.TM || vr === vr_1.VR.DT) {
34458
- return splitString(this.bytes.toString()).map(base_1.trim);
34443
+ if (vr === vr_1.VR.LO || vr === vr_1.VR.SH || vr === vr_1.VR.UC) {
34444
+ return splitString(characterSets.decode(this.bytes, vr));
34459
34445
  }
34460
- if (vr === vr_1.VR.UC) {
34461
- return splitString(trimPadding(characterSets.decode(this.bytes, vr), vr.paddingByte));
34446
+ if (vr == vr_1.VR.PN) {
34447
+ return splitString(characterSets.decode(this.bytes, vr)).map(base_1.trim);
34462
34448
  }
34463
- return splitString(characterSets.decode(this.bytes, vr)).map(base_1.trim);
34449
+ return splitString(this.bytes.toString()).map(base_1.trim);
34464
34450
  }
34465
34451
  toSingleString(vr, bigEndian = false, characterSets = character_sets_1.defaultCharacterSet) {
34466
- if (vr === vr_1.VR.AT ||
34467
- vr === vr_1.VR.FL ||
34468
- vr === vr_1.VR.FD ||
34469
- vr === vr_1.VR.SL ||
34470
- vr === vr_1.VR.SS ||
34471
- vr === vr_1.VR.UL ||
34472
- vr === vr_1.VR.US ||
34473
- vr === vr_1.VR.OB ||
34474
- vr === vr_1.VR.OW ||
34475
- vr === vr_1.VR.OF ||
34476
- vr === vr_1.VR.OD) {
34477
- const strings = this.toStrings(vr, bigEndian, characterSets);
34478
- return strings.length === 0 ? '' : strings.join(base_1.multiValueDelimiter);
34479
- }
34480
- if (vr === vr_1.VR.ST || vr === vr_1.VR.LT || vr === vr_1.VR.UT || vr === vr_1.VR.UR) {
34481
- return trimPadding(characterSets.decode(this.bytes, vr), vr.paddingByte);
34482
- }
34483
- if (vr === vr_1.VR.DA || vr === vr_1.VR.TM || vr === vr_1.VR.DT) {
34484
- return (0, base_1.trim)(this.bytes.toString());
34485
- }
34486
- if (vr === vr_1.VR.UC) {
34487
- return trimPadding(characterSets.decode(this.bytes, vr), vr.paddingByte);
34488
- }
34489
- return (0, base_1.trim)(characterSets.decode(this.bytes, vr));
34452
+ const strings = this.toStrings(vr, bigEndian, characterSets);
34453
+ return strings.length === 0 ? '' : strings.join(base_1.multiValueDelimiter);
34490
34454
  }
34491
34455
  toNumbers(vr, bigEndian = false) {
34492
34456
  if (this.length === 0) {
@@ -34586,7 +34550,7 @@ class Value {
34586
34550
  }
34587
34551
  }
34588
34552
  exports.Value = Value;
34589
- function trimPadding(s, paddingByte) {
34553
+ function trimTrailing(s, paddingByte) {
34590
34554
  let index = s.length;
34591
34555
  while (index > 0 && s.charCodeAt(index - 1) <= paddingByte) {
34592
34556
  index -= 1;
@@ -34755,6 +34719,9 @@ function parseAT(value, bigEndian = false) {
34755
34719
  function parseSL(value, bigEndian = false) {
34756
34720
  return splitFixed(value, 4).map((b) => (0, base_1.bytesToInt)(b, bigEndian));
34757
34721
  }
34722
+ function parseSV(value, bigEndian = false) {
34723
+ return splitFixed(value, 8).map((b) => (0, base_1.bytesToFloat)(b, bigEndian));
34724
+ }
34758
34725
  function parseSS(value, bigEndian = false) {
34759
34726
  return splitFixed(value, 2).map((b) => (0, base_1.bytesToShort)(b, bigEndian));
34760
34727
  }
@@ -37206,6 +37173,7 @@ exports["default"] = _default;
37206
37173
 
37207
37174
  var forEach = __webpack_require__(/*! for-each */ "./node_modules/for-each/index.js");
37208
37175
  var availableTypedArrays = __webpack_require__(/*! available-typed-arrays */ "./node_modules/available-typed-arrays/index.js");
37176
+ var callBind = __webpack_require__(/*! call-bind */ "./node_modules/call-bind/index.js");
37209
37177
  var callBound = __webpack_require__(/*! call-bind/callBound */ "./node_modules/call-bind/callBound.js");
37210
37178
  var gOPD = __webpack_require__(/*! gopd */ "./node_modules/gopd/index.js");
37211
37179
 
@@ -37216,45 +37184,78 @@ var g = typeof globalThis === 'undefined' ? __webpack_require__.g : globalThis;
37216
37184
  var typedArrays = availableTypedArrays();
37217
37185
 
37218
37186
  var $slice = callBound('String.prototype.slice');
37219
- var toStrTags = {};
37220
37187
  var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof');
37188
+
37189
+ var $indexOf = callBound('Array.prototype.indexOf', true) || function indexOf(array, value) {
37190
+ for (var i = 0; i < array.length; i += 1) {
37191
+ if (array[i] === value) {
37192
+ return i;
37193
+ }
37194
+ }
37195
+ return -1;
37196
+ };
37197
+ var cache = { __proto__: null };
37221
37198
  if (hasToStringTag && gOPD && getPrototypeOf) {
37222
37199
  forEach(typedArrays, function (typedArray) {
37223
- if (typeof g[typedArray] === 'function') {
37224
- var arr = new g[typedArray]();
37225
- if (Symbol.toStringTag in arr) {
37226
- var proto = getPrototypeOf(arr);
37227
- var descriptor = gOPD(proto, Symbol.toStringTag);
37228
- if (!descriptor) {
37229
- var superProto = getPrototypeOf(proto);
37230
- descriptor = gOPD(superProto, Symbol.toStringTag);
37231
- }
37232
- toStrTags[typedArray] = descriptor.get;
37200
+ var arr = new g[typedArray]();
37201
+ if (Symbol.toStringTag in arr) {
37202
+ var proto = getPrototypeOf(arr);
37203
+ var descriptor = gOPD(proto, Symbol.toStringTag);
37204
+ if (!descriptor) {
37205
+ var superProto = getPrototypeOf(proto);
37206
+ descriptor = gOPD(superProto, Symbol.toStringTag);
37233
37207
  }
37208
+ cache['$' + typedArray] = callBind(descriptor.get);
37234
37209
  }
37235
37210
  });
37211
+ } else {
37212
+ forEach(typedArrays, function (typedArray) {
37213
+ var arr = new g[typedArray]();
37214
+ cache['$' + typedArray] = callBind(arr.slice);
37215
+ });
37236
37216
  }
37237
37217
 
37238
37218
  var tryTypedArrays = function tryAllTypedArrays(value) {
37239
- var foundName = false;
37240
- forEach(toStrTags, function (getter, typedArray) {
37241
- if (!foundName) {
37219
+ var found = false;
37220
+ forEach(cache, function (getter, typedArray) {
37221
+ if (!found) {
37242
37222
  try {
37243
- var name = getter.call(value);
37244
- if (name === typedArray) {
37245
- foundName = name;
37223
+ if ('$' + getter(value) === typedArray) {
37224
+ found = $slice(typedArray, 1);
37246
37225
  }
37247
- } catch (e) {}
37226
+ } catch (e) { /**/ }
37248
37227
  }
37249
37228
  });
37250
- return foundName;
37229
+ return found;
37251
37230
  };
37252
37231
 
37253
- var isTypedArray = __webpack_require__(/*! is-typed-array */ "./node_modules/is-typed-array/index.js");
37232
+ var trySlices = function tryAllSlices(value) {
37233
+ var found = false;
37234
+ forEach(cache, function (getter, name) {
37235
+ if (!found) {
37236
+ try {
37237
+ getter(value);
37238
+ found = $slice(name, 1);
37239
+ } catch (e) { /**/ }
37240
+ }
37241
+ });
37242
+ return found;
37243
+ };
37254
37244
 
37255
37245
  module.exports = function whichTypedArray(value) {
37256
- if (!isTypedArray(value)) { return false; }
37257
- if (!hasToStringTag || !(Symbol.toStringTag in value)) { return $slice($toString(value), 8, -1); }
37246
+ if (!value || typeof value !== 'object') { return false; }
37247
+ if (!hasToStringTag) {
37248
+ var tag = $slice($toString(value), 8, -1);
37249
+ if ($indexOf(typedArrays, tag) > -1) {
37250
+ return tag;
37251
+ }
37252
+ if (tag !== 'Object') {
37253
+ return false;
37254
+ }
37255
+ // node < 0.6 hits here on real Typed Arrays
37256
+ return trySlices(value);
37257
+ }
37258
+ if (!gOPD) { return null; } // unknown engine
37258
37259
  return tryTypedArrays(value);
37259
37260
  };
37260
37261