dolphindb 2.0.1030 → 2.0.1032

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
@@ -180,6 +180,8 @@ export interface InspectOptions extends UtilInspectOptions {
180
180
  colors?: boolean;
181
181
  /** `null` decimal places 小数位数 */
182
182
  decimals?: number;
183
+ /** `true` 决定格式化后的数据是否有千分位 */
184
+ grouping?: boolean;
183
185
  }
184
186
  /** 根据 DdbType 格式化单个元素 (value) 为字符串,空值返回 'null' 字符串 Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
185
187
  export declare function format(type: DdbType, value: DdbValue, le: boolean, options?: InspectOptions): string;
package/index.js CHANGED
@@ -1268,21 +1268,27 @@ export class DdbObj {
1268
1268
  /** 整数一定用这个 number formatter, InspectOptions.decimals 不传也用这个 */
1269
1269
  let default_formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
1270
1270
  let _decimals = 20;
1271
+ let _grouping = true;
1271
1272
  /** 缓存,为了优化性能,通常 options.decimals 都是不变的 */
1272
1273
  let _formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
1273
1274
  /** 用来处理时差 To deal with jet lag */
1274
1275
  let _datetime_formatter = new Intl.DateTimeFormat('zh-CN', { dateStyle: 'short', timeStyle: 'medium', timeZone: 'UTC' });
1275
1276
  /** 根据 DdbType 格式化单个元素 (value) 为字符串,空值返回 'null' 字符串 Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
1276
1277
  export function format(type, value, le, options = {}) {
1277
- const { decimals } = options;
1278
1278
  const formatter = (() => {
1279
- if (decimals === undefined || decimals === null)
1280
- return default_formatter;
1281
- if (decimals !== _decimals) {
1279
+ const { grouping = true } = options;
1280
+ const decimals = options.decimals ?? _decimals;
1281
+ if (decimals !== _decimals || grouping !== _grouping) {
1282
1282
  _decimals = decimals;
1283
- _formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: decimals, minimumFractionDigits: decimals });
1283
+ _grouping = grouping;
1284
+ default_formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20, useGrouping: grouping });
1285
+ _formatter = new Intl.NumberFormat('en-US', {
1286
+ maximumFractionDigits: decimals,
1287
+ minimumFractionDigits: decimals,
1288
+ useGrouping: grouping
1289
+ });
1284
1290
  }
1285
- return _formatter;
1291
+ return options.decimals === undefined || options.decimals === null ? default_formatter : _formatter;
1286
1292
  })();
1287
1293
  switch (type) {
1288
1294
  case DdbType.bool:
@@ -2696,15 +2702,15 @@ export class DDB {
2696
2702
  segments: [],
2697
2703
  };
2698
2704
  let schema;
2699
- let first_message = true;
2700
2705
  const { value: colnames } = await this.call('publishTable', [
2701
2706
  'localhost',
2702
2707
  new DdbInt(0),
2703
2708
  this.streaming.table,
2704
2709
  (this.streaming.action ||= `api_js_${new Date().getTime()}`),
2705
- // new DdbInt(-1), // offset
2706
- // filter
2707
- // allow exists
2710
+ ...this.streaming?.filters?.column ? [
2711
+ new DdbVoid(),
2712
+ this.streaming.filters.column // filter
2713
+ ] : []
2708
2714
  ], {
2709
2715
  skip_connection_check: true,
2710
2716
  // 先准备好收到 websocket message 的 callback
@@ -2714,12 +2720,10 @@ export class DDB {
2714
2720
  const i_topic_end = buffer.indexOf(0, 17);
2715
2721
  // 首个 message 一定是 table schema, 后续消息是 column 片段组成的 any vector
2716
2722
  const data = DdbObj.parse(buffer.subarray(i_topic_end + 1), this.le);
2717
- if (first_message) {
2723
+ if (!schema) {
2718
2724
  schema = data;
2719
- first_message = false;
2720
2725
  return;
2721
2726
  }
2722
- assert(schema, t('流数据订阅后一定先返回 schema'));
2723
2727
  const { rows } = data.value[0];
2724
2728
  win.rows += rows;
2725
2729
  win.segments.push(data);