nv-facutil-slct-ta 1.1.2 → 1.1.3

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.
Files changed (2) hide show
  1. package/index.js +75 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -412,6 +412,78 @@ const min_tacls = (...Clss) => {
412
412
  return min;
413
413
  };
414
414
 
415
+ const read_dv_with_cls = (dv, Cls, offset, little_endian = true) => {
416
+ if (Cls === Uint8Array) {
417
+ return dv.getUint8(offset);
418
+ } else if (Cls === Int8Array) {
419
+ return dv.getInt8(offset);
420
+
421
+ } else if (Cls === Uint16Array) {
422
+ return dv.getUint16(offset, little_endian);
423
+ } else if (Cls === Int16Array) {
424
+ return dv.getInt16(offset, little_endian);
425
+
426
+ } else if (Cls === Uint32Array) {
427
+ return dv.getUint32(offset, little_endian);
428
+ } else if (Cls === Int32Array) {
429
+ return dv.getInt32(offset, little_endian);
430
+
431
+ } else if (Cls === Float32Array) {
432
+ return dv.getFloat32(offset, little_endian);
433
+ } else if (Cls === Float64Array) {
434
+ return dv.getFloat64(offset, little_endian);
435
+
436
+ } else if (Cls === BigUint64Array) {
437
+ return dv.getBigUint64(offset, little_endian);
438
+ } else if (Cls === BigInt64Array) {
439
+ return dv.getBigInt64(offset, little_endian);
440
+
441
+ } else if (globalThis.Float16Array && Cls === Float16Array) {
442
+ const u16 = dv.getUint16(offset, little_endian);
443
+ return f16_to_f32(u16);
444
+
445
+ } else {
446
+ throw new Error("Unsupported TypedArray class");
447
+ }
448
+ };
449
+
450
+
451
+ const write_dv_with_cls = (dv, Cls, offset, value, little_endian = true) => {
452
+ if (Cls === Uint8Array) {
453
+ dv.setUint8(offset, value);
454
+ } else if (Cls === Int8Array) {
455
+ dv.setInt8(offset, value);
456
+
457
+ } else if (Cls === Uint16Array) {
458
+ dv.setUint16(offset, value, little_endian);
459
+ } else if (Cls === Int16Array) {
460
+ dv.setInt16(offset, value, little_endian);
461
+
462
+ } else if (Cls === Uint32Array) {
463
+ dv.setUint32(offset, value, little_endian);
464
+ } else if (Cls === Int32Array) {
465
+ dv.setInt32(offset, value, little_endian);
466
+
467
+ } else if (Cls === Float32Array) {
468
+ dv.setFloat32(offset, value, little_endian);
469
+ } else if (Cls === Float64Array) {
470
+ dv.setFloat64(offset, value, little_endian);
471
+
472
+ } else if (Cls === BigUint64Array) {
473
+ dv.setBigUint64(offset, value, little_endian);
474
+ } else if (Cls === BigInt64Array) {
475
+ dv.setBigInt64(offset, value, little_endian);
476
+
477
+ } else if (globalThis.Float16Array && Cls === Float16Array) {
478
+ const u16 = f32_to_f16(value);
479
+ dv.setUint16(offset, u16, little_endian);
480
+
481
+ } else {
482
+ throw new Error("Unsupported TypedArray class");
483
+ }
484
+ };
485
+
486
+
415
487
  module.exports = {
416
488
  tcate,
417
489
  ////
@@ -464,5 +536,7 @@ module.exports = {
464
536
  ele_tbrief_to_tacls,
465
537
  tacls_to_ele_tbrief,
466
538
  ////
467
- min_tacls,max_tacls
539
+ min_tacls,max_tacls,
540
+ read_dv_with_cls,
541
+ write_dv_with_cls,
468
542
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nv-facutil-slct-ta",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"