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/README.md
CHANGED
|
@@ -128,12 +128,12 @@ class DdbObj <T extends DdbValue = DdbValue> {
|
|
|
128
128
|
/** 2nd dimension */
|
|
129
129
|
cols?: number
|
|
130
130
|
|
|
131
|
-
/** the type of the value in matrix (only matrix has this field) */
|
|
132
|
-
datatype?: DdbType
|
|
133
|
-
|
|
134
131
|
/** the actual data. Different DdbForm, DdbType use different types in DdbValue to represent actual data */
|
|
135
132
|
value: T
|
|
136
133
|
|
|
134
|
+
/** raw binary data, only top-level objects generated by parse_message when parse_object is false have this attribute */
|
|
135
|
+
buffer?: Uint8Array
|
|
136
|
+
|
|
137
137
|
constructor (data: Partial<DdbObj> & { form: DdbForm, type: DdbType, length: number }) {
|
|
138
138
|
Object.assign(this, data)
|
|
139
139
|
}
|
package/README.zh.md
CHANGED
|
@@ -129,12 +129,12 @@ class DdbObj <T extends DdbValue = DdbValue> {
|
|
|
129
129
|
/** 第 2 维 */
|
|
130
130
|
cols?: number
|
|
131
131
|
|
|
132
|
-
/** matrix 中值的类型,仅 matrix 才有 */
|
|
133
|
-
datatype?: DdbType
|
|
134
|
-
|
|
135
132
|
/** 实际数据。不同的 DdbForm, DdbType 使用 DdbValue 中不同的类型来表示实际数据 */
|
|
136
133
|
value: T
|
|
137
134
|
|
|
135
|
+
/** 原始二进制数据,仅在 parse_object 为 false 时通过 parse_message 生成的顶层对象有这个属性 */
|
|
136
|
+
buffer?: Uint8Array
|
|
137
|
+
|
|
138
138
|
constructor (data: Partial<DdbObj> & { form: DdbForm, type: DdbType, length: number }) {
|
|
139
139
|
Object.assign(this, data)
|
|
140
140
|
}
|
package/browser.d.ts
CHANGED
|
@@ -8,7 +8,9 @@ export declare enum DdbForm {
|
|
|
8
8
|
dict = 5,
|
|
9
9
|
table = 6,
|
|
10
10
|
chart = 7,
|
|
11
|
-
chunk = 8
|
|
11
|
+
chunk = 8,
|
|
12
|
+
/** sysobj */
|
|
13
|
+
object = 9
|
|
12
14
|
}
|
|
13
15
|
/** DolphinDB DataType
|
|
14
16
|
对应的 array vector 类型为 64 + 基本类型
|
|
@@ -288,7 +290,7 @@ export declare function nanotimestamp2str(nanotimestamp: bigint, format?: string
|
|
|
288
290
|
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
289
291
|
*/
|
|
290
292
|
export declare function str2nanotimestamp(str: string, format?: string): bigint;
|
|
291
|
-
export declare function ipaddr2str(buffer: Uint8Array, le?: boolean): string;
|
|
293
|
+
export declare function ipaddr2str(buffer: Uint8Array, le?: boolean, ipv6?: boolean): string;
|
|
292
294
|
export declare function uuid2str(buffer: Uint8Array, le?: boolean): string;
|
|
293
295
|
export declare function int1282str(buffer: Uint8Array, le?: boolean): string;
|
|
294
296
|
export declare class DDB {
|
package/browser.js
CHANGED
|
@@ -5,6 +5,8 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
6
6
|
const customParseFormat_js_1 = tslib_1.__importDefault(require("dayjs/plugin/customParseFormat.js"));
|
|
7
7
|
dayjs_1.default.extend(customParseFormat_js_1.default);
|
|
8
|
+
const ipaddr_js_1 = tslib_1.__importDefault(require("ipaddr.js"));
|
|
9
|
+
const { fromByteArray: buf2ipaddr } = ipaddr_js_1.default;
|
|
8
10
|
require("xshell/prototype.browser");
|
|
9
11
|
const utils_browser_1 = require("xshell/utils.browser");
|
|
10
12
|
const net_browser_js_1 = require("xshell/net.browser.js");
|
|
@@ -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 + 基本类型
|
|
@@ -1088,7 +1092,12 @@ function format(type, value, le) {
|
|
|
1088
1092
|
return String((value === null || value === exports.nulls.int8) ?
|
|
1089
1093
|
null
|
|
1090
1094
|
:
|
|
1091
|
-
|
|
1095
|
+
// ascii printable
|
|
1096
|
+
// http://facweb.cs.depaul.edu/sjost/it212/documents/ascii-pr.htm
|
|
1097
|
+
(32 <= value && value <= 126) ?
|
|
1098
|
+
String.fromCharCode(value).quote()
|
|
1099
|
+
:
|
|
1100
|
+
value);
|
|
1092
1101
|
case DdbType.short:
|
|
1093
1102
|
return String((value === null || value === exports.nulls.int16) ?
|
|
1094
1103
|
null
|
|
@@ -1165,7 +1174,7 @@ function format(type, value, le) {
|
|
|
1165
1174
|
case DdbType.uuid:
|
|
1166
1175
|
return uuid2str(value, le);
|
|
1167
1176
|
case DdbType.functiondef:
|
|
1168
|
-
return value.quote('single');
|
|
1177
|
+
return value.name.quote('single');
|
|
1169
1178
|
case DdbType.handle:
|
|
1170
1179
|
case DdbType.code:
|
|
1171
1180
|
return value.quote('single');
|
|
@@ -1213,7 +1222,6 @@ class DdbVoid extends DdbObj {
|
|
|
1213
1222
|
super({
|
|
1214
1223
|
form: DdbForm.scalar,
|
|
1215
1224
|
type: DdbType.void,
|
|
1216
|
-
length: 0,
|
|
1217
1225
|
value: null,
|
|
1218
1226
|
});
|
|
1219
1227
|
}
|
|
@@ -1224,7 +1232,6 @@ class DdbBool extends DdbObj {
|
|
|
1224
1232
|
super({
|
|
1225
1233
|
form: DdbForm.scalar,
|
|
1226
1234
|
type: DdbType.bool,
|
|
1227
|
-
length: 1,
|
|
1228
1235
|
value,
|
|
1229
1236
|
});
|
|
1230
1237
|
}
|
|
@@ -1235,7 +1242,6 @@ class DdbChar extends DdbObj {
|
|
|
1235
1242
|
super({
|
|
1236
1243
|
form: DdbForm.scalar,
|
|
1237
1244
|
type: DdbType.char,
|
|
1238
|
-
length: 1,
|
|
1239
1245
|
value: typeof value === 'string' ?
|
|
1240
1246
|
value.charCodeAt(0)
|
|
1241
1247
|
:
|
|
@@ -1249,7 +1255,6 @@ class DdbInt extends DdbObj {
|
|
|
1249
1255
|
super({
|
|
1250
1256
|
form: DdbForm.scalar,
|
|
1251
1257
|
type: DdbType.int,
|
|
1252
|
-
length: 4,
|
|
1253
1258
|
value,
|
|
1254
1259
|
});
|
|
1255
1260
|
}
|
|
@@ -1260,7 +1265,6 @@ class DdbString extends DdbObj {
|
|
|
1260
1265
|
super({
|
|
1261
1266
|
form: DdbForm.scalar,
|
|
1262
1267
|
type: DdbType.string,
|
|
1263
|
-
length: 0,
|
|
1264
1268
|
value
|
|
1265
1269
|
});
|
|
1266
1270
|
}
|
|
@@ -1271,7 +1275,6 @@ class DdbLong extends DdbObj {
|
|
|
1271
1275
|
super({
|
|
1272
1276
|
form: DdbForm.scalar,
|
|
1273
1277
|
type: DdbType.long,
|
|
1274
|
-
length: 8,
|
|
1275
1278
|
value
|
|
1276
1279
|
});
|
|
1277
1280
|
}
|
|
@@ -1282,7 +1285,6 @@ class DdbDouble extends DdbObj {
|
|
|
1282
1285
|
super({
|
|
1283
1286
|
form: DdbForm.scalar,
|
|
1284
1287
|
type: DdbType.double,
|
|
1285
|
-
length: 8,
|
|
1286
1288
|
value
|
|
1287
1289
|
});
|
|
1288
1290
|
}
|
|
@@ -1293,7 +1295,6 @@ class DdbDateTime extends DdbObj {
|
|
|
1293
1295
|
super({
|
|
1294
1296
|
form: DdbForm.scalar,
|
|
1295
1297
|
type: DdbType.datetime,
|
|
1296
|
-
length: 4,
|
|
1297
1298
|
value
|
|
1298
1299
|
});
|
|
1299
1300
|
}
|
|
@@ -1304,7 +1305,6 @@ class DdbTimeStamp extends DdbObj {
|
|
|
1304
1305
|
super({
|
|
1305
1306
|
form: DdbForm.scalar,
|
|
1306
1307
|
type: DdbType.timestamp,
|
|
1307
|
-
length: 8,
|
|
1308
1308
|
value
|
|
1309
1309
|
});
|
|
1310
1310
|
}
|
|
@@ -1315,7 +1315,6 @@ class DdbNanoTimeStamp extends DdbObj {
|
|
|
1315
1315
|
super({
|
|
1316
1316
|
form: DdbForm.scalar,
|
|
1317
1317
|
type: DdbType.nanotimestamp,
|
|
1318
|
-
length: 8,
|
|
1319
1318
|
value
|
|
1320
1319
|
});
|
|
1321
1320
|
}
|
|
@@ -1326,7 +1325,6 @@ class DdbPair extends DdbObj {
|
|
|
1326
1325
|
super({
|
|
1327
1326
|
form: DdbForm.pair,
|
|
1328
1327
|
type: DdbType.int,
|
|
1329
|
-
length: 0,
|
|
1330
1328
|
rows: 2,
|
|
1331
1329
|
cols: 1,
|
|
1332
1330
|
value: Int32Array.of(l === null ? exports.nulls.int32 : l, r === null ? exports.nulls.int32 : r)
|
|
@@ -1339,7 +1337,6 @@ class DdbFunction extends DdbObj {
|
|
|
1339
1337
|
super({
|
|
1340
1338
|
form: DdbForm.scalar,
|
|
1341
1339
|
type: DdbType.functiondef,
|
|
1342
|
-
length: 0,
|
|
1343
1340
|
value: { type, name }
|
|
1344
1341
|
});
|
|
1345
1342
|
}
|
|
@@ -1350,7 +1347,6 @@ class DdbVectorInt extends DdbObj {
|
|
|
1350
1347
|
super({
|
|
1351
1348
|
form: DdbForm.vector,
|
|
1352
1349
|
type: DdbType.int,
|
|
1353
|
-
length: 0,
|
|
1354
1350
|
rows: ints.length,
|
|
1355
1351
|
cols: 1,
|
|
1356
1352
|
value: ints instanceof Int32Array ?
|
|
@@ -1370,7 +1366,6 @@ class DdbVectorDouble extends DdbObj {
|
|
|
1370
1366
|
super({
|
|
1371
1367
|
form: DdbForm.vector,
|
|
1372
1368
|
type: DdbType.double,
|
|
1373
|
-
length: 0,
|
|
1374
1369
|
rows: doubles.length,
|
|
1375
1370
|
cols: 1,
|
|
1376
1371
|
value: doubles instanceof Float64Array ?
|
|
@@ -1390,7 +1385,6 @@ class DdbVectorString extends DdbObj {
|
|
|
1390
1385
|
super({
|
|
1391
1386
|
form: DdbForm.vector,
|
|
1392
1387
|
type: DdbType.string,
|
|
1393
|
-
length: 0,
|
|
1394
1388
|
rows: strings.length,
|
|
1395
1389
|
cols: 1,
|
|
1396
1390
|
value: strings,
|
|
@@ -1404,7 +1398,6 @@ class DdbVectorAny extends DdbObj {
|
|
|
1404
1398
|
super({
|
|
1405
1399
|
form: DdbForm.vector,
|
|
1406
1400
|
type: DdbType.any,
|
|
1407
|
-
length: 0,
|
|
1408
1401
|
rows: objs.length,
|
|
1409
1402
|
cols: 1,
|
|
1410
1403
|
value: objs,
|
|
@@ -1431,7 +1424,6 @@ class DdbVectorSymbol extends DdbObj {
|
|
|
1431
1424
|
super({
|
|
1432
1425
|
form: DdbForm.vector,
|
|
1433
1426
|
type: DdbType.symbol_extended,
|
|
1434
|
-
length: 0,
|
|
1435
1427
|
rows: strings.length,
|
|
1436
1428
|
cols: 1,
|
|
1437
1429
|
value: {
|
|
@@ -1449,7 +1441,6 @@ class DdbSetInt extends DdbObj {
|
|
|
1449
1441
|
super({
|
|
1450
1442
|
form: DdbForm.set,
|
|
1451
1443
|
type: DdbType.int,
|
|
1452
|
-
length: 0,
|
|
1453
1444
|
rows: ints instanceof Set ?
|
|
1454
1445
|
ints.size
|
|
1455
1446
|
:
|
|
@@ -1471,7 +1462,6 @@ class DdbSetDouble extends DdbObj {
|
|
|
1471
1462
|
super({
|
|
1472
1463
|
form: DdbForm.set,
|
|
1473
1464
|
type: DdbType.double,
|
|
1474
|
-
length: 0,
|
|
1475
1465
|
rows: doubles instanceof Set ?
|
|
1476
1466
|
doubles.size
|
|
1477
1467
|
:
|
|
@@ -1495,7 +1485,6 @@ class DdbSetString extends DdbObj {
|
|
|
1495
1485
|
super({
|
|
1496
1486
|
form: DdbForm.set,
|
|
1497
1487
|
type: DdbType.string,
|
|
1498
|
-
length: 0,
|
|
1499
1488
|
rows: strings.length,
|
|
1500
1489
|
cols: 1,
|
|
1501
1490
|
value: strings
|
|
@@ -1508,7 +1497,6 @@ class DdbTable extends DdbObj {
|
|
|
1508
1497
|
super({
|
|
1509
1498
|
form: DdbForm.table,
|
|
1510
1499
|
type: DdbType.void,
|
|
1511
|
-
length: 0,
|
|
1512
1500
|
rows: columns[0].rows,
|
|
1513
1501
|
cols: columns.length,
|
|
1514
1502
|
name,
|
|
@@ -1677,14 +1665,14 @@ function str2nanotimestamp(str, format = 'YYYY.MM.DD HH:mm:ss.SSSSSSSSS') {
|
|
|
1677
1665
|
BigInt(str.slice(i_nanosecond_start, i_nanosecond_start + 9)));
|
|
1678
1666
|
}
|
|
1679
1667
|
exports.str2nanotimestamp = str2nanotimestamp;
|
|
1680
|
-
function ipaddr2str(buffer, le = true) {
|
|
1668
|
+
function ipaddr2str(buffer, le = true, ipv6) {
|
|
1681
1669
|
let buf = buffer;
|
|
1682
1670
|
if (le)
|
|
1683
1671
|
buf = buffer.slice().reverse();
|
|
1684
1672
|
const i_non_zero = buf.findIndex(x => x);
|
|
1685
|
-
if (
|
|
1686
|
-
|
|
1687
|
-
|
|
1673
|
+
if (ipv6 ||
|
|
1674
|
+
i_non_zero !== -1 && i_non_zero < 12) // ipv6
|
|
1675
|
+
return buf2ipaddr([...buf]).toString();
|
|
1688
1676
|
else // ipv4
|
|
1689
1677
|
return buf.subarray(12).join('.');
|
|
1690
1678
|
}
|