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/browser.d.ts +2 -0
- package/browser.js +12 -6
- package/browser.js.map +1 -1
- package/index.d.ts +2 -0
- package/index.js +12 -6
- package/index.js.map +1 -1
- package/package.json +1 -1
package/browser.d.ts
CHANGED
|
@@ -189,6 +189,8 @@ export interface InspectOptions {
|
|
|
189
189
|
nullstr?: boolean;
|
|
190
190
|
/** `false` 决定 string, symbol, char 类型是否加引号 */
|
|
191
191
|
quote?: boolean;
|
|
192
|
+
/** `true` 决定格式化后的数据是否有千分位 */
|
|
193
|
+
grouping?: boolean;
|
|
192
194
|
}
|
|
193
195
|
/** 根据 DdbType 格式化单个元素 (value) 为字符串 Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
|
|
194
196
|
export declare function format(type: DdbType, value: DdbValue, le: boolean, options?: InspectOptions): string;
|
package/browser.js
CHANGED
|
@@ -1267,21 +1267,27 @@ export class DdbObj {
|
|
|
1267
1267
|
/** 整数一定用这个 number formatter, InspectOptions.decimals 不传也用这个 Integer must use this number formatter, InspectOptions.decimals also use this if not passed */
|
|
1268
1268
|
let default_formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
|
|
1269
1269
|
let _decimals = 20;
|
|
1270
|
+
let _grouping = true;
|
|
1270
1271
|
/** 缓存,为了优化性能,通常 options.decimals 都是不变的 Cache, in order to optimize performance, usually options.decimals are unchanged */
|
|
1271
1272
|
let _formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
|
|
1272
1273
|
/** 用来处理时差 To deal with jet lag */
|
|
1273
1274
|
let _datetime_formatter = new Intl.DateTimeFormat('zh-CN', { dateStyle: 'short', timeStyle: 'medium', timeZone: 'UTC' });
|
|
1274
1275
|
/** 根据 DdbType 格式化单个元素 (value) 为字符串 Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
|
|
1275
1276
|
export function format(type, value, le, options = {}) {
|
|
1276
|
-
const {
|
|
1277
|
+
const { nullstr = false, colors = false, quote = false, grouping = true } = options;
|
|
1277
1278
|
const formatter = (() => {
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
if (decimals !== _decimals) {
|
|
1279
|
+
const decimals = options.decimals ?? _decimals;
|
|
1280
|
+
if (decimals !== _decimals || grouping !== _grouping) {
|
|
1281
1281
|
_decimals = decimals;
|
|
1282
|
-
|
|
1282
|
+
_grouping = grouping;
|
|
1283
|
+
default_formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20, useGrouping: grouping });
|
|
1284
|
+
_formatter = new Intl.NumberFormat('en-US', {
|
|
1285
|
+
maximumFractionDigits: decimals,
|
|
1286
|
+
minimumFractionDigits: decimals,
|
|
1287
|
+
useGrouping: grouping
|
|
1288
|
+
});
|
|
1283
1289
|
}
|
|
1284
|
-
return _formatter;
|
|
1290
|
+
return options.decimals === undefined || options.decimals === null ? default_formatter : _formatter;
|
|
1285
1291
|
})();
|
|
1286
1292
|
function get_nullstr() {
|
|
1287
1293
|
return nullstr ?
|