dolphindb 2.0.1130 → 3.0.1

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.
@@ -0,0 +1,2 @@
1
+ declare const _default: Linter.FlatConfig[];
2
+ export default _default;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eslint.config.js","sourceRoot":"","sources":["eslint.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,iDAAiD;AACjD,eAAe,CAAC,YAAY,CAAC,CAAA","sourcesContent":["import { xlint_config } from 'xshell/xlint.js'\n\n// eslint-disable-next-line no-restricted-exports\nexport default [xlint_config]\n"]}
package/i18n/dict.json CHANGED
@@ -11,8 +11,8 @@
11
11
  "this.form 必须是 DdbForm.dict, 否则不能调用 to_dict 转换为 js object": {
12
12
  "en": "this.form must be DdbForm.dict, otherwise to_dict cannot be called to convert to js object"
13
13
  },
14
- "当前只支持自动转换 dict<string, any> 为 js object": {
15
- "en": "currently api only supports automatic conversion of dict<string, any> to js object"
14
+ "当前只支持自动转换 dict<string, any | ...dictables> 为 js object": {
15
+ "en": "currently api only supports automatic conversion of dict<string, any | ...dictables> to js object"
16
16
  },
17
17
  "deep = true 时必须设置 strip = true": {
18
18
  "en": "strip = true must be set when deep = true"
package/index.d.ts CHANGED
@@ -162,8 +162,7 @@ export declare class DdbObj<TValue extends DdbValue = DdbValue> {
162
162
  to_rows<T extends Record<string, any> = Record<string, any>>(): T[];
163
163
  /** 将 dict<string, any> 自动转换为 js object (Record<string, any>) Automatically convert dict<string, any> to js object (Record<string, any>)
164
164
  - options?:
165
- - strip?: `false` 是否将 DdbObj 中的 value 直接提取、剥离出来作为 js object 的 value (丢弃 DdbObj 中的其余信息,只保留 value)
166
- Whether to directly extract and strip the value in DdbObj as the value of js object (discard the rest of the information in DdbObj, only keep the value)
165
+ - strip?: `false` 是否将 dict<string, any> 中的 value 直接提取、剥离出来作为 js object 的 value (丢弃 DdbObj 中的其余信息,只保留 value)
167
166
  - deep?: `false` 是否递归转换
168
167
  Whether to convert recursively
169
168
  */
package/index.js CHANGED
@@ -9,7 +9,7 @@ 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
11
  import { is_decimal_type, is_decimal_null_value, get_duration_unit } from './shared/utils.js';
12
- import { nulls, DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType, DdbVoidType } from './shared/constants.js';
12
+ import { nulls, DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType, DdbVoidType, dictables } from './shared/constants.js';
13
13
  export * from './shared/constants.js';
14
14
  // Simulate other TypedArray behavior in nodejs
15
15
  BigInt128Array.prototype[inspect.custom] = function () {
@@ -1256,15 +1256,20 @@ export class DdbObj {
1256
1256
  to_dict({ strip, deep, } = {}) {
1257
1257
  assert(this.form === DdbForm.dict, t('this.form 必须是 DdbForm.dict, 否则不能调用 to_dict 转换为 js object'));
1258
1258
  const [{ value: keys, type: key_type }, { value: values, type: value_type }] = this.value;
1259
- assert(key_type === DdbType.string && value_type === DdbType.any, t('当前只支持自动转换 dict<string, any> 为 js object'));
1259
+ assert(key_type === DdbType.string && dictables.has(value_type), t('当前只支持自动转换 dict<string, any | ...dictables> 为 js object'));
1260
1260
  assert(!(deep && !strip), t('deep = true 时必须设置 strip = true'));
1261
1261
  let obj = {};
1262
1262
  for (let i = 0; i < this.rows; i++) {
1263
- let value = values[i];
1264
- if (deep && value.form === DdbForm.dict)
1265
- obj[keys[i]] = value.to_dict({ strip, deep });
1263
+ const key = keys[i];
1264
+ if (value_type === DdbType.any) {
1265
+ let value = values[i];
1266
+ if (deep && value.form === DdbForm.dict)
1267
+ obj[key] = value.to_dict({ strip, deep });
1268
+ else
1269
+ obj[key] = strip ? value.value : value;
1270
+ }
1266
1271
  else
1267
- obj[keys[i]] = strip ? value.value : value;
1272
+ obj[key] = values[i];
1268
1273
  }
1269
1274
  return obj;
1270
1275
  }
@@ -1276,7 +1281,7 @@ let _grouping = true;
1276
1281
  /** 缓存,为了优化性能,通常 options.decimals 都是不变的 */
1277
1282
  let _formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
1278
1283
  /** 用来处理时差 To deal with jet lag */
1279
- let _datetime_formatter = new Intl.DateTimeFormat('zh-CN', { dateStyle: 'short', timeStyle: 'medium', timeZone: 'UTC' });
1284
+ let _datetime_formatter = new Intl.DateTimeFormat('zh-CN', { dateStyle: 'short', timeStyle: 'medium', timeZone: 'UTC', hour12: false });
1280
1285
  /** 根据 DdbType 格式化单个元素 (value) 为字符串,空值返回 'null' 字符串 Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
1281
1286
  export function format(type, value, le, options = {}) {
1282
1287
  const formatter = (() => {