dolphindb 2.0.515 → 2.0.518
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 +3 -3
- package/README.zh.md +3 -3
- package/browser.d.ts +4 -2
- package/browser.js +20 -8
- package/browser.js.map +1 -1
- package/index.d.ts +4 -2
- package/index.js +20 -8
- package/index.js.map +1 -1
- package/package.json +7 -6
package/index.d.ts
CHANGED
|
@@ -10,7 +10,9 @@ export declare enum DdbForm {
|
|
|
10
10
|
dict = 5,
|
|
11
11
|
table = 6,
|
|
12
12
|
chart = 7,
|
|
13
|
-
chunk = 8
|
|
13
|
+
chunk = 8,
|
|
14
|
+
/** sysobj */
|
|
15
|
+
object = 9
|
|
14
16
|
}
|
|
15
17
|
/** DolphinDB DataType
|
|
16
18
|
对应的 array vector 类型为 64 + 基本类型
|
|
@@ -285,7 +287,7 @@ export declare function nanotimestamp2str(nanotimestamp: bigint, format?: string
|
|
|
285
287
|
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
286
288
|
*/
|
|
287
289
|
export declare function str2nanotimestamp(str: string, format?: string): bigint;
|
|
288
|
-
export declare function ipaddr2str(buffer: Uint8Array, le?: boolean): string;
|
|
290
|
+
export declare function ipaddr2str(buffer: Uint8Array, le?: boolean, ipv6?: boolean): string;
|
|
289
291
|
export declare function uuid2str(buffer: Uint8Array, le?: boolean): string;
|
|
290
292
|
export declare function int1282str(buffer: Uint8Array, le?: boolean): string;
|
|
291
293
|
export declare class DDB {
|
package/index.js
CHANGED
|
@@ -6,6 +6,8 @@ const ws_1 = require("ws");
|
|
|
6
6
|
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
7
7
|
const customParseFormat_js_1 = tslib_1.__importDefault(require("dayjs/plugin/customParseFormat.js"));
|
|
8
8
|
dayjs_1.default.extend(customParseFormat_js_1.default);
|
|
9
|
+
const ipaddr_js_1 = tslib_1.__importDefault(require("ipaddr.js"));
|
|
10
|
+
const { fromByteArray: buf2ipaddr } = ipaddr_js_1.default;
|
|
9
11
|
const net_js_1 = require("xshell/net.js");
|
|
10
12
|
const utils_js_1 = require("xshell/utils.js");
|
|
11
13
|
var DdbForm;
|
|
@@ -19,6 +21,8 @@ var DdbForm;
|
|
|
19
21
|
DdbForm[DdbForm["table"] = 6] = "table";
|
|
20
22
|
DdbForm[DdbForm["chart"] = 7] = "chart";
|
|
21
23
|
DdbForm[DdbForm["chunk"] = 8] = "chunk";
|
|
24
|
+
/** sysobj */
|
|
25
|
+
DdbForm[DdbForm["object"] = 9] = "object";
|
|
22
26
|
})(DdbForm = exports.DdbForm || (exports.DdbForm = {}));
|
|
23
27
|
/** DolphinDB DataType
|
|
24
28
|
对应的 array vector 类型为 64 + 基本类型
|
|
@@ -913,7 +917,7 @@ class DdbObj {
|
|
|
913
917
|
case DdbForm.dict:
|
|
914
918
|
return `dict<${DdbType[this.value[0].type]}, ${DdbType[this.value[1].type]}>`;
|
|
915
919
|
case DdbForm.matrix:
|
|
916
|
-
return `matrix<${
|
|
920
|
+
return `matrix<${tname}>[${this.rows}r][${this.cols}c]`;
|
|
917
921
|
default:
|
|
918
922
|
return `${DdbForm[this.form]} ${tname}`;
|
|
919
923
|
}
|
|
@@ -1070,7 +1074,12 @@ function format(type, value, le, options) {
|
|
|
1070
1074
|
return (0, utils_js_1.inspect)((value === null || value === exports.nulls.int8) ?
|
|
1071
1075
|
null
|
|
1072
1076
|
:
|
|
1073
|
-
|
|
1077
|
+
// ascii printable
|
|
1078
|
+
// http://facweb.cs.depaul.edu/sjost/it212/documents/ascii-pr.htm
|
|
1079
|
+
(32 <= value && value <= 126) ?
|
|
1080
|
+
String.fromCharCode(value)
|
|
1081
|
+
:
|
|
1082
|
+
value, options);
|
|
1074
1083
|
case DdbType.short:
|
|
1075
1084
|
return (0, utils_js_1.inspect)((value === null || value === exports.nulls.int16) ?
|
|
1076
1085
|
null
|
|
@@ -1203,7 +1212,10 @@ function format(type, value, le, options) {
|
|
|
1203
1212
|
:
|
|
1204
1213
|
int1282str(value, le);
|
|
1205
1214
|
case DdbType.blob:
|
|
1206
|
-
return (0, utils_js_1.inspect)(
|
|
1215
|
+
return (0, utils_js_1.inspect)(value.length > 100 ?
|
|
1216
|
+
DdbObj.dec.decode(value.subarray(0, 98)) + '…'
|
|
1217
|
+
:
|
|
1218
|
+
DdbObj.dec.decode(value), options);
|
|
1207
1219
|
case DdbType.point: {
|
|
1208
1220
|
let [x, y] = value;
|
|
1209
1221
|
if (x === exports.nulls.double)
|
|
@@ -1570,7 +1582,7 @@ function time2str(time, format = 'HH:mm:ss.SSS') {
|
|
|
1570
1582
|
.format(format);
|
|
1571
1583
|
}
|
|
1572
1584
|
exports.time2str = time2str;
|
|
1573
|
-
function minute2str(minute, format = 'HH:mm') {
|
|
1585
|
+
function minute2str(minute, format = 'HH:mm[m]') {
|
|
1574
1586
|
return (minute === null || minute === exports.nulls.int32) ?
|
|
1575
1587
|
'null'
|
|
1576
1588
|
:
|
|
@@ -1705,14 +1717,14 @@ function str2nanotimestamp(str, format = 'YYYY.MM.DD HH:mm:ss.SSSSSSSSS') {
|
|
|
1705
1717
|
BigInt(str.slice(i_nanosecond_start, i_nanosecond_start + 9)));
|
|
1706
1718
|
}
|
|
1707
1719
|
exports.str2nanotimestamp = str2nanotimestamp;
|
|
1708
|
-
function ipaddr2str(buffer, le = true) {
|
|
1720
|
+
function ipaddr2str(buffer, le = true, ipv6) {
|
|
1709
1721
|
let buf = buffer;
|
|
1710
1722
|
if (le)
|
|
1711
1723
|
buf = buffer.slice().reverse();
|
|
1712
1724
|
const i_non_zero = buf.findIndex(x => x);
|
|
1713
|
-
if (
|
|
1714
|
-
|
|
1715
|
-
|
|
1725
|
+
if (ipv6 ||
|
|
1726
|
+
i_non_zero !== -1 && i_non_zero < 12) // ipv6
|
|
1727
|
+
return buf2ipaddr([...buf]).toString();
|
|
1716
1728
|
else // ipv4
|
|
1717
1729
|
return buf.subarray(12).join('.');
|
|
1718
1730
|
}
|