dolphindb 3.0.201 → 3.0.203

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
@@ -408,16 +408,18 @@ export declare function format(type: DdbType, value: DdbValue, le: boolean, opti
408
408
  /** 格式化向量、集合中的第 index 项为字符串,空值返回 'null' 字符串 formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
409
409
  export declare function formati(obj: DdbVectorObj, index: number, options?: InspectOptions): string;
410
410
  export interface ConvertOptions {
411
- /** `'string'` blob 类型数据的格式 */
411
+ /** `'string'` blob 转换格式 */
412
412
  blob?: 'string' | 'binary';
413
- /** `'string'` char 类型数据的格式: string 解析成 string[],number 解析为 number[] */
413
+ /** `'string'` char 转换格式: string 转为 string[],number 转为 number[] */
414
414
  char?: 'string' | 'number';
415
+ /** `'strings'` char vector 转换格式: strings 转为 string[], binary 转为 Uint8Array */
416
+ chars?: 'strings' | 'binary';
415
417
  /** `'ms'` timestamp 类型转换为字符串表示时显示到秒还是毫秒 */
416
418
  timestamp?: 's' | 'ms';
417
419
  }
418
420
  export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, char, timestamp }?: ConvertOptions): string | number | bigint | boolean | Uint8Array | number[] | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | BigInt128Array | string[] | Uint8Array[] | DdbObj<DdbValue>[] | IotVectorItemValue | DdbSymbolExtendedValue | DdbArrayVectorValue | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbDecimal128VectorValue | DdbDurationVectorValue | DdbMatrixValue | DdbChartValue | DdbTensorValue;
419
421
  /** 转换一个向量到 js 原生数组 */
420
- export declare function converts(type: DdbType, value: DdbVectorValue, rows: number, le: boolean, options?: ConvertOptions): any[];
422
+ export declare function converts(type: DdbType, value: DdbVectorValue, rows: number, le: boolean, options?: ConvertOptions): any[] | Uint8Array;
421
423
  export declare class DdbVoid extends DdbObj<undefined> {
422
424
  constructor(value?: DdbVoidType);
423
425
  }
package/browser.js CHANGED
@@ -2058,7 +2058,6 @@ export function converts(type, value, rows, le, options) {
2058
2058
  switch (type) {
2059
2059
  // 可以直接用下标取值再转换的类型
2060
2060
  case DdbType.bool:
2061
- case DdbType.char:
2062
2061
  case DdbType.short:
2063
2062
  case DdbType.int:
2064
2063
  case DdbType.float:
@@ -2085,6 +2084,11 @@ export function converts(type, value, rows, le, options) {
2085
2084
  case DdbType.blob:
2086
2085
  case DdbType.compressed:
2087
2086
  return Array.prototype.map.call(value, (x) => convert(type, x, le, options));
2087
+ case DdbType.char:
2088
+ if (options?.chars === 'binary')
2089
+ return value;
2090
+ else
2091
+ return Array.prototype.map.call(value, (x) => convert(type, x, le, options));
2088
2092
  case DdbType.void:
2089
2093
  return [];
2090
2094
  case DdbType.symbol_extended: {
@@ -2549,7 +2553,7 @@ export function datetime2ms(datetime) {
2549
2553
  if (datetime === null || datetime === nulls.int32)
2550
2554
  return null;
2551
2555
  const date = new Date(1000 * datetime);
2552
- return dayjs(`${_datetime_formatter.format(date)}.${date.getUTCMilliseconds()}`).valueOf();
2556
+ return new Date(`${_datetime_formatter.format(date)}.${date.getUTCMilliseconds()}`).valueOf();
2553
2557
  }
2554
2558
  export function datetime2str(datetime, format = 'YYYY.MM.DD HH:mm:ss') {
2555
2559
  return (datetime === null || datetime === nulls.int32) ?
@@ -2562,7 +2566,7 @@ export function timestamp2ms(timestamp) {
2562
2566
  if (timestamp === null || timestamp === nulls.int64)
2563
2567
  return null;
2564
2568
  const date = new Date(Number(timestamp));
2565
- return dayjs(`${_datetime_formatter.format(date)}.${date.getUTCMilliseconds()}`).valueOf();
2569
+ return new Date(`${_datetime_formatter.format(date)}.${date.getUTCMilliseconds()}`).valueOf();
2566
2570
  }
2567
2571
  /** format timestamp (bigint) to string
2568
2572
  - timestamp: bigint value
@@ -2624,7 +2628,7 @@ export function nanotimestamp2ns(nanotimestamp) {
2624
2628
  if (nanotimestamp === null || nanotimestamp === nulls.int64)
2625
2629
  return null;
2626
2630
  const date = new Date(Number(nanotimestamp / 1000000n));
2627
- return BigInt(dayjs(`${_datetime_formatter.format(date)}.${date.getUTCMilliseconds()}`).valueOf()) * 1000000n + nanotimestamp % 1000000n;
2631
+ return BigInt(new Date(`${_datetime_formatter.format(date)}.${date.getUTCMilliseconds()}`).valueOf()) * 1000000n + nanotimestamp % 1000000n;
2628
2632
  }
2629
2633
  /** format nanotimestamp value (bigint) to string
2630
2634
  - nanotimestamp: bigint value