dolphindb 2.0.516 → 2.0.519
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 +15 -27
- package/browser.js.map +1 -1
- package/index.d.ts +4 -2
- package/index.js +14 -26
- package/index.js.map +1 -1
- package/package.json +9 -8
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 + 基本类型
|
|
@@ -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
|
|
@@ -1244,7 +1253,6 @@ class DdbVoid extends DdbObj {
|
|
|
1244
1253
|
super({
|
|
1245
1254
|
form: DdbForm.scalar,
|
|
1246
1255
|
type: DdbType.void,
|
|
1247
|
-
length: 0,
|
|
1248
1256
|
value: null,
|
|
1249
1257
|
});
|
|
1250
1258
|
}
|
|
@@ -1255,7 +1263,6 @@ class DdbBool extends DdbObj {
|
|
|
1255
1263
|
super({
|
|
1256
1264
|
form: DdbForm.scalar,
|
|
1257
1265
|
type: DdbType.bool,
|
|
1258
|
-
length: 1,
|
|
1259
1266
|
value,
|
|
1260
1267
|
});
|
|
1261
1268
|
}
|
|
@@ -1266,7 +1273,6 @@ class DdbChar extends DdbObj {
|
|
|
1266
1273
|
super({
|
|
1267
1274
|
form: DdbForm.scalar,
|
|
1268
1275
|
type: DdbType.char,
|
|
1269
|
-
length: 1,
|
|
1270
1276
|
value: typeof value === 'string' ?
|
|
1271
1277
|
value.charCodeAt(0)
|
|
1272
1278
|
:
|
|
@@ -1280,7 +1286,6 @@ class DdbInt extends DdbObj {
|
|
|
1280
1286
|
super({
|
|
1281
1287
|
form: DdbForm.scalar,
|
|
1282
1288
|
type: DdbType.int,
|
|
1283
|
-
length: 4,
|
|
1284
1289
|
value,
|
|
1285
1290
|
});
|
|
1286
1291
|
}
|
|
@@ -1291,7 +1296,6 @@ class DdbString extends DdbObj {
|
|
|
1291
1296
|
super({
|
|
1292
1297
|
form: DdbForm.scalar,
|
|
1293
1298
|
type: DdbType.string,
|
|
1294
|
-
length: 0,
|
|
1295
1299
|
value
|
|
1296
1300
|
});
|
|
1297
1301
|
}
|
|
@@ -1302,7 +1306,6 @@ class DdbLong extends DdbObj {
|
|
|
1302
1306
|
super({
|
|
1303
1307
|
form: DdbForm.scalar,
|
|
1304
1308
|
type: DdbType.long,
|
|
1305
|
-
length: 8,
|
|
1306
1309
|
value
|
|
1307
1310
|
});
|
|
1308
1311
|
}
|
|
@@ -1313,7 +1316,6 @@ class DdbDouble extends DdbObj {
|
|
|
1313
1316
|
super({
|
|
1314
1317
|
form: DdbForm.scalar,
|
|
1315
1318
|
type: DdbType.double,
|
|
1316
|
-
length: 8,
|
|
1317
1319
|
value
|
|
1318
1320
|
});
|
|
1319
1321
|
}
|
|
@@ -1324,7 +1326,6 @@ class DdbDateTime extends DdbObj {
|
|
|
1324
1326
|
super({
|
|
1325
1327
|
form: DdbForm.scalar,
|
|
1326
1328
|
type: DdbType.datetime,
|
|
1327
|
-
length: 4,
|
|
1328
1329
|
value
|
|
1329
1330
|
});
|
|
1330
1331
|
}
|
|
@@ -1335,7 +1336,6 @@ class DdbTimeStamp extends DdbObj {
|
|
|
1335
1336
|
super({
|
|
1336
1337
|
form: DdbForm.scalar,
|
|
1337
1338
|
type: DdbType.timestamp,
|
|
1338
|
-
length: 8,
|
|
1339
1339
|
value
|
|
1340
1340
|
});
|
|
1341
1341
|
}
|
|
@@ -1346,7 +1346,6 @@ class DdbNanoTimeStamp extends DdbObj {
|
|
|
1346
1346
|
super({
|
|
1347
1347
|
form: DdbForm.scalar,
|
|
1348
1348
|
type: DdbType.nanotimestamp,
|
|
1349
|
-
length: 8,
|
|
1350
1349
|
value
|
|
1351
1350
|
});
|
|
1352
1351
|
}
|
|
@@ -1357,7 +1356,6 @@ class DdbPair extends DdbObj {
|
|
|
1357
1356
|
super({
|
|
1358
1357
|
form: DdbForm.pair,
|
|
1359
1358
|
type: DdbType.int,
|
|
1360
|
-
length: 0,
|
|
1361
1359
|
rows: 2,
|
|
1362
1360
|
cols: 1,
|
|
1363
1361
|
value: Int32Array.of(l === null ? exports.nulls.int32 : l, r === null ? exports.nulls.int32 : r)
|
|
@@ -1370,7 +1368,6 @@ class DdbFunction extends DdbObj {
|
|
|
1370
1368
|
super({
|
|
1371
1369
|
form: DdbForm.scalar,
|
|
1372
1370
|
type: DdbType.functiondef,
|
|
1373
|
-
length: 0,
|
|
1374
1371
|
value: { type, name }
|
|
1375
1372
|
});
|
|
1376
1373
|
}
|
|
@@ -1381,7 +1378,6 @@ class DdbVectorInt extends DdbObj {
|
|
|
1381
1378
|
super({
|
|
1382
1379
|
form: DdbForm.vector,
|
|
1383
1380
|
type: DdbType.int,
|
|
1384
|
-
length: 0,
|
|
1385
1381
|
rows: ints.length,
|
|
1386
1382
|
cols: 1,
|
|
1387
1383
|
value: ints instanceof Int32Array ?
|
|
@@ -1401,7 +1397,6 @@ class DdbVectorDouble extends DdbObj {
|
|
|
1401
1397
|
super({
|
|
1402
1398
|
form: DdbForm.vector,
|
|
1403
1399
|
type: DdbType.double,
|
|
1404
|
-
length: 0,
|
|
1405
1400
|
rows: doubles.length,
|
|
1406
1401
|
cols: 1,
|
|
1407
1402
|
value: doubles instanceof Float64Array ?
|
|
@@ -1421,7 +1416,6 @@ class DdbVectorString extends DdbObj {
|
|
|
1421
1416
|
super({
|
|
1422
1417
|
form: DdbForm.vector,
|
|
1423
1418
|
type: DdbType.string,
|
|
1424
|
-
length: 0,
|
|
1425
1419
|
rows: strings.length,
|
|
1426
1420
|
cols: 1,
|
|
1427
1421
|
value: strings,
|
|
@@ -1435,7 +1429,6 @@ class DdbVectorAny extends DdbObj {
|
|
|
1435
1429
|
super({
|
|
1436
1430
|
form: DdbForm.vector,
|
|
1437
1431
|
type: DdbType.any,
|
|
1438
|
-
length: 0,
|
|
1439
1432
|
rows: objs.length,
|
|
1440
1433
|
cols: 1,
|
|
1441
1434
|
value: objs,
|
|
@@ -1462,7 +1455,6 @@ class DdbVectorSymbol extends DdbObj {
|
|
|
1462
1455
|
super({
|
|
1463
1456
|
form: DdbForm.vector,
|
|
1464
1457
|
type: DdbType.symbol_extended,
|
|
1465
|
-
length: 0,
|
|
1466
1458
|
rows: strings.length,
|
|
1467
1459
|
cols: 1,
|
|
1468
1460
|
value: {
|
|
@@ -1480,7 +1472,6 @@ class DdbSetInt extends DdbObj {
|
|
|
1480
1472
|
super({
|
|
1481
1473
|
form: DdbForm.set,
|
|
1482
1474
|
type: DdbType.int,
|
|
1483
|
-
length: 0,
|
|
1484
1475
|
rows: ints instanceof Set ?
|
|
1485
1476
|
ints.size
|
|
1486
1477
|
:
|
|
@@ -1502,7 +1493,6 @@ class DdbSetDouble extends DdbObj {
|
|
|
1502
1493
|
super({
|
|
1503
1494
|
form: DdbForm.set,
|
|
1504
1495
|
type: DdbType.double,
|
|
1505
|
-
length: 0,
|
|
1506
1496
|
rows: doubles instanceof Set ?
|
|
1507
1497
|
doubles.size
|
|
1508
1498
|
:
|
|
@@ -1526,7 +1516,6 @@ class DdbSetString extends DdbObj {
|
|
|
1526
1516
|
super({
|
|
1527
1517
|
form: DdbForm.set,
|
|
1528
1518
|
type: DdbType.string,
|
|
1529
|
-
length: 0,
|
|
1530
1519
|
rows: strings.length,
|
|
1531
1520
|
cols: 1,
|
|
1532
1521
|
value: strings
|
|
@@ -1539,7 +1528,6 @@ class DdbTable extends DdbObj {
|
|
|
1539
1528
|
super({
|
|
1540
1529
|
form: DdbForm.table,
|
|
1541
1530
|
type: DdbType.void,
|
|
1542
|
-
length: 0,
|
|
1543
1531
|
rows: columns[0].rows,
|
|
1544
1532
|
cols: columns.length,
|
|
1545
1533
|
name,
|
|
@@ -1708,14 +1696,14 @@ function str2nanotimestamp(str, format = 'YYYY.MM.DD HH:mm:ss.SSSSSSSSS') {
|
|
|
1708
1696
|
BigInt(str.slice(i_nanosecond_start, i_nanosecond_start + 9)));
|
|
1709
1697
|
}
|
|
1710
1698
|
exports.str2nanotimestamp = str2nanotimestamp;
|
|
1711
|
-
function ipaddr2str(buffer, le = true) {
|
|
1699
|
+
function ipaddr2str(buffer, le = true, ipv6) {
|
|
1712
1700
|
let buf = buffer;
|
|
1713
1701
|
if (le)
|
|
1714
1702
|
buf = buffer.slice().reverse();
|
|
1715
1703
|
const i_non_zero = buf.findIndex(x => x);
|
|
1716
|
-
if (
|
|
1717
|
-
|
|
1718
|
-
|
|
1704
|
+
if (ipv6 ||
|
|
1705
|
+
i_non_zero !== -1 && i_non_zero < 12) // ipv6
|
|
1706
|
+
return buf2ipaddr([...buf]).toString();
|
|
1719
1707
|
else // ipv4
|
|
1720
1708
|
return buf.subarray(12).join('.');
|
|
1721
1709
|
}
|