dolphindb 2.0.520 → 2.0.523
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 +57 -10
- package/browser.js +134 -38
- package/browser.js.map +1 -1
- package/index.d.ts +54 -7
- package/index.js +128 -32
- package/index.js.map +1 -1
- package/language.d.ts +53 -0
- package/language.js +828 -0
- package/language.js.map +1 -0
- package/package.json +6 -8
package/browser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import 'xshell/prototype.browser';
|
|
1
|
+
import 'xshell/prototype.browser.js';
|
|
2
2
|
export declare enum DdbForm {
|
|
3
3
|
scalar = 0,
|
|
4
4
|
vector = 1,
|
|
@@ -8,13 +8,14 @@ export declare enum DdbForm {
|
|
|
8
8
|
dict = 5,
|
|
9
9
|
table = 6,
|
|
10
10
|
chart = 7,
|
|
11
|
+
/** Node internal communication may be used, calling function execution script generally does not return this type */
|
|
11
12
|
chunk = 8,
|
|
12
13
|
/** sysobj */
|
|
13
14
|
object = 9
|
|
14
15
|
}
|
|
15
16
|
/** DolphinDB DataType
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
The corresponding array vector type is 64 + base type
|
|
18
|
+
The corresponding extended type is 128 + base type
|
|
18
19
|
*/
|
|
19
20
|
export declare enum DdbType {
|
|
20
21
|
void = 0,
|
|
@@ -104,6 +105,32 @@ export interface DdbMatrixValue {
|
|
|
104
105
|
cols: DdbObj<DdbVectorValue>;
|
|
105
106
|
data: DdbVectorValue;
|
|
106
107
|
}
|
|
108
|
+
export declare type DdbDictValue = [DdbObj<DdbVectorValue>, DdbObj<DdbVectorValue>];
|
|
109
|
+
export declare enum DdbChartType {
|
|
110
|
+
area = 0,
|
|
111
|
+
bar = 1,
|
|
112
|
+
column = 2,
|
|
113
|
+
histogram = 3,
|
|
114
|
+
line = 4,
|
|
115
|
+
pie = 5,
|
|
116
|
+
scatter = 6,
|
|
117
|
+
trend = 7,
|
|
118
|
+
kline = 8
|
|
119
|
+
}
|
|
120
|
+
export interface DdbChartValue {
|
|
121
|
+
/** 原属性 chartType */
|
|
122
|
+
type: DdbChartType;
|
|
123
|
+
stacking: boolean;
|
|
124
|
+
titles: {
|
|
125
|
+
chart: string;
|
|
126
|
+
x_axis: string;
|
|
127
|
+
y_axis: string;
|
|
128
|
+
};
|
|
129
|
+
extras: {
|
|
130
|
+
multi_y_axis: boolean;
|
|
131
|
+
};
|
|
132
|
+
data: DdbObj<DdbMatrixValue>;
|
|
133
|
+
}
|
|
107
134
|
export declare type DdbScalarValue = null | boolean | number | bigint | string | Uint8Array | // uuid, ipaddr, int128, blob
|
|
108
135
|
[
|
|
109
136
|
number,
|
|
@@ -114,7 +141,7 @@ export declare type DdbVectorValue = Uint8Array | Int8Array | Int16Array | Int32
|
|
|
114
141
|
Uint8Array[] | // blob
|
|
115
142
|
DdbObj[] | // any
|
|
116
143
|
DdbSymbolExtendedValue | DdbArrayVectorBlock[];
|
|
117
|
-
export declare type DdbValue = DdbScalarValue | DdbVectorValue | DdbMatrixValue;
|
|
144
|
+
export declare type DdbValue = DdbScalarValue | DdbVectorValue | DdbMatrixValue | DdbDictValue | DdbChartValue;
|
|
118
145
|
export declare const nulls: {
|
|
119
146
|
readonly int8: -128;
|
|
120
147
|
readonly int16: -32768;
|
|
@@ -180,13 +207,29 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
|
|
|
180
207
|
pack(): Uint8Array;
|
|
181
208
|
static pack_vector_body(value: DdbVectorValue, type: DdbType, length: number): ArrayBufferView[];
|
|
182
209
|
toString(): string;
|
|
210
|
+
/** 自动转换 js string, boolean 为 DdbObj */
|
|
211
|
+
static to_ddbobj(value: DdbObj | string | boolean): DdbObj;
|
|
212
|
+
/** 转换 js 数组为 DdbObj[] */
|
|
213
|
+
static to_ddbobjs(values: any[]): DdbObj<DdbValue>[];
|
|
183
214
|
to_cols(): {
|
|
184
215
|
title: string;
|
|
185
216
|
dataIndex: string;
|
|
186
217
|
render?: any;
|
|
187
218
|
}[];
|
|
188
219
|
to_rows<T extends Record<string, any> = Record<string, any>>(): T[];
|
|
189
|
-
|
|
220
|
+
/** Automatically convert dict<string, any> to js object (Record<string, any>)
|
|
221
|
+
- options?:
|
|
222
|
+
- strip?: `false` Whether to directly extract and strip the value in DdbObj as the value of js object (discard the rest of the information in DdbObj, only keep the value)
|
|
223
|
+
- deep?: `false` whether to convert recursively
|
|
224
|
+
*/
|
|
225
|
+
to_dict<T extends Record<string, DdbObj> = Record<string, DdbObj>>(): T;
|
|
226
|
+
to_dict<T extends Record<string, any> = Record<string, any>>(options: {
|
|
227
|
+
strip: true;
|
|
228
|
+
}): T;
|
|
229
|
+
to_dict<T extends Record<string, any> = Record<string, any>>(options?: {
|
|
230
|
+
strip?: boolean;
|
|
231
|
+
deep?: boolean;
|
|
232
|
+
}): T;
|
|
190
233
|
}
|
|
191
234
|
export declare function format(type: DdbType, value: DdbValue, le: boolean): string;
|
|
192
235
|
export declare class DdbVoid extends DdbObj<undefined> {
|
|
@@ -235,7 +278,7 @@ export declare class DdbVectorString extends DdbObj<string[]> {
|
|
|
235
278
|
constructor(strings: string[], name?: string);
|
|
236
279
|
}
|
|
237
280
|
export declare class DdbVectorAny extends DdbObj {
|
|
238
|
-
constructor(objs: DdbObj
|
|
281
|
+
constructor(objs: (DdbObj | string | boolean)[], name?: string);
|
|
239
282
|
}
|
|
240
283
|
export declare class DdbVectorSymbol extends DdbObj<DdbSymbolExtendedValue> {
|
|
241
284
|
constructor(strings: string[], name?: string);
|
|
@@ -249,6 +292,14 @@ export declare class DdbSetDouble extends DdbObj<Float64Array> {
|
|
|
249
292
|
export declare class DdbSetString extends DdbObj<string[]> {
|
|
250
293
|
constructor(strings: string[] | Set<string>);
|
|
251
294
|
}
|
|
295
|
+
/** Constructs a DdbDict object, which supports two usages:
|
|
296
|
+
- The incoming type is the keys of DdbObj<DdbVectorValue>, and the two parameters of values directly form the DdbDict of dict<keys.type, values.type>
|
|
297
|
+
- Pass in js object (type is Record<string, boolean | string | DdbObj>), automatically converted to DdbDict of dict<string, any>
|
|
298
|
+
*/
|
|
299
|
+
export declare class DdbDict extends DdbObj<DdbDictValue> {
|
|
300
|
+
constructor(obj: Record<string, boolean | string | DdbObj>);
|
|
301
|
+
constructor(keys: DdbObj<DdbVectorValue>, values: DdbObj<DdbVectorValue>);
|
|
302
|
+
}
|
|
252
303
|
export declare class DdbTable extends DdbObj<DdbObj[]> {
|
|
253
304
|
constructor(columns: DdbObj[], name?: string);
|
|
254
305
|
}
|
|
@@ -467,10 +518,6 @@ export declare class DDB {
|
|
|
467
518
|
}): Promise<DdbObj<DdbValue>>;
|
|
468
519
|
/** 解析服务端响应报文,返回去掉 header 的 data buf */
|
|
469
520
|
parse_message(buf: Uint8Array, parse_object?: boolean): DdbMessage;
|
|
470
|
-
/** 自动转换 js string, boolean 为 DdbObj */
|
|
471
|
-
to_ddbobj(value: DdbObj | string | boolean): DdbObj;
|
|
472
|
-
/** 转换 js 数组为 DdbObj[] */
|
|
473
|
-
to_ddbobjs(values: any[]): DdbObj<DdbValue>[];
|
|
474
521
|
}
|
|
475
522
|
export interface DdbMessageListener {
|
|
476
523
|
(message: DdbMessage, _this: DDB): any;
|
package/browser.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.ddb = exports.DDB = exports.int1282str = exports.uuid2str = exports.ipaddr2str = exports.str2nanotimestamp = void 0;
|
|
3
|
+
exports.nanotime2str = exports.nanotime2ns = exports.str2timestamp = exports.datehour2str = exports.datehour2ms = exports.timestamp2str = exports.timestamp2ms = exports.datetime2str = exports.datetime2ms = exports.second2str = exports.second2ms = exports.minute2str = exports.minute2ms = exports.time2str = exports.time2ms = exports.month2str = exports.month2ms = exports.date2str = exports.date2ms = exports.DdbTable = exports.DdbDict = 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.format = exports.DdbObj = exports.timezone_offset = exports.nulls = exports.DdbChartType = exports.DdbDurationUnit = exports.DdbFunctionType = exports.DdbType = exports.DdbForm = void 0;
|
|
4
|
+
exports.ddb = exports.DDB = exports.int1282str = exports.uuid2str = exports.ipaddr2str = exports.str2nanotimestamp = exports.nanotimestamp2str = exports.nanotimestamp2ns = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
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
9
|
const ipaddr_js_1 = tslib_1.__importDefault(require("ipaddr.js"));
|
|
10
10
|
const { fromByteArray: buf2ipaddr } = ipaddr_js_1.default;
|
|
11
|
-
require("xshell/prototype.browser");
|
|
12
|
-
const
|
|
11
|
+
require("xshell/prototype.browser.js");
|
|
12
|
+
const utils_browser_js_1 = require("xshell/utils.browser.js");
|
|
13
13
|
const net_browser_js_1 = require("xshell/net.browser.js");
|
|
14
14
|
var DdbForm;
|
|
15
15
|
(function (DdbForm) {
|
|
@@ -21,13 +21,14 @@ var DdbForm;
|
|
|
21
21
|
DdbForm[DdbForm["dict"] = 5] = "dict";
|
|
22
22
|
DdbForm[DdbForm["table"] = 6] = "table";
|
|
23
23
|
DdbForm[DdbForm["chart"] = 7] = "chart";
|
|
24
|
+
/** Node internal communication may be used, calling function execution script generally does not return this type */
|
|
24
25
|
DdbForm[DdbForm["chunk"] = 8] = "chunk";
|
|
25
26
|
/** sysobj */
|
|
26
27
|
DdbForm[DdbForm["object"] = 9] = "object";
|
|
27
28
|
})(DdbForm = exports.DdbForm || (exports.DdbForm = {}));
|
|
28
29
|
/** DolphinDB DataType
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
The corresponding array vector type is 64 + base type
|
|
31
|
+
The corresponding extended type is 128 + base type
|
|
31
32
|
*/
|
|
32
33
|
var DdbType;
|
|
33
34
|
(function (DdbType) {
|
|
@@ -95,6 +96,18 @@ var DdbDurationUnit;
|
|
|
95
96
|
DdbDurationUnit[DdbDurationUnit["y"] = 9] = "y";
|
|
96
97
|
DdbDurationUnit[DdbDurationUnit["B"] = 10] = "B";
|
|
97
98
|
})(DdbDurationUnit = exports.DdbDurationUnit || (exports.DdbDurationUnit = {}));
|
|
99
|
+
var DdbChartType;
|
|
100
|
+
(function (DdbChartType) {
|
|
101
|
+
DdbChartType[DdbChartType["area"] = 0] = "area";
|
|
102
|
+
DdbChartType[DdbChartType["bar"] = 1] = "bar";
|
|
103
|
+
DdbChartType[DdbChartType["column"] = 2] = "column";
|
|
104
|
+
DdbChartType[DdbChartType["histogram"] = 3] = "histogram";
|
|
105
|
+
DdbChartType[DdbChartType["line"] = 4] = "line";
|
|
106
|
+
DdbChartType[DdbChartType["pie"] = 5] = "pie";
|
|
107
|
+
DdbChartType[DdbChartType["scatter"] = 6] = "scatter";
|
|
108
|
+
DdbChartType[DdbChartType["trend"] = 7] = "trend";
|
|
109
|
+
DdbChartType[DdbChartType["kline"] = 8] = "kline";
|
|
110
|
+
})(DdbChartType = exports.DdbChartType || (exports.DdbChartType = {}));
|
|
98
111
|
exports.nulls = {
|
|
99
112
|
int8: -0x80,
|
|
100
113
|
int16: -32768,
|
|
@@ -199,7 +212,8 @@ class DdbObj {
|
|
|
199
212
|
value,
|
|
200
213
|
});
|
|
201
214
|
}
|
|
202
|
-
case DdbForm.dict:
|
|
215
|
+
case DdbForm.dict:
|
|
216
|
+
case DdbForm.chart: {
|
|
203
217
|
// <Buffer 19 05 type = any, form = dict
|
|
204
218
|
// 12 01 keys.type = string, keys.form = vector
|
|
205
219
|
// 03 00 00 00 01 00 00 00 keys.cols = 3, keys.rows = 1
|
|
@@ -211,9 +225,9 @@ class DdbObj {
|
|
|
211
225
|
keys.length += 2;
|
|
212
226
|
let values = this.parse_vector(buf_data.subarray(keys.length + 2), le, buf_data[keys.length]);
|
|
213
227
|
values.length += 2;
|
|
214
|
-
|
|
228
|
+
let dict = new this({
|
|
215
229
|
le,
|
|
216
|
-
form,
|
|
230
|
+
form: DdbForm.dict,
|
|
217
231
|
type,
|
|
218
232
|
length: i_data + keys.length + values.length,
|
|
219
233
|
rows: keys.rows,
|
|
@@ -223,6 +237,30 @@ class DdbObj {
|
|
|
223
237
|
values
|
|
224
238
|
],
|
|
225
239
|
});
|
|
240
|
+
if (form === DdbForm.dict)
|
|
241
|
+
return dict;
|
|
242
|
+
else {
|
|
243
|
+
const { chartType: type, stacking, title: titles, extras, data, ...others } = dict.to_dict();
|
|
244
|
+
const [chart, x_axis, y_axis] = titles.value;
|
|
245
|
+
const { multiYAxes: multi_y_axis, ...extras_others } = extras.to_dict({ strip: true });
|
|
246
|
+
dict.form = DdbForm.chart;
|
|
247
|
+
dict.value = {
|
|
248
|
+
type: type.value,
|
|
249
|
+
stacking: stacking.value,
|
|
250
|
+
titles: {
|
|
251
|
+
chart,
|
|
252
|
+
x_axis,
|
|
253
|
+
y_axis,
|
|
254
|
+
},
|
|
255
|
+
extras: {
|
|
256
|
+
multi_y_axis,
|
|
257
|
+
...extras_others,
|
|
258
|
+
},
|
|
259
|
+
data,
|
|
260
|
+
...others,
|
|
261
|
+
};
|
|
262
|
+
return dict;
|
|
263
|
+
}
|
|
226
264
|
}
|
|
227
265
|
case DdbForm.matrix: {
|
|
228
266
|
// rename!(
|
|
@@ -792,6 +830,23 @@ class DdbObj {
|
|
|
792
830
|
value[0].pack(),
|
|
793
831
|
value[1].pack(),
|
|
794
832
|
];
|
|
833
|
+
case DdbForm.chart: {
|
|
834
|
+
const { type, stacking, titles: { chart, x_axis, y_axis, }, extras: { multi_y_axis, ...extras_other }, data } = this.value;
|
|
835
|
+
const { value: [keys, values] } = new DdbDict({
|
|
836
|
+
chartType: new DdbInt(type),
|
|
837
|
+
stacking,
|
|
838
|
+
title: new DdbVectorString([chart, x_axis, y_axis]),
|
|
839
|
+
extras: new DdbDict({
|
|
840
|
+
multiYAxis: multi_y_axis,
|
|
841
|
+
...extras_other
|
|
842
|
+
}),
|
|
843
|
+
data,
|
|
844
|
+
});
|
|
845
|
+
return [
|
|
846
|
+
keys.pack(),
|
|
847
|
+
values.pack(),
|
|
848
|
+
];
|
|
849
|
+
}
|
|
795
850
|
case DdbForm.matrix: {
|
|
796
851
|
const { rows, cols, data } = value;
|
|
797
852
|
return [
|
|
@@ -804,12 +859,12 @@ class DdbObj {
|
|
|
804
859
|
];
|
|
805
860
|
}
|
|
806
861
|
default:
|
|
807
|
-
throw new Error(`${DdbForm[form]}
|
|
862
|
+
throw new Error(`${DdbForm[form]} Serialization is not currently supported`);
|
|
808
863
|
}
|
|
809
864
|
})();
|
|
810
865
|
if (!body)
|
|
811
866
|
return new Uint8Array(0);
|
|
812
|
-
return (0,
|
|
867
|
+
return (0, utils_browser_js_1.concat)([
|
|
813
868
|
header,
|
|
814
869
|
...body
|
|
815
870
|
]);
|
|
@@ -917,6 +972,8 @@ class DdbObj {
|
|
|
917
972
|
return `table[${this.rows}r][${this.cols}c]`;
|
|
918
973
|
case DdbForm.dict:
|
|
919
974
|
return `dict<${DdbType[this.value[0].type]}, ${DdbType[this.value[1].type]}>`;
|
|
975
|
+
case DdbForm.chart:
|
|
976
|
+
return `chart<${DdbChartType[this.value.type]}>`;
|
|
920
977
|
case DdbForm.matrix:
|
|
921
978
|
return `matrix<${tname}>[${this.rows}r][${this.cols}c]`;
|
|
922
979
|
default:
|
|
@@ -1010,6 +1067,24 @@ class DdbObj {
|
|
|
1010
1067
|
})();
|
|
1011
1068
|
return `${type}(${this.name ? `'${this.name}', ` : ''}${data})\n`;
|
|
1012
1069
|
}
|
|
1070
|
+
/** 自动转换 js string, boolean 为 DdbObj */
|
|
1071
|
+
static to_ddbobj(value) {
|
|
1072
|
+
if (value && value instanceof DdbObj)
|
|
1073
|
+
return value;
|
|
1074
|
+
const type = typeof value;
|
|
1075
|
+
switch (type) {
|
|
1076
|
+
case 'string':
|
|
1077
|
+
return new DdbString(value);
|
|
1078
|
+
case 'boolean':
|
|
1079
|
+
return new DdbBool(value);
|
|
1080
|
+
default:
|
|
1081
|
+
throw new Error(`Cannot automatically convert ${type} to DdbObj`);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
/** 转换 js 数组为 DdbObj[] */
|
|
1085
|
+
static to_ddbobjs(values) {
|
|
1086
|
+
return values.map(value => this.to_ddbobj(value));
|
|
1087
|
+
}
|
|
1013
1088
|
to_cols() {
|
|
1014
1089
|
return this.value.map(col => {
|
|
1015
1090
|
let col_ = {
|
|
@@ -1063,13 +1138,22 @@ class DdbObj {
|
|
|
1063
1138
|
}
|
|
1064
1139
|
return rows;
|
|
1065
1140
|
}
|
|
1066
|
-
to_dict() {
|
|
1141
|
+
to_dict({ strip, deep, } = {}) {
|
|
1067
1142
|
if (this.form !== DdbForm.dict)
|
|
1068
|
-
throw new Error('this.form is not DdbForm.dict
|
|
1069
|
-
const [{ value: keys }, { value: values }] = this.value;
|
|
1143
|
+
throw new Error('this.form is not DdbForm.dict and cannot be converted to js object');
|
|
1144
|
+
const [{ value: keys, type: key_type }, { value: values, type: value_type }] = this.value;
|
|
1145
|
+
if (key_type !== DdbType.string || value_type !== DdbType.any)
|
|
1146
|
+
throw new Error('Not dict<string, any>, automatic conversion to js object is not supported for the time being');
|
|
1147
|
+
if (deep && !strip)
|
|
1148
|
+
throw new Error('strip = true must be set when deep = true');
|
|
1070
1149
|
let obj = {};
|
|
1071
|
-
for (let i = 0; i < this.rows; i++)
|
|
1072
|
-
|
|
1150
|
+
for (let i = 0; i < this.rows; i++) {
|
|
1151
|
+
let value = values[i];
|
|
1152
|
+
if (deep && value.form === DdbForm.dict)
|
|
1153
|
+
obj[keys[i]] = value.to_dict({ strip, deep });
|
|
1154
|
+
else
|
|
1155
|
+
obj[keys[i]] = strip ? value.value : value;
|
|
1156
|
+
}
|
|
1073
1157
|
return obj;
|
|
1074
1158
|
}
|
|
1075
1159
|
}
|
|
@@ -1401,7 +1485,7 @@ class DdbVectorAny extends DdbObj {
|
|
|
1401
1485
|
type: DdbType.any,
|
|
1402
1486
|
rows: objs.length,
|
|
1403
1487
|
cols: 1,
|
|
1404
|
-
value: objs,
|
|
1488
|
+
value: DdbObj.to_ddbobjs(objs),
|
|
1405
1489
|
name,
|
|
1406
1490
|
});
|
|
1407
1491
|
}
|
|
@@ -1493,6 +1577,36 @@ class DdbSetString extends DdbObj {
|
|
|
1493
1577
|
}
|
|
1494
1578
|
}
|
|
1495
1579
|
exports.DdbSetString = DdbSetString;
|
|
1580
|
+
/** Constructs a DdbDict object, which supports two usages:
|
|
1581
|
+
- The incoming type is the keys of DdbObj<DdbVectorValue>, and the two parameters of values directly form the DdbDict of dict<keys.type, values.type>
|
|
1582
|
+
- Pass in js object (type is Record<string, boolean | string | DdbObj>), automatically converted to DdbDict of dict<string, any>
|
|
1583
|
+
*/
|
|
1584
|
+
class DdbDict extends DdbObj {
|
|
1585
|
+
constructor(arg0, arg1) {
|
|
1586
|
+
if (arg1)
|
|
1587
|
+
super({
|
|
1588
|
+
form: DdbForm.dict,
|
|
1589
|
+
type: arg1.type,
|
|
1590
|
+
rows: arg0.rows,
|
|
1591
|
+
cols: 2,
|
|
1592
|
+
value: [arg0, arg1]
|
|
1593
|
+
});
|
|
1594
|
+
else {
|
|
1595
|
+
const keys = Object.keys(arg0);
|
|
1596
|
+
super({
|
|
1597
|
+
form: DdbForm.dict,
|
|
1598
|
+
type: DdbType.any,
|
|
1599
|
+
rows: keys.length,
|
|
1600
|
+
cols: 2,
|
|
1601
|
+
value: [
|
|
1602
|
+
new DdbVectorString(keys),
|
|
1603
|
+
new DdbVectorAny(Object.values(arg0))
|
|
1604
|
+
]
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
exports.DdbDict = DdbDict;
|
|
1496
1610
|
class DdbTable extends DdbObj {
|
|
1497
1611
|
constructor(columns, name = '') {
|
|
1498
1612
|
super({
|
|
@@ -1989,7 +2103,7 @@ class DDB {
|
|
|
1989
2103
|
reject(error);
|
|
1990
2104
|
}
|
|
1991
2105
|
};
|
|
1992
|
-
args =
|
|
2106
|
+
args = DdbObj.to_ddbobjs(args);
|
|
1993
2107
|
const command = this.enc.encode((() => {
|
|
1994
2108
|
switch (type) {
|
|
1995
2109
|
case 'function':
|
|
@@ -2009,7 +2123,7 @@ class DDB {
|
|
|
2009
2123
|
return 'connect\n';
|
|
2010
2124
|
}
|
|
2011
2125
|
})());
|
|
2012
|
-
this.websocket.send((0,
|
|
2126
|
+
this.websocket.send((0, utils_browser_js_1.concat)([
|
|
2013
2127
|
this.enc.encode(`API2 ${this.sid} ${command.length} / ${this.get_rpc_options({ urgent })}\n`),
|
|
2014
2128
|
command,
|
|
2015
2129
|
...args.map((arg) => arg.pack())
|
|
@@ -2057,7 +2171,7 @@ class DDB {
|
|
|
2057
2171
|
args = [
|
|
2058
2172
|
new DdbVectorString(nodes),
|
|
2059
2173
|
func,
|
|
2060
|
-
new DdbVectorAny(
|
|
2174
|
+
new DdbVectorAny(args),
|
|
2061
2175
|
...(() => {
|
|
2062
2176
|
if (typeof add_node_alias !== 'undefined')
|
|
2063
2177
|
return [add_node_alias];
|
|
@@ -2138,24 +2252,6 @@ class DDB {
|
|
|
2138
2252
|
})
|
|
2139
2253
|
};
|
|
2140
2254
|
}
|
|
2141
|
-
/** 自动转换 js string, boolean 为 DdbObj */
|
|
2142
|
-
to_ddbobj(value) {
|
|
2143
|
-
if (value instanceof DdbObj)
|
|
2144
|
-
return value;
|
|
2145
|
-
const type = typeof value;
|
|
2146
|
-
switch (type) {
|
|
2147
|
-
case 'string':
|
|
2148
|
-
return new DdbString(value);
|
|
2149
|
-
case 'boolean':
|
|
2150
|
-
return new DdbBool(value);
|
|
2151
|
-
default:
|
|
2152
|
-
throw new Error(`不能自动转换 ${type} 至 DdbObj`);
|
|
2153
|
-
}
|
|
2154
|
-
}
|
|
2155
|
-
/** 转换 js 数组为 DdbObj[] */
|
|
2156
|
-
to_ddbobjs(values) {
|
|
2157
|
-
return values.map(value => this.to_ddbobj(value));
|
|
2158
|
-
}
|
|
2159
2255
|
}
|
|
2160
2256
|
exports.DDB = DDB;
|
|
2161
2257
|
/** little endian (client) */
|