dolphindb 2.0.509 → 2.0.512
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 +19 -1
- package/browser.js +70 -26
- package/browser.js.map +1 -1
- package/index.d.ts +19 -2
- package/index.js +71 -63
- package/index.js.map +1 -1
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -51,7 +51,6 @@ export declare enum DdbType {
|
|
|
51
51
|
object = 37,
|
|
52
52
|
symbol_extended = 145
|
|
53
53
|
}
|
|
54
|
-
export declare const ddb_sizes: readonly [0, 1, 1, 2, 4, 8, 4, 4, 4, 4, 4, 4, 8, 8, 8, 4, 8, 0, 0, 16, 0, 0, 0, 0, 0, 0, 1, 0, 0, 16, 16, 0, 0, 0, 0];
|
|
55
54
|
export declare enum DdbFunctionType {
|
|
56
55
|
SystemFunc = 0,
|
|
57
56
|
SystemProc = 1,
|
|
@@ -63,10 +62,28 @@ export declare enum DdbFunctionType {
|
|
|
63
62
|
JitFunc = 7,
|
|
64
63
|
JitPartialFunc = 8
|
|
65
64
|
}
|
|
65
|
+
export declare enum DdbDurationUnit {
|
|
66
|
+
ns = 0,
|
|
67
|
+
us = 1,
|
|
68
|
+
ms = 2,
|
|
69
|
+
s = 3,
|
|
70
|
+
m = 4,
|
|
71
|
+
H = 5,
|
|
72
|
+
d = 6,
|
|
73
|
+
w = 7,
|
|
74
|
+
M = 8,
|
|
75
|
+
y = 9,
|
|
76
|
+
B = 10
|
|
77
|
+
}
|
|
66
78
|
export interface DdbFunctionDefValue {
|
|
67
79
|
type: DdbFunctionType;
|
|
68
80
|
name: string;
|
|
69
81
|
}
|
|
82
|
+
export interface DdbDurationValue {
|
|
83
|
+
unit: DdbDurationUnit;
|
|
84
|
+
/** int32 */
|
|
85
|
+
data: number;
|
|
86
|
+
}
|
|
70
87
|
export interface DdbSymbolExtendedValue {
|
|
71
88
|
base_id: number;
|
|
72
89
|
base: string[];
|
|
@@ -88,7 +105,7 @@ export declare type DdbScalarValue = null | boolean | number | bigint | string |
|
|
|
88
105
|
number,
|
|
89
106
|
number
|
|
90
107
|
] | // complex, point
|
|
91
|
-
DdbFunctionDefValue;
|
|
108
|
+
DdbFunctionDefValue | DdbDurationValue;
|
|
92
109
|
export declare type DdbVectorValue = Uint8Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | string[] | // string[]
|
|
93
110
|
Uint8Array[] | // blob
|
|
94
111
|
DdbObj[] | // any
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DDB = exports.str2nanotimestamp = exports.nanotimestamp2str = exports.str2timestamp = exports.timestamp2str = exports.datetime2str = exports.date2str = exports.DdbTable = exports.DdbSetString = exports.DdbSetDouble = exports.DdbSetInt = exports.DdbVectorSymbol = exports.DdbVectorAny = exports.DdbVectorString = exports.DdbVectorDouble = exports.DdbVectorInt = exports.DdbFunction = exports.DdbPair = exports.DdbNanoTimeStamp = exports.DdbTimeStamp = exports.DdbDateTime = exports.DdbDouble = exports.DdbLong = exports.DdbString = exports.DdbInt = exports.DdbChar = exports.DdbBool = exports.DdbVoid = exports.DdbObj = exports.timezone_offset = exports.nulls = exports.
|
|
3
|
+
exports.DDB = exports.str2nanotimestamp = exports.nanotimestamp2str = exports.str2timestamp = exports.timestamp2str = exports.datetime2str = exports.date2str = exports.DdbTable = exports.DdbSetString = exports.DdbSetDouble = exports.DdbSetInt = exports.DdbVectorSymbol = exports.DdbVectorAny = exports.DdbVectorString = exports.DdbVectorDouble = exports.DdbVectorInt = exports.DdbFunction = exports.DdbPair = exports.DdbNanoTimeStamp = exports.DdbTimeStamp = exports.DdbDateTime = exports.DdbDouble = exports.DdbLong = exports.DdbString = exports.DdbInt = exports.DdbChar = exports.DdbBool = exports.DdbVoid = exports.DdbObj = exports.timezone_offset = exports.nulls = exports.DdbDurationUnit = exports.DdbFunctionType = exports.DdbType = exports.DdbForm = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const ws_1 = require("ws");
|
|
6
6
|
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
@@ -60,43 +60,6 @@ var DdbType;
|
|
|
60
60
|
DdbType[DdbType["object"] = 37] = "object";
|
|
61
61
|
DdbType[DdbType["symbol_extended"] = 145] = "symbol_extended";
|
|
62
62
|
})(DdbType = exports.DdbType || (exports.DdbType = {}));
|
|
63
|
-
exports.ddb_sizes = [
|
|
64
|
-
0,
|
|
65
|
-
1,
|
|
66
|
-
1,
|
|
67
|
-
2,
|
|
68
|
-
4,
|
|
69
|
-
8,
|
|
70
|
-
4,
|
|
71
|
-
4,
|
|
72
|
-
4,
|
|
73
|
-
4,
|
|
74
|
-
4,
|
|
75
|
-
4,
|
|
76
|
-
8,
|
|
77
|
-
8,
|
|
78
|
-
8,
|
|
79
|
-
4,
|
|
80
|
-
8,
|
|
81
|
-
0,
|
|
82
|
-
0,
|
|
83
|
-
16,
|
|
84
|
-
0,
|
|
85
|
-
0,
|
|
86
|
-
0,
|
|
87
|
-
0,
|
|
88
|
-
0,
|
|
89
|
-
0,
|
|
90
|
-
1,
|
|
91
|
-
0,
|
|
92
|
-
0,
|
|
93
|
-
16,
|
|
94
|
-
16,
|
|
95
|
-
0,
|
|
96
|
-
0,
|
|
97
|
-
0,
|
|
98
|
-
0, // duration = 36,
|
|
99
|
-
];
|
|
100
63
|
var DdbFunctionType;
|
|
101
64
|
(function (DdbFunctionType) {
|
|
102
65
|
DdbFunctionType[DdbFunctionType["SystemFunc"] = 0] = "SystemFunc";
|
|
@@ -109,6 +72,20 @@ var DdbFunctionType;
|
|
|
109
72
|
DdbFunctionType[DdbFunctionType["JitFunc"] = 7] = "JitFunc";
|
|
110
73
|
DdbFunctionType[DdbFunctionType["JitPartialFunc"] = 8] = "JitPartialFunc";
|
|
111
74
|
})(DdbFunctionType = exports.DdbFunctionType || (exports.DdbFunctionType = {}));
|
|
75
|
+
var DdbDurationUnit;
|
|
76
|
+
(function (DdbDurationUnit) {
|
|
77
|
+
DdbDurationUnit[DdbDurationUnit["ns"] = 0] = "ns";
|
|
78
|
+
DdbDurationUnit[DdbDurationUnit["us"] = 1] = "us";
|
|
79
|
+
DdbDurationUnit[DdbDurationUnit["ms"] = 2] = "ms";
|
|
80
|
+
DdbDurationUnit[DdbDurationUnit["s"] = 3] = "s";
|
|
81
|
+
DdbDurationUnit[DdbDurationUnit["m"] = 4] = "m";
|
|
82
|
+
DdbDurationUnit[DdbDurationUnit["H"] = 5] = "H";
|
|
83
|
+
DdbDurationUnit[DdbDurationUnit["d"] = 6] = "d";
|
|
84
|
+
DdbDurationUnit[DdbDurationUnit["w"] = 7] = "w";
|
|
85
|
+
DdbDurationUnit[DdbDurationUnit["M"] = 8] = "M";
|
|
86
|
+
DdbDurationUnit[DdbDurationUnit["y"] = 9] = "y";
|
|
87
|
+
DdbDurationUnit[DdbDurationUnit["B"] = 10] = "B";
|
|
88
|
+
})(DdbDurationUnit = exports.DdbDurationUnit || (exports.DdbDurationUnit = {}));
|
|
112
89
|
exports.nulls = {
|
|
113
90
|
int8: -0x80,
|
|
114
91
|
int16: -32768,
|
|
@@ -359,6 +336,7 @@ class DdbObj {
|
|
|
359
336
|
case DdbType.string:
|
|
360
337
|
case DdbType.symbol:
|
|
361
338
|
case DdbType.code:
|
|
339
|
+
case DdbType.handle:
|
|
362
340
|
case DdbType.functiondef: {
|
|
363
341
|
const i_head = type === DdbType.functiondef ? 1 : 0;
|
|
364
342
|
let i_zero = buf.indexOf(0, i_head);
|
|
@@ -406,8 +384,18 @@ class DdbObj {
|
|
|
406
384
|
]
|
|
407
385
|
];
|
|
408
386
|
}
|
|
387
|
+
case DdbType.duration: {
|
|
388
|
+
const dv = new DataView(buf.buffer, buf.byteOffset);
|
|
389
|
+
return [
|
|
390
|
+
8,
|
|
391
|
+
{
|
|
392
|
+
unit: dv.getUint32(4, le),
|
|
393
|
+
data: dv.getInt32(0, le)
|
|
394
|
+
}
|
|
395
|
+
];
|
|
396
|
+
}
|
|
409
397
|
default:
|
|
410
|
-
|
|
398
|
+
throw new Error(`${DdbType[type] || type} 暂时不支持解析`);
|
|
411
399
|
}
|
|
412
400
|
}
|
|
413
401
|
/** parse: rows, cols, items
|
|
@@ -546,6 +534,7 @@ class DdbObj {
|
|
|
546
534
|
];
|
|
547
535
|
case DdbType.string:
|
|
548
536
|
case DdbType.symbol:
|
|
537
|
+
case DdbType.handle:
|
|
549
538
|
case DdbType.code: {
|
|
550
539
|
let value = new Array(length);
|
|
551
540
|
let i_head = 0, i_tail = i_head;
|
|
@@ -639,6 +628,13 @@ class DdbObj {
|
|
|
639
628
|
values
|
|
640
629
|
];
|
|
641
630
|
}
|
|
631
|
+
// case DdbType.duration: -> 实际会返回一个 any vector
|
|
632
|
+
// [2y, 1M, 3d, 7H, 11m, 12s, 15ms, 16us, 17ns]
|
|
633
|
+
// <Buffer 19 01 type = any, form = vector
|
|
634
|
+
// 09 00 00 00 01 00 00 00 rows = 9, cols = 1
|
|
635
|
+
// 24 00 type = DdbType.duration, form = scalar
|
|
636
|
+
// 02 00 00 00 09 00 00 00
|
|
637
|
+
// 24 00 01 00 00 00 08 00 00 00 24 00 03 00 00 00 06 00 00 00 24 00 07 00 00 00 05 00 00 00 ... 50 more bytes>
|
|
642
638
|
default:
|
|
643
639
|
return [0, buf];
|
|
644
640
|
}
|
|
@@ -718,6 +714,7 @@ class DdbObj {
|
|
|
718
714
|
case DdbType.string:
|
|
719
715
|
case DdbType.symbol:
|
|
720
716
|
case DdbType.code:
|
|
717
|
+
case DdbType.handle:
|
|
721
718
|
return [
|
|
722
719
|
DdbObj.enc.encode(value),
|
|
723
720
|
Uint8Array.of(0),
|
|
@@ -740,12 +737,12 @@ class DdbObj {
|
|
|
740
737
|
case DdbType.complex:
|
|
741
738
|
case DdbType.point:
|
|
742
739
|
return [Float64Array.from(this.value)];
|
|
743
|
-
case DdbType.duration:
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
740
|
+
case DdbType.duration: {
|
|
741
|
+
const { unit, data } = this.value;
|
|
742
|
+
return [Int32Array.of(data, unit)];
|
|
743
|
+
}
|
|
747
744
|
default:
|
|
748
|
-
throw new Error(`${DdbType[type]} 暂时不支持序列化`);
|
|
745
|
+
throw new Error(`${DdbType[type] || type} 暂时不支持序列化`);
|
|
749
746
|
}
|
|
750
747
|
case DdbForm.vector:
|
|
751
748
|
case DdbForm.pair:
|
|
@@ -838,6 +835,7 @@ class DdbObj {
|
|
|
838
835
|
return [value];
|
|
839
836
|
case DdbType.string:
|
|
840
837
|
case DdbType.symbol:
|
|
838
|
+
case DdbType.handle:
|
|
841
839
|
case DdbType.code: {
|
|
842
840
|
let bufs = new Array(length * 2);
|
|
843
841
|
for (let i = 0; i < length; i++) {
|
|
@@ -924,6 +922,11 @@ class DdbObj {
|
|
|
924
922
|
switch (this.type) {
|
|
925
923
|
case DdbType.functiondef:
|
|
926
924
|
return (0, utils_js_1.inspect)(this.value.name, options);
|
|
925
|
+
case DdbType.duration: {
|
|
926
|
+
const { data, unit } = this.value;
|
|
927
|
+
const str = `${data}${DdbDurationUnit[unit]}`;
|
|
928
|
+
return options.colors ? str.green : str;
|
|
929
|
+
}
|
|
927
930
|
}
|
|
928
931
|
break;
|
|
929
932
|
}
|
|
@@ -1585,25 +1588,30 @@ class DDB {
|
|
|
1585
1588
|
catch { }
|
|
1586
1589
|
// 临界区结束,只有一个 rpc 函数调用运行到这里,可以独占 this.on_message 然后写 WebSocket
|
|
1587
1590
|
this.on_message = ({ data: buffer }) => {
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1591
|
+
try {
|
|
1592
|
+
const buf = new Uint8Array(buffer);
|
|
1593
|
+
if (this.print_message_buffer)
|
|
1594
|
+
console.log((0, utils_js_1.typed_array_to_buffer)(buf));
|
|
1595
|
+
const message = this.parse_message(buf, parse_object);
|
|
1596
|
+
listener?.(message, this);
|
|
1597
|
+
for (const listener of _handlers)
|
|
1598
|
+
listener(message, this);
|
|
1599
|
+
const { type, data } = message;
|
|
1600
|
+
switch (type) {
|
|
1601
|
+
case 'print':
|
|
1602
|
+
if (this.print_message)
|
|
1603
|
+
console.log(data);
|
|
1604
|
+
return;
|
|
1605
|
+
case 'object':
|
|
1606
|
+
resolve(data);
|
|
1607
|
+
return;
|
|
1608
|
+
case 'error':
|
|
1609
|
+
reject(data);
|
|
1610
|
+
return;
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
catch (error) {
|
|
1614
|
+
reject(error);
|
|
1607
1615
|
}
|
|
1608
1616
|
};
|
|
1609
1617
|
args = this.to_ddbobjs(args);
|