dolphindb 3.0.209 → 3.0.210

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.d.ts CHANGED
@@ -280,6 +280,7 @@ export interface DdbMatrixData {
280
280
  }
281
281
  export type IotVectorItemValue = [number | string | bigint | boolean][];
282
282
  export type DdbIotAnyVector = DdbObj<IotVectorItemValue>;
283
+ export type JsSimpleType = DdbObj | string | boolean | null | undefined;
283
284
  /** 可以表示所有 DolphinDB 数据库中的数据类型 Can represent data types in all DolphinDB databases */
284
285
  export declare class DdbObj<TValue extends DdbValue = DdbValue> {
285
286
  static dec: TextDecoder;
@@ -356,10 +357,10 @@ export declare class DdbObj<TValue extends DdbValue = DdbValue> {
356
357
  }, limit?: number): TensorData;
357
358
  [inspect.custom](depth: number, _options: InspectOptions, _inspect: any): string;
358
359
  inspect_type(): string;
359
- /** 自动转换 js string, boolean 为 DdbObj */
360
- static to_ddbobj(value: DdbObj | string | boolean): DdbObj;
360
+ /** 自动转换 JsSimpleType 为 DdbObj */
361
+ static to_ddbobj(value: JsSimpleType): DdbObj;
361
362
  /** 转换 js 数组为 DdbObj[] */
362
- static to_ddbobjs(values: (DdbObj | string | boolean)[]): DdbObj<DdbValue>[];
363
+ static to_ddbobjs(values: JsSimpleType[]): DdbObj<DdbValue>[];
363
364
  /** 将 table 转换为 rows,空值转换为 null
364
365
  @deprecated 用 data() */
365
366
  to_rows<T extends Record<string, any> = Record<string, any>>(): T[];
@@ -410,6 +411,7 @@ export interface ConvertOptions {
410
411
  export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, char, timestamp }?: ConvertOptions): string | number | bigint | boolean | number[] | string[] | Uint8Array<ArrayBufferLike> | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | Int8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | BigInt64Array<ArrayBufferLike> | BigInt128Array | Uint8Array<ArrayBufferLike>[] | DdbObj<DdbValue>[] | IotVectorItemValue | DdbSymbolExtendedValue | DdbArrayVectorValue | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbDecimal128VectorValue | DdbDurationVectorValue | DdbMatrixValue | DdbChartValue | DdbTensorValue;
411
412
  /** 转换一个向量到 js 原生数组 */
412
413
  export declare function converts(type: DdbType, value: DdbVectorValue, rows: number, le: boolean, options?: ConvertOptions): any[] | Uint8Array;
414
+ /** 构造 void 类型,默认为 `DdbVoidType.undefined` */
413
415
  export declare class DdbVoid extends DdbObj<undefined> {
414
416
  constructor(value?: DdbVoidType);
415
417
  }
package/index.js CHANGED
@@ -1548,10 +1548,14 @@ export class DdbObj {
1548
1548
  return `${DdbForm[this.form]} ${tname}`;
1549
1549
  }
1550
1550
  }
1551
- /** 自动转换 js string, boolean 为 DdbObj */
1551
+ /** 自动转换 JsSimpleType 为 DdbObj */
1552
1552
  static to_ddbobj(value) {
1553
1553
  if (value && value instanceof DdbObj)
1554
1554
  return value;
1555
+ if (value === undefined)
1556
+ return new DdbVoid();
1557
+ if (value === null)
1558
+ return new DdbVoid(DdbVoidType.null);
1555
1559
  const type = typeof value;
1556
1560
  switch (type) {
1557
1561
  case 'string':
@@ -2122,6 +2126,7 @@ export function converts(type, value, rows, le, options) {
2122
2126
  }).flat();
2123
2127
  }
2124
2128
  }
2129
+ /** 构造 void 类型,默认为 `DdbVoidType.undefined` */
2125
2130
  export class DdbVoid extends DdbObj {
2126
2131
  constructor(value = DdbVoidType.undefined) {
2127
2132
  super({
@@ -3279,9 +3284,12 @@ export class DDB {
3279
3284
  for (const arg of args)
3280
3285
  if (arg && arg instanceof DdbObj)
3281
3286
  has_ddbobj = true;
3287
+ else if (arg === undefined || arg === null) {
3288
+ // simple
3289
+ }
3282
3290
  else {
3283
3291
  const type = typeof arg;
3284
- if (type === 'string' || type === 'boolean') { }
3292
+ if (type === 'string' || type === 'boolean') { } // simple
3285
3293
  else
3286
3294
  simple = false;
3287
3295
  }
@@ -3374,15 +3382,10 @@ export class DDB {
3374
3382
  /** index of line feed 0 */
3375
3383
  const ilf0 = buf.indexOf(0x0a); // '\n'
3376
3384
  const parts = this.dec.decode(buf.subarray(0, ilf0)).split(' ');
3377
- /** session id */
3378
- const sid = parts[0];
3379
- if (sid !== this.sid) {
3380
- console.log(t('session id 从 {{sid}} 变为 {{sid_}}', { sid: this.sid, sid_: sid }));
3381
- this.sid = sid;
3382
- }
3383
- /** 返回对象的数量 */
3384
- const nobj = Number(parts[1]);
3385
- /** 大小端: 协议中大端为 0, 小端为 1 */
3385
+ this.sid = parts[0];
3386
+ // 返回对象的数量
3387
+ // const nobj = Number(parts[1])
3388
+ // 大小端: 协议中大端为 0, 小端为 1
3386
3389
  this.le = Number(parts[2]) !== 0;
3387
3390
  const ils1 = ilf0 + 1;
3388
3391
  const ilf1 = buf.indexOf(0x0a, ils1); // '\n'