dolphindb 2.0.905 → 2.0.907
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 +4 -2
- package/browser.js +91 -64
- package/browser.js.map +1 -1
- package/index.d.ts +10 -11
- package/index.js +97 -70
- package/index.js.map +1 -1
- package/package.json +5 -4
package/browser.d.ts
CHANGED
|
@@ -386,7 +386,8 @@ export declare function datehour2str(datehour: number | null, format?: string):
|
|
|
386
386
|
- str: timestamp string, 如果为空字符串或 'null' 会返回对应的空值 (nulls.int64)
|
|
387
387
|
timestamp string, If it is an empty string or 'null', it will return the corresponding empty value (nulls.int64)
|
|
388
388
|
- format?:
|
|
389
|
-
对应传入字符串的格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSS`
|
|
389
|
+
对应传入字符串的格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSS`
|
|
390
|
+
The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSS`
|
|
390
391
|
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
391
392
|
*/
|
|
392
393
|
export declare function str2timestamp(str: string, format?: string): bigint;
|
|
@@ -443,7 +444,8 @@ export interface StreamingData extends StreamingParams {
|
|
|
443
444
|
/** 每次接收到的 data 组成的数组 An array of data received each time */
|
|
444
445
|
segments: DdbObj<DdbVectorObj[]>[];
|
|
445
446
|
};
|
|
446
|
-
/** 成功订阅后,后续推送过来的 message 解析错误,则会设置 error 并调用 handler
|
|
447
|
+
/** 成功订阅后,后续推送过来的 message 解析错误,则会设置 error 并调用 handler
|
|
448
|
+
After successfully subscribed, if the subsequently pushed message is parsed incorrectly, the error will be set and the handler will be called. */
|
|
447
449
|
error?: Error;
|
|
448
450
|
}
|
|
449
451
|
export declare const winsize: 100000;
|
package/browser.js
CHANGED
|
@@ -1080,34 +1080,51 @@ export class DdbObj {
|
|
|
1080
1080
|
// append!(av, [1..500])
|
|
1081
1081
|
// ...
|
|
1082
1082
|
// av
|
|
1083
|
-
const
|
|
1083
|
+
const type_ = this.type - 64;
|
|
1084
1084
|
const limit = 10;
|
|
1085
|
-
let
|
|
1085
|
+
let array_items = new Array(Math.min(limit, this.rows));
|
|
1086
1086
|
let i_items = 0;
|
|
1087
1087
|
for (const { lengths, data } of this.value) {
|
|
1088
1088
|
let acc_len = 0;
|
|
1089
1089
|
for (const length of lengths) {
|
|
1090
|
-
let
|
|
1091
|
-
for (let i = 0; i <
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
x
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1090
|
+
let items = new Array(Math.min(limit, length));
|
|
1091
|
+
for (let i = 0; i < items.length; i++)
|
|
1092
|
+
switch (type_) {
|
|
1093
|
+
case DdbType.decimal32:
|
|
1094
|
+
case DdbType.decimal64:
|
|
1095
|
+
const x = data[acc_len + i];
|
|
1096
|
+
if (x === nulls.int64 /* && type_ === DdbType.decimal64 一定成立 */ ||
|
|
1097
|
+
x === nulls.int32 && type_ === DdbType.decimal32)
|
|
1098
|
+
return '';
|
|
1099
|
+
const { scale } = this.value;
|
|
1100
|
+
const s = String(x < 0 ? -x : x).padStart(scale, '0');
|
|
1101
|
+
const str = (x < 0 ? '-' : '') + (scale ? `${s.slice(0, -scale) || '0'}.${s.slice(-scale)}` : s);
|
|
1102
|
+
items[i] = options.colors ? green(str) : str;
|
|
1103
|
+
break;
|
|
1104
|
+
case DdbType.complex:
|
|
1105
|
+
case DdbType.point: {
|
|
1106
|
+
const index = acc_len + i;
|
|
1107
|
+
items[i] = format(type_, data.subarray(2 * index, 2 * (index + 1)), this.le, options);
|
|
1108
|
+
break;
|
|
1109
|
+
}
|
|
1110
|
+
case DdbType.uuid:
|
|
1111
|
+
case DdbType.int128:
|
|
1112
|
+
case DdbType.ipaddr: {
|
|
1113
|
+
const index = acc_len + i;
|
|
1114
|
+
items[i] = format(type_, data.subarray(16 * index, 16 * (index + 1)), this.le, options);
|
|
1115
|
+
break;
|
|
1116
|
+
}
|
|
1117
|
+
default:
|
|
1118
|
+
items[i] = format(type_, data[acc_len + i], this.le, options);
|
|
1119
|
+
break;
|
|
1101
1120
|
}
|
|
1102
|
-
|
|
1103
|
-
_items[i] = format(_type, data[acc_len + i], this.le, options);
|
|
1104
|
-
items[i_items++] = format_array(_items, length > limit);
|
|
1121
|
+
array_items[i_items++] = format_array(items, length > limit);
|
|
1105
1122
|
acc_len += length;
|
|
1106
1123
|
}
|
|
1107
1124
|
if (i_items >= limit)
|
|
1108
1125
|
break;
|
|
1109
1126
|
}
|
|
1110
|
-
return format_array(
|
|
1127
|
+
return format_array(array_items, this.rows > limit);
|
|
1111
1128
|
}
|
|
1112
1129
|
switch (this.type) {
|
|
1113
1130
|
case DdbType.symbol_extended: {
|
|
@@ -1493,7 +1510,7 @@ export function formati(obj, index, options = {}) {
|
|
|
1493
1510
|
// append!(av, [1..500])
|
|
1494
1511
|
// ...
|
|
1495
1512
|
// av
|
|
1496
|
-
const
|
|
1513
|
+
const type_ = obj.type - 64;
|
|
1497
1514
|
let offset = 0;
|
|
1498
1515
|
for (const { lengths, data, rows } of obj.value) {
|
|
1499
1516
|
let acc_len = 0;
|
|
@@ -1510,18 +1527,35 @@ export function formati(obj, index, options = {}) {
|
|
|
1510
1527
|
const limit = 10;
|
|
1511
1528
|
let items = new Array(Math.min(limit, length));
|
|
1512
1529
|
for (let i = 0; i < items.length; i++)
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
x
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1530
|
+
switch (type_) {
|
|
1531
|
+
case DdbType.decimal32:
|
|
1532
|
+
case DdbType.decimal64:
|
|
1533
|
+
const x = data[acc_len + i];
|
|
1534
|
+
if (x === nulls.int64 /* && type_ === DdbType.decimal64 一定成立 */ ||
|
|
1535
|
+
x === nulls.int32 && type_ === DdbType.decimal32)
|
|
1536
|
+
return '';
|
|
1537
|
+
const { scale } = obj.value;
|
|
1538
|
+
const s = String(x < 0 ? -x : x).padStart(scale, '0');
|
|
1539
|
+
const str = (x < 0 ? '-' : '') + (scale ? `${s.slice(0, -scale) || '0'}.${s.slice(-scale)}` : s);
|
|
1540
|
+
items[i] = options.colors ? green(str) : str;
|
|
1541
|
+
break;
|
|
1542
|
+
case DdbType.complex:
|
|
1543
|
+
case DdbType.point: {
|
|
1544
|
+
const index = acc_len + i;
|
|
1545
|
+
items[i] = format(type_, data.subarray(2 * index, 2 * (index + 1)), obj.le, options);
|
|
1546
|
+
break;
|
|
1547
|
+
}
|
|
1548
|
+
case DdbType.uuid:
|
|
1549
|
+
case DdbType.int128:
|
|
1550
|
+
case DdbType.ipaddr: {
|
|
1551
|
+
const index = acc_len + i;
|
|
1552
|
+
items[i] = format(type_, data.subarray(16 * index, 16 * (index + 1)), obj.le, options);
|
|
1553
|
+
break;
|
|
1554
|
+
}
|
|
1555
|
+
default:
|
|
1556
|
+
items[i] = format(type_, data[acc_len + i], obj.le, options);
|
|
1557
|
+
break;
|
|
1522
1558
|
}
|
|
1523
|
-
else
|
|
1524
|
-
items[i] = format(_type, data[acc_len + i], obj.le, options);
|
|
1525
1559
|
return (items.join(', ') + (length > limit ? ', ...' : '')).bracket('square');
|
|
1526
1560
|
}
|
|
1527
1561
|
}
|
|
@@ -1861,15 +1895,14 @@ export function date2ms(date) {
|
|
|
1861
1895
|
// 将 server 的本地时间 (以 ms 为单位,1970.01.01 00:00:00 作为零点) 当成是客户端这里的本地的时间,然后根据本地的时区信息转换为 utc 时间
|
|
1862
1896
|
// 本地的时区与实际的时间值相关,timezone offset 可能会受到夏令时 (DST) 的影响
|
|
1863
1897
|
// 得到的 utc 毫秒数交给 js date 或者 dayjs 去格式化
|
|
1898
|
+
if (date === null || date === nulls.int32)
|
|
1899
|
+
return null;
|
|
1864
1900
|
const ms = 1000 * 3600 * 24 * date;
|
|
1865
|
-
return
|
|
1866
|
-
null
|
|
1867
|
-
:
|
|
1868
|
-
1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1901
|
+
return 1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1869
1902
|
}
|
|
1870
1903
|
export function date2str(date, format = 'YYYY.MM.DD') {
|
|
1871
1904
|
return (date === null || date === nulls.int32) ?
|
|
1872
|
-
null
|
|
1905
|
+
'null'
|
|
1873
1906
|
:
|
|
1874
1907
|
dayjs(date2ms(date)).format(format);
|
|
1875
1908
|
}
|
|
@@ -1896,16 +1929,15 @@ export function time2ms(time) {
|
|
|
1896
1929
|
}
|
|
1897
1930
|
export function time2str(time, format = 'HH:mm:ss.SSS') {
|
|
1898
1931
|
return (time === null || time === nulls.int32) ?
|
|
1899
|
-
null
|
|
1932
|
+
'null'
|
|
1900
1933
|
:
|
|
1901
1934
|
dayjs(time2ms(time)).format(format);
|
|
1902
1935
|
}
|
|
1903
1936
|
export function minute2ms(minute) {
|
|
1937
|
+
if (minute === null || minute === nulls.int32)
|
|
1938
|
+
return null;
|
|
1904
1939
|
const ms = 60 * 1000 * minute;
|
|
1905
|
-
return
|
|
1906
|
-
null
|
|
1907
|
-
:
|
|
1908
|
-
1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1940
|
+
return 1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1909
1941
|
}
|
|
1910
1942
|
export function minute2str(minute, format = 'HH:mm[m]') {
|
|
1911
1943
|
return (minute === null || minute === nulls.int32) ?
|
|
@@ -1914,11 +1946,10 @@ export function minute2str(minute, format = 'HH:mm[m]') {
|
|
|
1914
1946
|
dayjs(minute2ms(minute)).format(format);
|
|
1915
1947
|
}
|
|
1916
1948
|
export function second2ms(second) {
|
|
1949
|
+
if (second === null || second === nulls.int32)
|
|
1950
|
+
return null;
|
|
1917
1951
|
const ms = 1000 * second;
|
|
1918
|
-
return
|
|
1919
|
-
null
|
|
1920
|
-
:
|
|
1921
|
-
1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1952
|
+
return 1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1922
1953
|
}
|
|
1923
1954
|
export function second2str(second, format = 'HH:mm:ss') {
|
|
1924
1955
|
return (second === null || second === nulls.int32) ?
|
|
@@ -1927,11 +1958,10 @@ export function second2str(second, format = 'HH:mm:ss') {
|
|
|
1927
1958
|
dayjs(second2ms(second)).format(format);
|
|
1928
1959
|
}
|
|
1929
1960
|
export function datetime2ms(datetime) {
|
|
1961
|
+
if (datetime === null || datetime === nulls.int32)
|
|
1962
|
+
return null;
|
|
1930
1963
|
const ms = 1000 * datetime;
|
|
1931
|
-
return
|
|
1932
|
-
null
|
|
1933
|
-
:
|
|
1934
|
-
1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1964
|
+
return 1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1935
1965
|
}
|
|
1936
1966
|
export function datetime2str(datetime, format = 'YYYY.MM.DD HH:mm:ss') {
|
|
1937
1967
|
return (datetime === null || datetime === nulls.int32) ?
|
|
@@ -1940,11 +1970,10 @@ export function datetime2str(datetime, format = 'YYYY.MM.DD HH:mm:ss') {
|
|
|
1940
1970
|
dayjs(datetime2ms(datetime)).format(format);
|
|
1941
1971
|
}
|
|
1942
1972
|
export function timestamp2ms(timestamp) {
|
|
1973
|
+
if (timestamp === null || timestamp === nulls.int64)
|
|
1974
|
+
return null;
|
|
1943
1975
|
const ms = Number(timestamp);
|
|
1944
|
-
return
|
|
1945
|
-
null
|
|
1946
|
-
:
|
|
1947
|
-
1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1976
|
+
return 1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1948
1977
|
}
|
|
1949
1978
|
/** format timestamp (bigint) to string
|
|
1950
1979
|
- timestamp: bigint value
|
|
@@ -1959,24 +1988,23 @@ export function timestamp2str(timestamp, format = 'YYYY.MM.DD HH:mm:ss.SSS') {
|
|
|
1959
1988
|
dayjs(timestamp2ms(timestamp)).format(format);
|
|
1960
1989
|
}
|
|
1961
1990
|
export function datehour2ms(datehour) {
|
|
1991
|
+
if (datehour === null || datehour === nulls.int32)
|
|
1992
|
+
return null;
|
|
1962
1993
|
const ms = 1000 * 3600 * datehour;
|
|
1963
|
-
return
|
|
1964
|
-
null
|
|
1965
|
-
:
|
|
1966
|
-
1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1994
|
+
return 1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1967
1995
|
}
|
|
1968
1996
|
export function datehour2str(datehour, format = 'YYYY.MM.DDTHH') {
|
|
1997
|
+
if (datehour === null || datehour === nulls.int32)
|
|
1998
|
+
return 'null';
|
|
1969
1999
|
const ms = 1000 * 3600 * datehour;
|
|
1970
|
-
return (
|
|
1971
|
-
'null'
|
|
1972
|
-
:
|
|
1973
|
-
dayjs(1000 * 60 * new Date(ms).getTimezoneOffset() + ms).format(format);
|
|
2000
|
+
return dayjs(1000 * 60 * new Date(ms).getTimezoneOffset() + ms).format(format);
|
|
1974
2001
|
}
|
|
1975
2002
|
/** parse timestamp string to bigint value
|
|
1976
2003
|
- str: timestamp string, 如果为空字符串或 'null' 会返回对应的空值 (nulls.int64)
|
|
1977
2004
|
timestamp string, If it is an empty string or 'null', it will return the corresponding empty value (nulls.int64)
|
|
1978
2005
|
- format?:
|
|
1979
|
-
对应传入字符串的格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSS`
|
|
2006
|
+
对应传入字符串的格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSS`
|
|
2007
|
+
The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSS`
|
|
1980
2008
|
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
1981
2009
|
*/
|
|
1982
2010
|
export function str2timestamp(str, format = 'YYYY.MM.DD HH:mm:ss.SSS') {
|
|
@@ -2006,11 +2034,10 @@ export function nanotime2str(nanotime, format = 'HH:mm:ss.SSSSSSSSS') {
|
|
|
2006
2034
|
String(nanotime % 1000000000n).padStart(9, '0'));
|
|
2007
2035
|
}
|
|
2008
2036
|
export function nanotimestamp2ns(nanotimestamp) {
|
|
2037
|
+
if (nanotimestamp === null || nanotimestamp === nulls.int64)
|
|
2038
|
+
return null;
|
|
2009
2039
|
const ms = Number(nanotimestamp / 1000000n);
|
|
2010
|
-
return (
|
|
2011
|
-
null
|
|
2012
|
-
:
|
|
2013
|
-
BigInt(1000 * 60 * new Date(ms).getTimezoneOffset()) * 1000000n + nanotimestamp;
|
|
2040
|
+
return BigInt(1000 * 60 * new Date(ms).getTimezoneOffset()) * 1000000n + nanotimestamp;
|
|
2014
2041
|
}
|
|
2015
2042
|
/** format nanotimestamp value (bigint) to string
|
|
2016
2043
|
- nanotimestamp: bigint value
|