dolphindb 2.0.1103 → 3.0.0

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/browser.d.ts CHANGED
@@ -3,7 +3,7 @@ import { Lock } from 'xshell/utils.browser.js';
3
3
  import { type WebSocketConnectionError } from 'xshell/net.browser.js';
4
4
  import { type DdbDecimal128Value, type DdbDecimal128VectorValue } from './data-types/decimal-128.js';
5
5
  import type { BigInt128Array } from './shared/bigint-128-array.js';
6
- import { DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType } from './shared/constants.js';
6
+ import { DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType, DdbVoidType } from './shared/constants.js';
7
7
  export * from './shared/constants.js';
8
8
  export type { DdbDecimal128Value, DdbDecimal128VectorValue } from './data-types/decimal-128.js';
9
9
  export interface DdbFunctionDefValue {
@@ -197,7 +197,7 @@ export declare function format(type: DdbType, value: DdbValue, le: boolean, opti
197
197
  /** 格式化向量、集合中的第 index 项为字符串,空值返回 'null' 字符串 formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
198
198
  export declare function formati(obj: DdbVectorObj, index: number, options?: InspectOptions): string;
199
199
  export declare class DdbVoid extends DdbObj<undefined> {
200
- constructor();
200
+ constructor(value?: DdbVoidType);
201
201
  }
202
202
  export declare class DdbBool extends DdbObj<boolean> {
203
203
  constructor(value: boolean | null);
package/browser.js CHANGED
@@ -10,7 +10,7 @@ import { connect_websocket } from 'xshell/net.browser.js';
10
10
  import { t } from './i18n/index.js';
11
11
  import { DdbDecimal128Serializor } from './data-types/decimal-128.js';
12
12
  import { is_decimal_type, is_decimal_null_value, get_duration_unit } from './shared/utils.js';
13
- import { nulls, DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType } from './shared/constants.js';
13
+ import { nulls, DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType, DdbVoidType } from './shared/constants.js';
14
14
  export * from './shared/constants.js';
15
15
  /** 可以表示所有 DolphinDB 数据库中的数据类型 Can represent data types in all DolphinDB databases */
16
16
  export class DdbObj {
@@ -261,13 +261,12 @@ export class DdbObj {
261
261
  }
262
262
  static parse_scalar(buf, le, type) {
263
263
  switch (type) {
264
- case DdbType.void:
265
- return [1, null];
266
264
  case DdbType.bool: {
267
265
  const dv = new DataView(buf.buffer, buf.byteOffset);
268
266
  const value = dv.getInt8(0);
269
267
  return [1, value === nulls.int8 ? null : Boolean(value)];
270
268
  }
269
+ case DdbType.void:
271
270
  case DdbType.char: {
272
271
  const dv = new DataView(buf.buffer, buf.byteOffset);
273
272
  const value = dv.getInt8(0);
@@ -716,10 +715,7 @@ export class DdbObj {
716
715
  case DdbForm.scalar:
717
716
  switch (type) {
718
717
  case DdbType.void:
719
- // Server 实现中区分了 explicitNull
720
- // Void::serialize()
721
- // isNothing() ? 0 : 1;
722
- return [Uint8Array.of(0)];
718
+ return [Uint8Array.of(Number(value))];
723
719
  case DdbType.bool:
724
720
  return [
725
721
  Int8Array.of(value === null ?
@@ -898,7 +894,6 @@ export class DdbObj {
898
894
  case DdbType.void:
899
895
  return [];
900
896
  case DdbType.bool:
901
- return [value];
902
897
  case DdbType.char:
903
898
  return [value];
904
899
  case DdbType.short:
@@ -1280,7 +1275,7 @@ let _grouping = true;
1280
1275
  /** 缓存,为了优化性能,通常 options.decimals 都是不变的 Cache, in order to optimize performance, usually options.decimals are unchanged */
1281
1276
  let _formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
1282
1277
  /** 用来处理时差 To deal with jet lag */
1283
- let _datetime_formatter = new Intl.DateTimeFormat('zh-CN', { dateStyle: 'short', timeStyle: 'medium', timeZone: 'UTC' });
1278
+ let _datetime_formatter = new Intl.DateTimeFormat('zh-CN', { dateStyle: 'short', timeStyle: 'medium', timeZone: 'UTC', hour12: false });
1284
1279
  /** 根据 DdbType 格式化单个元素 (value) 为字符串 Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
1285
1280
  export function format(type, value, le, options = {}) {
1286
1281
  const { nullstr = false, colors = false, quote = false, grouping = true } = options;
@@ -1299,8 +1294,9 @@ export function format(type, value, le, options = {}) {
1299
1294
  return options.decimals === undefined || options.decimals === null ? default_formatter : _formatter;
1300
1295
  })();
1301
1296
  function get_nullstr() {
1297
+ const str = value === DdbVoidType.default ? 'default' : 'null';
1302
1298
  return nullstr ?
1303
- colors ? grey('null') : 'null'
1299
+ colors ? grey(str) : str
1304
1300
  :
1305
1301
  '';
1306
1302
  }
@@ -1321,6 +1317,8 @@ export function format(type, value, le, options = {}) {
1321
1317
  return colors ? magenta(str) : str;
1322
1318
  }
1323
1319
  switch (type) {
1320
+ case DdbType.void:
1321
+ return get_nullstr();
1324
1322
  case DdbType.bool:
1325
1323
  if (value === null || value === nulls.int8)
1326
1324
  return get_nullstr();
@@ -1567,11 +1565,11 @@ export function formati(obj, index, options = {}) {
1567
1565
  }
1568
1566
  }
1569
1567
  export class DdbVoid extends DdbObj {
1570
- constructor() {
1568
+ constructor(value = DdbVoidType.undefined) {
1571
1569
  super({
1572
1570
  form: DdbForm.scalar,
1573
1571
  type: DdbType.void,
1574
- value: null,
1572
+ value,
1575
1573
  });
1576
1574
  }
1577
1575
  }