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/browser.d.ts +2 -0
- package/browser.js +17 -13
- package/browser.js.map +1 -1
- package/index.d.ts +2 -0
- package/index.js +17 -13
- 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 ?
|
|
@@ -2697,15 +2703,15 @@ export class DDB {
|
|
|
2697
2703
|
segments: [],
|
|
2698
2704
|
};
|
|
2699
2705
|
let schema;
|
|
2700
|
-
let first_message = true;
|
|
2701
2706
|
const { value: colnames } = await this.call('publishTable', [
|
|
2702
2707
|
'localhost',
|
|
2703
2708
|
new DdbInt(0),
|
|
2704
2709
|
this.streaming.table,
|
|
2705
2710
|
(this.streaming.action ||= `api_js_${new Date().getTime()}`),
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2711
|
+
...this.streaming?.filters?.column ? [
|
|
2712
|
+
new DdbVoid(),
|
|
2713
|
+
this.streaming.filters.column // filter
|
|
2714
|
+
] : []
|
|
2709
2715
|
], {
|
|
2710
2716
|
skip_connection_check: true,
|
|
2711
2717
|
// 先准备好收到 websocket message 的 callback
|
|
@@ -2715,12 +2721,10 @@ export class DDB {
|
|
|
2715
2721
|
const i_topic_end = buffer.indexOf(0, 17);
|
|
2716
2722
|
// 首个 message 一定是 table schema, 后续消息是 column 片段组成的 any vector
|
|
2717
2723
|
const data = DdbObj.parse(buffer.subarray(i_topic_end + 1), this.le);
|
|
2718
|
-
if (
|
|
2724
|
+
if (!schema) {
|
|
2719
2725
|
schema = data;
|
|
2720
|
-
first_message = false;
|
|
2721
2726
|
return;
|
|
2722
2727
|
}
|
|
2723
|
-
assert(schema, t('流数据订阅后一定先返回 schema'));
|
|
2724
2728
|
const { rows } = data.value[0];
|
|
2725
2729
|
win.rows += rows;
|
|
2726
2730
|
win.segments.push(data);
|