dolphindb 2.0.1031 → 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: