dolphindb 2.0.905 → 2.0.906
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 +72 -59
- package/browser.js.map +1 -1
- package/index.d.ts +10 -11
- package/index.js +78 -65
- package/index.js.map +1 -1
- package/package.json +5 -4
package/index.d.ts
CHANGED
|
@@ -399,10 +399,11 @@ export declare function nanotimestamp2str(nanotimestamp: bigint | null, format?:
|
|
|
399
399
|
- str: nano timestamp string, 如果为空字符串或 'null' 会返回对应的空值 (nulls.int64)
|
|
400
400
|
nano timestamp string, If it is an empty string or 'null', it will return the corresponding empty value (nulls.int64)
|
|
401
401
|
- format?:
|
|
402
|
-
对应传入字符串的格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
|
|
403
|
-
秒的格式为 ss (必须包含); 纳秒的格式为 SSSSSSSSS (必须包含)
|
|
402
|
+
对应传入字符串的格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
|
|
403
|
+
秒的格式为 ss (必须包含); 纳秒的格式为 SSSSSSSSS (必须包含)
|
|
404
404
|
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
405
|
-
|
|
405
|
+
The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
|
|
406
|
+
Seconds are in the format ss (must be included); nanoseconds are in the format SSSSSSSSS (must be included) */
|
|
406
407
|
export declare function str2nanotimestamp(str: string, format?: string): bigint;
|
|
407
408
|
export declare function ipaddr2str(buffer: Uint8Array, le?: boolean, ipv6?: boolean): string;
|
|
408
409
|
export declare function uuid2str(buffer: Uint8Array, le?: boolean): string;
|
|
@@ -413,10 +414,8 @@ export interface StreamingParams {
|
|
|
413
414
|
handler(message: StreamingData): any;
|
|
414
415
|
}
|
|
415
416
|
export interface StreamingData extends StreamingParams {
|
|
416
|
-
/**
|
|
417
|
-
|
|
418
|
-
std::chrono::system_clock::now().time_since_epoch() / std::chrono::nanoseconds(1)
|
|
419
|
-
*/
|
|
417
|
+
/** server 发送消息的时间 (nano seconds since epoch) The time the server sent the message (nano seconds since epoch)
|
|
418
|
+
std::chrono::system_clock::now().time_since_epoch() / std::chrono::nanoseconds(1) */
|
|
420
419
|
time: bigint;
|
|
421
420
|
/** message id */
|
|
422
421
|
id: bigint;
|
|
@@ -462,11 +461,11 @@ export declare class DDB {
|
|
|
462
461
|
le: boolean;
|
|
463
462
|
/** little endian (client) */
|
|
464
463
|
static le_client: boolean;
|
|
465
|
-
/** 是否在建立连接后自动登录,默认 true */
|
|
464
|
+
/** 是否在建立连接后自动登录,默认 true Whether to automatically log in after the connection is established, the default is true */
|
|
466
465
|
autologin: boolean;
|
|
467
|
-
/** DolphinDB 登录用户名 */
|
|
466
|
+
/** DolphinDB 登录用户名 DolphinDB username */
|
|
468
467
|
username: string;
|
|
469
|
-
/** DolphinDB 登录密码 */
|
|
468
|
+
/** DolphinDB 登录密码 DolphinDB password */
|
|
470
469
|
password: string;
|
|
471
470
|
/** python session flag (2048) */
|
|
472
471
|
python: boolean;
|
|
@@ -514,7 +513,7 @@ export declare class DDB {
|
|
|
514
513
|
});
|
|
515
514
|
private on_message;
|
|
516
515
|
/** 建立实际的 WebSocket 连接到 URL 对应的 DolphinDB Establish a actual websocket connection to the DolphindB corresponding to the URL
|
|
517
|
-
是幂等的,调用后会确保已连接到数据库 (确保 websocket.readyState 为 open),否则报错
|
|
516
|
+
是幂等的,调用后会确保已连接到数据库 (确保 websocket.readyState 为 open),否则报错 After calling, it will ensure that it has been connected to the database (ensure that websocket.ReadyState is open), otherwise an error will be reported
|
|
518
517
|
this.autologin 为 true 时自动登录 this.autologin automatically log in when it is true */
|
|
519
518
|
connect(): Promise<void>;
|
|
520
519
|
get_rpc_options({ urgent, secondary, async: _async, pickle, clear, api, compress, cancellable, priority, parallelism, root_id, limit, }?: {
|
package/index.js
CHANGED
|
@@ -1082,7 +1082,7 @@ export class DdbObj {
|
|
|
1082
1082
|
// append!(av, [1..500])
|
|
1083
1083
|
// ...
|
|
1084
1084
|
// av
|
|
1085
|
-
const
|
|
1085
|
+
const type_ = this.type - 64;
|
|
1086
1086
|
const limit = 10;
|
|
1087
1087
|
let items = new Array(Math.min(limit, this.rows));
|
|
1088
1088
|
let i_items = 0;
|
|
@@ -1091,18 +1091,28 @@ export class DdbObj {
|
|
|
1091
1091
|
for (const length of lengths) {
|
|
1092
1092
|
let _items = new Array(Math.min(limit, length));
|
|
1093
1093
|
for (let i = 0; i < _items.length; i++)
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
x
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1094
|
+
switch (type_) {
|
|
1095
|
+
case DdbType.decimal32:
|
|
1096
|
+
case DdbType.decimal64:
|
|
1097
|
+
const x = data[acc_len + i];
|
|
1098
|
+
if (x === nulls.int64 /* && _type === DdbType.decimal64 一定成立 */ ||
|
|
1099
|
+
x === nulls.int32 && type_ === DdbType.decimal32)
|
|
1100
|
+
return '';
|
|
1101
|
+
const { scale } = this.value;
|
|
1102
|
+
const s = String(x < 0 ? -x : x).padStart(scale, '0');
|
|
1103
|
+
const str = (x < 0 ? '-' : '') + (scale ? `${s.slice(0, -scale) || '0'}.${s.slice(-scale)}` : s);
|
|
1104
|
+
_items[i] = options.colors ? str.green : str;
|
|
1105
|
+
break;
|
|
1106
|
+
case DdbType.complex:
|
|
1107
|
+
case DdbType.point: {
|
|
1108
|
+
const index = acc_len + i;
|
|
1109
|
+
_items[i] = format(type_, data.subarray(2 * index, 2 * (index + 1)), this.le, options);
|
|
1110
|
+
break;
|
|
1111
|
+
}
|
|
1112
|
+
default:
|
|
1113
|
+
_items[i] = format(type_, data[acc_len + i], this.le, options);
|
|
1114
|
+
break;
|
|
1103
1115
|
}
|
|
1104
|
-
else
|
|
1105
|
-
_items[i] = format(_type, data[acc_len + i], this.le, options);
|
|
1106
1116
|
items[i_items++] = format_array(_items, length > limit);
|
|
1107
1117
|
acc_len += length;
|
|
1108
1118
|
}
|
|
@@ -1482,7 +1492,7 @@ export function formati(obj, index, options = {}) {
|
|
|
1482
1492
|
// append!(av, [1..500])
|
|
1483
1493
|
// ...
|
|
1484
1494
|
// av
|
|
1485
|
-
const
|
|
1495
|
+
const type_ = obj.type - 64;
|
|
1486
1496
|
let offset = 0;
|
|
1487
1497
|
for (const { lengths, data, rows } of obj.value) {
|
|
1488
1498
|
let acc_len = 0;
|
|
@@ -1499,18 +1509,28 @@ export function formati(obj, index, options = {}) {
|
|
|
1499
1509
|
const limit = 10;
|
|
1500
1510
|
let items = new Array(Math.min(limit, length));
|
|
1501
1511
|
for (let i = 0; i < items.length; i++)
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
x
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1512
|
+
switch (type_) {
|
|
1513
|
+
case DdbType.decimal32:
|
|
1514
|
+
case DdbType.decimal64:
|
|
1515
|
+
const x = data[acc_len + i];
|
|
1516
|
+
if (x === nulls.int64 /* && _type === DdbType.decimal64 一定成立 */ ||
|
|
1517
|
+
x === nulls.int32 && type_ === DdbType.decimal32)
|
|
1518
|
+
return '';
|
|
1519
|
+
const { scale } = obj.value;
|
|
1520
|
+
const s = String(x < 0 ? -x : x).padStart(scale, '0');
|
|
1521
|
+
const str = (x < 0 ? '-' : '') + (scale ? `${s.slice(0, -scale) || '0'}.${s.slice(-scale)}` : s);
|
|
1522
|
+
items[i] = options.colors ? str.green : str;
|
|
1523
|
+
break;
|
|
1524
|
+
case DdbType.complex:
|
|
1525
|
+
case DdbType.point: {
|
|
1526
|
+
const index = acc_len + i;
|
|
1527
|
+
items[i] = format(type_, data.subarray(2 * index, 2 * (index + 1)), obj.le, options);
|
|
1528
|
+
break;
|
|
1529
|
+
}
|
|
1530
|
+
default:
|
|
1531
|
+
items[i] = format(type_, data[acc_len + i], obj.le, options);
|
|
1532
|
+
break;
|
|
1511
1533
|
}
|
|
1512
|
-
else
|
|
1513
|
-
items[i] = format(_type, data[acc_len + i], obj.le, options);
|
|
1514
1534
|
return (items.join(', ') + (length > limit ? ', ...' : '')).bracket('square');
|
|
1515
1535
|
}
|
|
1516
1536
|
}
|
|
@@ -1848,15 +1868,14 @@ export function date2ms(date) {
|
|
|
1848
1868
|
// 将 server 的本地时间 (以 ms 为单位,1970.01.01 00:00:00 作为零点) 当成是客户端这里的本地的时间,然后根据本地的时区信息转换为 utc 时间
|
|
1849
1869
|
// 本地的时区与实际的时间值相关,timezone offset 可能会受到夏令时 (DST) 的影响
|
|
1850
1870
|
// 得到的 utc 毫秒数交给 js date 或者 dayjs 去格式化
|
|
1871
|
+
if (date === null || date === nulls.int32)
|
|
1872
|
+
return null;
|
|
1851
1873
|
const ms = 1000 * 3600 * 24 * date;
|
|
1852
|
-
return
|
|
1853
|
-
null
|
|
1854
|
-
:
|
|
1855
|
-
1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1874
|
+
return 1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1856
1875
|
}
|
|
1857
1876
|
export function date2str(date, format = 'YYYY.MM.DD') {
|
|
1858
1877
|
return (date === null || date === nulls.int32) ?
|
|
1859
|
-
null
|
|
1878
|
+
'null'
|
|
1860
1879
|
:
|
|
1861
1880
|
dayjs(date2ms(date)).format(format);
|
|
1862
1881
|
}
|
|
@@ -1883,16 +1902,15 @@ export function time2ms(time) {
|
|
|
1883
1902
|
}
|
|
1884
1903
|
export function time2str(time, format = 'HH:mm:ss.SSS') {
|
|
1885
1904
|
return (time === null || time === nulls.int32) ?
|
|
1886
|
-
null
|
|
1905
|
+
'null'
|
|
1887
1906
|
:
|
|
1888
1907
|
dayjs(time2ms(time)).format(format);
|
|
1889
1908
|
}
|
|
1890
1909
|
export function minute2ms(minute) {
|
|
1910
|
+
if (minute === null || minute === nulls.int32)
|
|
1911
|
+
return null;
|
|
1891
1912
|
const ms = 60 * 1000 * minute;
|
|
1892
|
-
return
|
|
1893
|
-
null
|
|
1894
|
-
:
|
|
1895
|
-
1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1913
|
+
return 1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1896
1914
|
}
|
|
1897
1915
|
export function minute2str(minute, format = 'HH:mm[m]') {
|
|
1898
1916
|
return (minute === null || minute === nulls.int32) ?
|
|
@@ -1901,11 +1919,10 @@ export function minute2str(minute, format = 'HH:mm[m]') {
|
|
|
1901
1919
|
dayjs(minute2ms(minute)).format(format);
|
|
1902
1920
|
}
|
|
1903
1921
|
export function second2ms(second) {
|
|
1922
|
+
if (second === null || second === nulls.int32)
|
|
1923
|
+
return null;
|
|
1904
1924
|
const ms = 1000 * second;
|
|
1905
|
-
return
|
|
1906
|
-
null
|
|
1907
|
-
:
|
|
1908
|
-
1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1925
|
+
return 1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1909
1926
|
}
|
|
1910
1927
|
export function second2str(second, format = 'HH:mm:ss') {
|
|
1911
1928
|
return (second === null || second === nulls.int32) ?
|
|
@@ -1914,11 +1931,10 @@ export function second2str(second, format = 'HH:mm:ss') {
|
|
|
1914
1931
|
dayjs(second2ms(second)).format(format);
|
|
1915
1932
|
}
|
|
1916
1933
|
export function datetime2ms(datetime) {
|
|
1934
|
+
if (datetime === null || datetime === nulls.int32)
|
|
1935
|
+
return null;
|
|
1917
1936
|
const ms = 1000 * datetime;
|
|
1918
|
-
return
|
|
1919
|
-
null
|
|
1920
|
-
:
|
|
1921
|
-
1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1937
|
+
return 1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1922
1938
|
}
|
|
1923
1939
|
export function datetime2str(datetime, format = 'YYYY.MM.DD HH:mm:ss') {
|
|
1924
1940
|
return (datetime === null || datetime === nulls.int32) ?
|
|
@@ -1927,11 +1943,10 @@ export function datetime2str(datetime, format = 'YYYY.MM.DD HH:mm:ss') {
|
|
|
1927
1943
|
dayjs(datetime2ms(datetime)).format(format);
|
|
1928
1944
|
}
|
|
1929
1945
|
export function timestamp2ms(timestamp) {
|
|
1946
|
+
if (timestamp === null || timestamp === nulls.int64)
|
|
1947
|
+
return null;
|
|
1930
1948
|
const ms = Number(timestamp);
|
|
1931
|
-
return
|
|
1932
|
-
null
|
|
1933
|
-
:
|
|
1934
|
-
1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1949
|
+
return 1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1935
1950
|
}
|
|
1936
1951
|
/** format timestamp (bigint) to string
|
|
1937
1952
|
- timestamp: bigint value
|
|
@@ -1946,18 +1961,16 @@ export function timestamp2str(timestamp, format = 'YYYY.MM.DD HH:mm:ss.SSS') {
|
|
|
1946
1961
|
dayjs(timestamp2ms(timestamp)).format(format);
|
|
1947
1962
|
}
|
|
1948
1963
|
export function datehour2ms(datehour) {
|
|
1964
|
+
if (datehour === null || datehour === nulls.int32)
|
|
1965
|
+
return null;
|
|
1949
1966
|
const ms = 1000 * 3600 * datehour;
|
|
1950
|
-
return
|
|
1951
|
-
null
|
|
1952
|
-
:
|
|
1953
|
-
1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1967
|
+
return 1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
|
|
1954
1968
|
}
|
|
1955
1969
|
export function datehour2str(datehour, format = 'YYYY.MM.DDTHH') {
|
|
1970
|
+
if (datehour === null || datehour === nulls.int32)
|
|
1971
|
+
return 'null';
|
|
1956
1972
|
const ms = 1000 * 3600 * datehour;
|
|
1957
|
-
return (
|
|
1958
|
-
'null'
|
|
1959
|
-
:
|
|
1960
|
-
dayjs(1000 * 60 * new Date(ms).getTimezoneOffset() + ms).format(format);
|
|
1973
|
+
return dayjs(1000 * 60 * new Date(ms).getTimezoneOffset() + ms).format(format);
|
|
1961
1974
|
}
|
|
1962
1975
|
/** parse timestamp string to bigint value
|
|
1963
1976
|
- str: timestamp string, 如果为空字符串或 'null' 会返回对应的空值 (nulls.int64)
|
|
@@ -1994,11 +2007,10 @@ export function nanotime2str(nanotime, format = 'HH:mm:ss.SSSSSSSSS') {
|
|
|
1994
2007
|
String(nanotime % 1000000000n).padStart(9, '0'));
|
|
1995
2008
|
}
|
|
1996
2009
|
export function nanotimestamp2ns(nanotimestamp) {
|
|
2010
|
+
if (nanotimestamp === null || nanotimestamp === nulls.int64)
|
|
2011
|
+
return null;
|
|
1997
2012
|
const ms = Number(nanotimestamp / 1000000n);
|
|
1998
|
-
return (
|
|
1999
|
-
null
|
|
2000
|
-
:
|
|
2001
|
-
BigInt(1000 * 60 * new Date(ms).getTimezoneOffset()) * 1000000n + nanotimestamp;
|
|
2013
|
+
return BigInt(1000 * 60 * new Date(ms).getTimezoneOffset()) * 1000000n + nanotimestamp;
|
|
2002
2014
|
}
|
|
2003
2015
|
/** format nanotimestamp value (bigint) to string
|
|
2004
2016
|
- nanotimestamp: bigint value
|
|
@@ -2037,10 +2049,11 @@ export function nanotimestamp2str(nanotimestamp, format = 'YYYY.MM.DD HH:mm:ss.S
|
|
|
2037
2049
|
- str: nano timestamp string, 如果为空字符串或 'null' 会返回对应的空值 (nulls.int64)
|
|
2038
2050
|
nano timestamp string, If it is an empty string or 'null', it will return the corresponding empty value (nulls.int64)
|
|
2039
2051
|
- format?:
|
|
2040
|
-
对应传入字符串的格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
|
|
2041
|
-
秒的格式为 ss (必须包含); 纳秒的格式为 SSSSSSSSS (必须包含)
|
|
2052
|
+
对应传入字符串的格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
|
|
2053
|
+
秒的格式为 ss (必须包含); 纳秒的格式为 SSSSSSSSS (必须包含)
|
|
2042
2054
|
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
2043
|
-
|
|
2055
|
+
The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
|
|
2056
|
+
Seconds are in the format ss (must be included); nanoseconds are in the format SSSSSSSSS (must be included) */
|
|
2044
2057
|
export function str2nanotimestamp(str, format = 'YYYY.MM.DD HH:mm:ss.SSSSSSSSS') {
|
|
2045
2058
|
if (!str || str === 'null')
|
|
2046
2059
|
return nulls.int64;
|
|
@@ -2106,11 +2119,11 @@ export class DDB {
|
|
|
2106
2119
|
le = true;
|
|
2107
2120
|
/** little endian (client) */
|
|
2108
2121
|
static le_client = Boolean(new Uint8Array(Uint32Array.of(1).buffer)[0]);
|
|
2109
|
-
/** 是否在建立连接后自动登录,默认 true */
|
|
2122
|
+
/** 是否在建立连接后自动登录,默认 true Whether to automatically log in after the connection is established, the default is true */
|
|
2110
2123
|
autologin = true;
|
|
2111
|
-
/** DolphinDB 登录用户名 */
|
|
2124
|
+
/** DolphinDB 登录用户名 DolphinDB username */
|
|
2112
2125
|
username = 'admin';
|
|
2113
|
-
/** DolphinDB 登录密码 */
|
|
2126
|
+
/** DolphinDB 登录密码 DolphinDB password */
|
|
2114
2127
|
password = '123456';
|
|
2115
2128
|
/** python session flag (2048) */
|
|
2116
2129
|
python = false;
|
|
@@ -2169,7 +2182,7 @@ export class DDB {
|
|
|
2169
2182
|
// 这里的实现一定会被 connect 中的实现覆盖
|
|
2170
2183
|
}
|
|
2171
2184
|
/** 建立实际的 WebSocket 连接到 URL 对应的 DolphinDB Establish a actual websocket connection to the DolphindB corresponding to the URL
|
|
2172
|
-
是幂等的,调用后会确保已连接到数据库 (确保 websocket.readyState 为 open),否则报错
|
|
2185
|
+
是幂等的,调用后会确保已连接到数据库 (确保 websocket.readyState 为 open),否则报错 After calling, it will ensure that it has been connected to the database (ensure that websocket.ReadyState is open), otherwise an error will be reported
|
|
2173
2186
|
this.autologin 为 true 时自动登录 this.autologin automatically log in when it is true */
|
|
2174
2187
|
async connect() {
|
|
2175
2188
|
if (this.connected)
|