dolphindb 3.0.40 → 3.0.41
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/README.md +4 -4
- package/README.zh.md +4 -4
- package/browser.d.ts +8 -6
- package/browser.js +11 -14
- package/browser.js.map +1 -1
- package/docs.d.ts +1 -1
- package/i18n/index.d.ts +1 -1
- package/index.d.ts +6 -7
- package/index.js +11 -14
- package/index.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -494,11 +494,11 @@ export interface StreamingMessage <TRows = any> extends StreamingParams {
|
|
|
494
494
|
/** The establishment of the connection starts offset = 0, and gradually increases as the window moves */
|
|
495
495
|
offset: number
|
|
496
496
|
|
|
497
|
-
/**
|
|
498
|
-
|
|
497
|
+
/** Historical data */
|
|
498
|
+
data: TRows[]
|
|
499
499
|
|
|
500
|
-
/** An array of
|
|
501
|
-
|
|
500
|
+
/** An array of obj received each time */
|
|
501
|
+
objs: DdbObj<DdbVectorObj[]>[]
|
|
502
502
|
}
|
|
503
503
|
|
|
504
504
|
/** After successfully subscribed, if the subsequently pushed message is parsed incorrectly, the error will be set and the handler will be called. */
|
package/README.zh.md
CHANGED
|
@@ -577,11 +577,11 @@ export interface StreamingMessage <TRows = any> extends StreamingParams {
|
|
|
577
577
|
/** 建立连接开始 offset = 0, 随着 window 的移动逐渐增加 */
|
|
578
578
|
offset: number
|
|
579
579
|
|
|
580
|
-
/**
|
|
581
|
-
|
|
580
|
+
/** 历史数据 */
|
|
581
|
+
data: TRows[]
|
|
582
582
|
|
|
583
|
-
/** 每次接收到的
|
|
584
|
-
|
|
583
|
+
/** 每次接收到的 obj 组成的数组 */
|
|
584
|
+
objs: DdbObj<DdbVectorObj[]>[]
|
|
585
585
|
}
|
|
586
586
|
|
|
587
587
|
/** 成功订阅后,后续推送过来的 message 解析错误,则会设置 error 并调用 handler */
|
package/browser.d.ts
CHANGED
|
@@ -384,7 +384,7 @@ export declare class DdbObj<TValue extends DdbValue = DdbValue> {
|
|
|
384
384
|
}
|
|
385
385
|
/** 根据 DdbType 获取其名称,array vector type 自动在后面加上 [] */
|
|
386
386
|
export declare function get_type_name(type: DdbType): string;
|
|
387
|
-
export declare function is_decimal_type(type: DdbType):
|
|
387
|
+
export declare function is_decimal_type(type: DdbType): type is DdbType.decimal32 | DdbType.decimal64 | DdbType.decimal128;
|
|
388
388
|
export declare function is_decimal_null_value(type: DdbType, value: number | bigint): boolean;
|
|
389
389
|
export declare function get_duration_unit(code: number): string;
|
|
390
390
|
export interface InspectOptions {
|
|
@@ -398,6 +398,8 @@ export interface InspectOptions {
|
|
|
398
398
|
quote?: boolean;
|
|
399
399
|
/** `true` 决定格式化后的数据是否有千分位 */
|
|
400
400
|
grouping?: boolean;
|
|
401
|
+
/** timestamp 类型转换为字符串表示时显示到秒还是毫秒 */
|
|
402
|
+
timestamp?: 's' | 'ms';
|
|
401
403
|
}
|
|
402
404
|
/** 根据 DdbType 格式化单个元素 (value) 为字符串 */
|
|
403
405
|
export declare function format(type: DdbType, value: DdbValue, le: boolean, options?: InspectOptions): string;
|
|
@@ -406,8 +408,10 @@ export declare function formati(obj: DdbVectorObj, index: number, options?: Insp
|
|
|
406
408
|
export interface ConvertOptions {
|
|
407
409
|
/** `'string'` blob 类型数据的格式 */
|
|
408
410
|
blob?: 'string' | 'binary';
|
|
411
|
+
/** timestamp 类型转换为字符串表示时显示到秒还是毫秒 */
|
|
412
|
+
timestamp?: 's' | 'ms';
|
|
409
413
|
}
|
|
410
|
-
export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob }?: ConvertOptions): string | number | bigint | boolean | Uint8Array | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | DdbDecimal32VectorValue | Int32Array | DdbDecimal64VectorValue | BigInt64Array | DdbDecimal128VectorValue | BigInt128Array | DdbSymbolExtendedValue | string[] | Int8Array | Int16Array | Float32Array | Float64Array | DdbArrayVectorValue | DdbMatrixValue | Uint8Array[] | DdbObj<DdbValue>[] | DdbDurationVectorValue | number[] | DdbTensorValue | DdbChartValue;
|
|
414
|
+
export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, timestamp }?: ConvertOptions): string | number | bigint | boolean | Uint8Array | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | DdbDecimal32VectorValue | Int32Array | DdbDecimal64VectorValue | BigInt64Array | DdbDecimal128VectorValue | BigInt128Array | DdbSymbolExtendedValue | string[] | Int8Array | Int16Array | Float32Array | Float64Array | DdbArrayVectorValue | DdbMatrixValue | Uint8Array[] | DdbObj<DdbValue>[] | DdbDurationVectorValue | number[] | DdbTensorValue | DdbChartValue;
|
|
411
415
|
/** 转换一个向量到 js 原生数组 */
|
|
412
416
|
export declare function converts(type: DdbType, value: DdbVectorValue, rows: number, le: boolean, options?: ConvertOptions): any[];
|
|
413
417
|
export declare class DdbVoid extends DdbObj<undefined> {
|
|
@@ -571,10 +575,8 @@ export interface StreamingMessage<TRows = any> extends StreamingParams {
|
|
|
571
575
|
window: {
|
|
572
576
|
/** 建立连接开始 offset = 0, 随着 window 的移动逐渐增加 The establishment of the connection starts offset = 0, and gradually increases as the window moves */
|
|
573
577
|
offset: number;
|
|
574
|
-
/**
|
|
575
|
-
|
|
576
|
-
/** 每次接收到的 data 组成的数组 An array of data received each time */
|
|
577
|
-
segments: DdbTableData<TRows>[];
|
|
578
|
+
/** 历史数据 Historical data */
|
|
579
|
+
data: TRows[];
|
|
578
580
|
/** 每次接收到的 obj 组成的数组 An array of obj received each time */
|
|
579
581
|
objs: DdbObj<DdbVectorObj[]>[];
|
|
580
582
|
};
|
package/browser.js
CHANGED
|
@@ -1670,7 +1670,7 @@ let _formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
|
|
|
1670
1670
|
let _datetime_formatter = new Intl.DateTimeFormat('zh-CN', { dateStyle: 'short', timeStyle: 'medium', timeZone: 'UTC', hour12: false });
|
|
1671
1671
|
/** 根据 DdbType 格式化单个元素 (value) 为字符串 */
|
|
1672
1672
|
export function format(type, value, le, options = {}) {
|
|
1673
|
-
const { nullstr = false, colors = false, quote = false, grouping = true } = options;
|
|
1673
|
+
const { nullstr = false, colors = false, quote = false, grouping = true, timestamp = 'ms' } = options;
|
|
1674
1674
|
const formatter = (() => {
|
|
1675
1675
|
const decimals = options.decimals ?? _decimals;
|
|
1676
1676
|
if (decimals !== _decimals || grouping !== _grouping) {
|
|
@@ -1698,7 +1698,7 @@ export function format(type, value, le, options = {}) {
|
|
|
1698
1698
|
let str;
|
|
1699
1699
|
// formatter 可能会在 value 不属于 new Date() 有效值时,调用 抛出错误,这里统一处理
|
|
1700
1700
|
try {
|
|
1701
|
-
str = formatter(value);
|
|
1701
|
+
str = formatter(value, (type === DdbType.timestamp && timestamp === 's') ? 'YYYY.MM.DD HH:mm:ss' : undefined);
|
|
1702
1702
|
}
|
|
1703
1703
|
catch (error) {
|
|
1704
1704
|
if (error instanceof RangeError)
|
|
@@ -1957,7 +1957,7 @@ export function formati(obj, index, options = {}) {
|
|
|
1957
1957
|
}
|
|
1958
1958
|
}
|
|
1959
1959
|
}
|
|
1960
|
-
export function convert(type, value, le, { blob = 'string' } = {}) {
|
|
1960
|
+
export function convert(type, value, le, { blob = 'string', timestamp = 'ms' } = {}) {
|
|
1961
1961
|
switch (type) {
|
|
1962
1962
|
case DdbType.void:
|
|
1963
1963
|
return value === DdbVoidType.null ? null : undefined;
|
|
@@ -2012,7 +2012,7 @@ export function convert(type, value, le, { blob = 'string' } = {}) {
|
|
|
2012
2012
|
case DdbType.decimal32:
|
|
2013
2013
|
case DdbType.decimal64:
|
|
2014
2014
|
case DdbType.decimal128:
|
|
2015
|
-
return format(type, value, le, { colors: false });
|
|
2015
|
+
return format(type, value, le, { colors: false, timestamp });
|
|
2016
2016
|
default:
|
|
2017
2017
|
throw new Error(String(DdbType[type] || type) + t(' 暂时不支持转换为 js 对象'));
|
|
2018
2018
|
}
|
|
@@ -3283,8 +3283,7 @@ export class DDB {
|
|
|
3283
3283
|
let first = true;
|
|
3284
3284
|
let win = {
|
|
3285
3285
|
offset: 0,
|
|
3286
|
-
|
|
3287
|
-
segments: [],
|
|
3286
|
+
data: [],
|
|
3288
3287
|
objs: []
|
|
3289
3288
|
};
|
|
3290
3289
|
let schema;
|
|
@@ -3338,19 +3337,17 @@ export class DDB {
|
|
|
3338
3337
|
data: seq(rows, i => zip_object(columns, seq(columns.length, j => _data[j][i])))
|
|
3339
3338
|
};
|
|
3340
3339
|
}
|
|
3341
|
-
|
|
3342
|
-
win.segments.push(data);
|
|
3340
|
+
data.data.forEach(row => { win.data.push(row); });
|
|
3343
3341
|
win.objs.push(obj);
|
|
3344
|
-
if (win.
|
|
3342
|
+
if (win.data.length >= winsize * 2 && win.objs.length >= 2) {
|
|
3345
3343
|
let winsize_ = 0;
|
|
3346
|
-
let i = win.
|
|
3344
|
+
let i = win.objs.length - 1;
|
|
3347
3345
|
// 往前移动至首个累计 winsize_ 超过 winsize 的位置
|
|
3348
3346
|
for (; winsize_ < winsize; i--)
|
|
3349
|
-
winsize_ += win.
|
|
3350
|
-
win.
|
|
3347
|
+
winsize_ += win.objs[i].value[0].rows;
|
|
3348
|
+
win.offset += win.data.length - winsize_;
|
|
3349
|
+
win.data = win.data.slice(-winsize_);
|
|
3351
3350
|
win.objs = win.objs.slice(i);
|
|
3352
|
-
win.offset += win.rows - winsize_;
|
|
3353
|
-
win.rows = winsize_;
|
|
3354
3351
|
}
|
|
3355
3352
|
}
|
|
3356
3353
|
this.streaming.handler({
|