dolphindb 3.0.1 → 3.0.3

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
@@ -181,17 +181,18 @@ export declare class DdbObj<TValue extends DdbValue = DdbValue> {
181
181
  }): T;
182
182
  }
183
183
  export interface InspectOptions {
184
+ /** `false` */
184
185
  colors?: boolean;
185
186
  /** `null` decimal places 小数位数 */
186
187
  decimals?: number;
187
188
  /** `false` 决定 null 值如何返回. nullstr ? 'null' : '' */
188
189
  nullstr?: boolean;
189
- /** `false` 决定 string, symbol, char 类型是否加引号 */
190
+ /** `在 format 中默认为 false,在 toString 中默认为 true` 决定 string, symbol, char 类型是否加引号 */
190
191
  quote?: boolean;
191
192
  /** `true` 决定格式化后的数据是否有千分位 */
192
193
  grouping?: boolean;
193
194
  }
194
- /** 根据 DdbType 格式化单个元素 (value) 为字符串 Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
195
+ /** 根据 DdbType 格式化单个元素 (value) 为字符串 */
195
196
  export declare function format(type: DdbType, value: DdbValue, le: boolean, options?: InspectOptions): string;
196
197
  /** 格式化向量、集合中的第 index 项为字符串,空值返回 'null' 字符串 formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
197
198
  export declare function formati(obj: DdbVectorObj, index: number, options?: InspectOptions): string;
package/browser.js CHANGED
@@ -120,6 +120,8 @@ export class DdbObj {
120
120
  let i_start = i_items_start + len_items;
121
121
  for (let i = 0; i < cols; i++) {
122
122
  const type = buf_data[i_start];
123
+ if (type === DdbType.compress)
124
+ throw new Error(t('{{form}}<{{type}}> 暂时不支持解析', { form: 'table', type: 'compress' }));
123
125
  let col = this.parse_vector(buf_data.subarray(i_start + 2), le, type);
124
126
  col.length += 2;
125
127
  col.name = colnames[i];
@@ -701,8 +703,16 @@ export class DdbObj {
701
703
  });
702
704
  return [8 * length, durations];
703
705
  }
706
+ case DdbType.compress:
707
+ return [
708
+ length,
709
+ new Uint8Array(buf.buffer.slice(buf.byteOffset, buf.byteOffset + length))
710
+ ];
704
711
  default:
705
- throw new Error(t('vector<{{type}}> 暂时不支持解析', { type: String(DdbType[type] || type) }));
712
+ throw new Error(t('{{form}}<{{type}}> 暂时不支持解析', {
713
+ form: 'vector',
714
+ type: String(DdbType[type] || type)
715
+ }));
706
716
  }
707
717
  }
708
718
  pack() {
@@ -933,6 +943,7 @@ export class DdbObj {
933
943
  case DdbType.uuid:
934
944
  case DdbType.ipaddr:
935
945
  case DdbType.int128:
946
+ case DdbType.compress:
936
947
  return [value];
937
948
  case DdbType.blob: {
938
949
  let bufs = new Array(length * 2);
@@ -994,11 +1005,7 @@ export class DdbObj {
994
1005
  const data = (() => {
995
1006
  switch (this.form) {
996
1007
  case DdbForm.scalar:
997
- // 如果类型为 string, 则不进行格式化处理
998
- if (this.type === DdbType.string)
999
- return this.value;
1000
- else
1001
- return format(this.type, this.value, this.le, options);
1008
+ return format(this.type, this.value, this.le, options);
1002
1009
  case DdbForm.vector:
1003
1010
  case DdbForm.pair:
1004
1011
  case DdbForm.set: {
@@ -1111,7 +1118,7 @@ export class DdbObj {
1111
1118
  return format_array(items, data.length > limit);
1112
1119
  }
1113
1120
  default: {
1114
- const limit = 50;
1121
+ const limit = this.type === DdbType.compress ? 5 : 50;
1115
1122
  let items = new Array(Math.min(limit, this.value.length));
1116
1123
  for (let i = 0; i < items.length; i++)
1117
1124
  items[i] = format(this.type, this.value[i], this.le, options);
@@ -1273,15 +1280,15 @@ export class DdbObj {
1273
1280
  return obj;
1274
1281
  }
1275
1282
  }
1276
- /** 整数一定用这个 number formatter, InspectOptions.decimals 不传也用这个 Integer must use this number formatter, InspectOptions.decimals also use this if not passed */
1283
+ /** 整数一定用这个 number formatter, InspectOptions.decimals 不传也用这个 */
1277
1284
  let default_formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
1278
1285
  let _decimals = 20;
1279
1286
  let _grouping = true;
1280
- /** 缓存,为了优化性能,通常 options.decimals 都是不变的 Cache, in order to optimize performance, usually options.decimals are unchanged */
1287
+ /** 缓存,为了优化性能,通常 options.decimals 都是不变的 */
1281
1288
  let _formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
1282
1289
  /** 用来处理时差 To deal with jet lag */
1283
1290
  let _datetime_formatter = new Intl.DateTimeFormat('zh-CN', { dateStyle: 'short', timeStyle: 'medium', timeZone: 'UTC', hour12: false });
1284
- /** 根据 DdbType 格式化单个元素 (value) 为字符串 Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
1291
+ /** 根据 DdbType 格式化单个元素 (value) 为字符串 */
1285
1292
  export function format(type, value, le, options = {}) {
1286
1293
  const { nullstr = false, colors = false, quote = false, grouping = true } = options;
1287
1294
  const formatter = (() => {