dolphindb 2.0.1036 → 2.0.1101

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/index.js CHANGED
@@ -8,7 +8,7 @@ import { concat, assert, inspect, typed_array_to_buffer, connect_websocket, Lock
8
8
  import { t } from './i18n/index.js';
9
9
  import { DdbDecimal128Serializor } from './data-types/decimal-128.js';
10
10
  import { BigInt128Array } from './shared/bigint-128-array.js';
11
- import { is_decimal_type, is_decimal_null_value } from './shared/utils/decimal-type.js';
11
+ import { is_decimal_type, is_decimal_null_value, get_duration_unit } from './shared/utils.js';
12
12
  import { nulls, DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType } from './shared/constants.js';
13
13
  export * from './shared/constants.js';
14
14
  // Simulate other TypedArray behavior in nodejs
@@ -958,6 +958,15 @@ export class DdbObj {
958
958
  case DdbType.complex:
959
959
  case DdbType.point:
960
960
  return [value];
961
+ case DdbType.duration: {
962
+ let bufs = new Int32Array(length * 2);
963
+ for (let i = 0; i < length; i++) {
964
+ const { data, unit } = value[i];
965
+ bufs[2 * i] = data;
966
+ bufs[2 * i + 1] = unit;
967
+ }
968
+ return [bufs];
969
+ }
961
970
  case DdbType.any: {
962
971
  // [1, 2, 'a', 'aaa']
963
972
  // any[4](<Buffer
@@ -1466,7 +1475,7 @@ export function format(type, value, le, options = {}) {
1466
1475
  }
1467
1476
  case DdbType.duration: {
1468
1477
  const { data, unit } = value;
1469
- const str = `${data}${DdbDurationUnit[unit]}`;
1478
+ const str = `${data}${DdbDurationUnit[unit] ?? get_duration_unit(unit)}`;
1470
1479
  return options.colors ? str.magenta : str;
1471
1480
  }
1472
1481
  case DdbType.decimal32: