dolphindb 3.0.202 → 3.0.204

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
@@ -397,16 +397,18 @@ export declare function format(type: DdbType, value: DdbValue, le: boolean, opti
397
397
  /** 格式化向量、集合中的第 index 项为字符串,空值返回 'null' 字符串 formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
398
398
  export declare function formati(obj: DdbVectorObj, index: number, options?: InspectOptions): string;
399
399
  export interface ConvertOptions {
400
- /** `'string'` blob 类型数据的格式 */
400
+ /** `'string'` blob 转换格式 */
401
401
  blob?: 'string' | 'binary';
402
- /** `'string'` char 类型数据的格式: string 解析成 string[],number 解析为 number[] */
402
+ /** `'string'` char 转换格式: string 转为 string[],number 转为 number[] */
403
403
  char?: 'string' | 'number';
404
+ /** `'strings'` char vector 转换格式: strings 转为 string[], binary 转为 Uint8Array */
405
+ chars?: 'strings' | 'binary';
404
406
  /** `'ms'` timestamp 类型转换为字符串表示时显示到秒还是毫秒 */
405
407
  timestamp?: 's' | 'ms';
406
408
  }
407
409
  export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, char, timestamp }?: ConvertOptions): string | number | bigint | boolean | Uint8Array | number[] | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | string[] | Uint8Array[] | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | BigInt128Array | DdbObj<DdbValue>[] | IotVectorItemValue | DdbSymbolExtendedValue | DdbArrayVectorValue | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbDecimal128VectorValue | DdbDurationVectorValue | DdbMatrixValue | DdbChartValue | DdbTensorValue;
408
410
  /** 转换一个向量到 js 原生数组 */
409
- export declare function converts(type: DdbType, value: DdbVectorValue, rows: number, le: boolean, options?: ConvertOptions): any[];
411
+ export declare function converts(type: DdbType, value: DdbVectorValue, rows: number, le: boolean, options?: ConvertOptions): any[] | Uint8Array;
410
412
  export declare class DdbVoid extends DdbObj<undefined> {
411
413
  constructor(value?: DdbVoidType);
412
414
  }
package/index.js CHANGED
@@ -2032,7 +2032,6 @@ export function converts(type, value, rows, le, options) {
2032
2032
  switch (type) {
2033
2033
  // 可以直接用下标取值再转换的类型
2034
2034
  case DdbType.bool:
2035
- case DdbType.char:
2036
2035
  case DdbType.short:
2037
2036
  case DdbType.int:
2038
2037
  case DdbType.float:
@@ -2059,6 +2058,11 @@ export function converts(type, value, rows, le, options) {
2059
2058
  case DdbType.blob:
2060
2059
  case DdbType.compressed:
2061
2060
  return Array.prototype.map.call(value, (x) => convert(type, x, le, options));
2061
+ case DdbType.char:
2062
+ if (options?.chars === 'binary')
2063
+ return value;
2064
+ else
2065
+ return Array.prototype.map.call(value, (x) => convert(type, x, le, options));
2062
2066
  case DdbType.void:
2063
2067
  return [];
2064
2068
  case DdbType.symbol_extended: {
@@ -2523,7 +2527,7 @@ export function datetime2ms(datetime) {
2523
2527
  if (datetime === null || datetime === nulls.int32)
2524
2528
  return null;
2525
2529
  const date = new Date(1000 * datetime);
2526
- return dayjs(`${_datetime_formatter.format(date)}.${date.getUTCMilliseconds()}`).valueOf();
2530
+ return new Date(`${_datetime_formatter.format(date)}.${date.getUTCMilliseconds()}`).valueOf();
2527
2531
  }
2528
2532
  export function datetime2str(datetime, format = 'YYYY.MM.DD HH:mm:ss') {
2529
2533
  return (datetime === null || datetime === nulls.int32) ?
@@ -2536,7 +2540,7 @@ export function timestamp2ms(timestamp) {
2536
2540
  if (timestamp === null || timestamp === nulls.int64)
2537
2541
  return null;
2538
2542
  const date = new Date(Number(timestamp));
2539
- return dayjs(`${_datetime_formatter.format(date)}.${date.getUTCMilliseconds()}`).valueOf();
2543
+ return new Date(`${_datetime_formatter.format(date)}.${date.getUTCMilliseconds()}`).valueOf();
2540
2544
  }
2541
2545
  /** format timestamp (bigint) to string
2542
2546
  - timestamp: bigint value
@@ -2598,7 +2602,7 @@ export function nanotimestamp2ns(nanotimestamp) {
2598
2602
  if (nanotimestamp === null || nanotimestamp === nulls.int64)
2599
2603
  return null;
2600
2604
  const date = new Date(Number(nanotimestamp / 1000000n));
2601
- return BigInt(dayjs(`${_datetime_formatter.format(date)}.${date.getUTCMilliseconds()}`).valueOf()) * 1000000n + nanotimestamp % 1000000n;
2605
+ return BigInt(new Date(`${_datetime_formatter.format(date)}.${date.getUTCMilliseconds()}`).valueOf()) * 1000000n + nanotimestamp % 1000000n;
2602
2606
  }
2603
2607
  /** format nanotimestamp value (bigint) to string
2604
2608
  - nanotimestamp: bigint value
@@ -3250,10 +3254,8 @@ export class DDB {
3250
3254
  else {
3251
3255
  const type = typeof arg;
3252
3256
  if (type === 'string' || type === 'boolean') { }
3253
- else {
3257
+ else
3254
3258
  simple = false;
3255
- break;
3256
- }
3257
3259
  }
3258
3260
  let result;
3259
3261
  if (simple)