cbor-x 1.5.1 → 1.5.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/dist/index.js CHANGED
@@ -945,9 +945,11 @@
945
945
  }
946
946
  function registerTypedArray(TypedArray, tag) {
947
947
  let dvMethod = 'get' + TypedArray.name.slice(0, -5);
948
- if (typeof TypedArray !== 'function')
948
+ let bytesPerElement;
949
+ if (typeof TypedArray === 'function')
950
+ bytesPerElement = TypedArray.BYTES_PER_ELEMENT;
951
+ else
949
952
  TypedArray = null;
950
- let bytesPerElement = TypedArray.BYTES_PER_ELEMENT;
951
953
  for (let littleEndian = 0; littleEndian < 2; littleEndian++) {
952
954
  if (!littleEndian && bytesPerElement == 1)
953
955
  continue
@@ -1481,7 +1483,7 @@
1481
1483
  }
1482
1484
  position += length;
1483
1485
  } else if (type === 'number') {
1484
- if (value >>> 0 === value) {// positive integer, 32-bit or less
1486
+ if (!this.alwaysUseFloat && value >>> 0 === value) {// positive integer, 32-bit or less
1485
1487
  // positive uint
1486
1488
  if (value < 0x18) {
1487
1489
  target[position++] = value;
@@ -1497,7 +1499,7 @@
1497
1499
  targetView.setUint32(position, value);
1498
1500
  position += 4;
1499
1501
  }
1500
- } else if (value >> 0 === value) { // negative integer
1502
+ } else if (!this.alwaysUseFloat && value >> 0 === value) { // negative integer
1501
1503
  if (value >= -0x18) {
1502
1504
  target[position++] = 0x1f - value;
1503
1505
  } else if (value >= -0x100) {