dolphindb 2.0.520 → 2.0.521
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 +60 -12
- package/browser.js +131 -34
- package/browser.js.map +1 -1
- package/index.d.ts +55 -7
- package/index.js +129 -32
- package/index.js.map +1 -1
- package/package.json +4 -6
package/browser.d.ts
CHANGED
|
@@ -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,33 @@ 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
|
+
stack = 9
|
|
120
|
+
}
|
|
121
|
+
export interface DdbChartValue {
|
|
122
|
+
/** 原属性 chartType */
|
|
123
|
+
type: DdbChartType;
|
|
124
|
+
stacking: boolean;
|
|
125
|
+
titles: {
|
|
126
|
+
chart: string;
|
|
127
|
+
x_axis: string;
|
|
128
|
+
y_axis: string;
|
|
129
|
+
};
|
|
130
|
+
extras: {
|
|
131
|
+
multi_y_axis: boolean;
|
|
132
|
+
};
|
|
133
|
+
data: DdbObj<DdbMatrixValue>;
|
|
134
|
+
}
|
|
107
135
|
export declare type DdbScalarValue = null | boolean | number | bigint | string | Uint8Array | // uuid, ipaddr, int128, blob
|
|
108
136
|
[
|
|
109
137
|
number,
|
|
@@ -114,7 +142,7 @@ export declare type DdbVectorValue = Uint8Array | Int8Array | Int16Array | Int32
|
|
|
114
142
|
Uint8Array[] | // blob
|
|
115
143
|
DdbObj[] | // any
|
|
116
144
|
DdbSymbolExtendedValue | DdbArrayVectorBlock[];
|
|
117
|
-
export declare type DdbValue = DdbScalarValue | DdbVectorValue | DdbMatrixValue;
|
|
145
|
+
export declare type DdbValue = DdbScalarValue | DdbVectorValue | DdbMatrixValue | DdbDictValue | DdbChartValue;
|
|
118
146
|
export declare const nulls: {
|
|
119
147
|
readonly int8: -128;
|
|
120
148
|
readonly int16: -32768;
|
|
@@ -179,16 +207,32 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
|
|
|
179
207
|
];
|
|
180
208
|
pack(): Uint8Array;
|
|
181
209
|
static pack_vector_body(value: DdbVectorValue, type: DdbType, length: number): ArrayBufferView[];
|
|
182
|
-
toString():
|
|
210
|
+
toString(): any;
|
|
211
|
+
/** 自动转换 js string, boolean 为 DdbObj */
|
|
212
|
+
static to_ddbobj(value: DdbObj | string | boolean): DdbObj;
|
|
213
|
+
/** 转换 js 数组为 DdbObj[] */
|
|
214
|
+
static to_ddbobjs(values: any[]): DdbObj<DdbValue>[];
|
|
183
215
|
to_cols(): {
|
|
184
216
|
title: string;
|
|
185
217
|
dataIndex: string;
|
|
186
218
|
render?: any;
|
|
187
219
|
}[];
|
|
188
220
|
to_rows<T extends Record<string, any> = Record<string, any>>(): T[];
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
221
|
+
/** Automatically convert dict<string, any> to js object (Record<string, any>)
|
|
222
|
+
- options?:
|
|
223
|
+
- 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)
|
|
224
|
+
- deep?: `false` whether to convert recursively
|
|
225
|
+
*/
|
|
226
|
+
to_dict<T extends Record<string, DdbObj> = Record<string, DdbObj>>(): T;
|
|
227
|
+
to_dict<T extends Record<string, any> = Record<string, any>>(options: {
|
|
228
|
+
strip: true;
|
|
229
|
+
}): T;
|
|
230
|
+
to_dict<T extends Record<string, any> = Record<string, any>>(options?: {
|
|
231
|
+
strip?: boolean;
|
|
232
|
+
deep?: boolean;
|
|
233
|
+
}): T;
|
|
234
|
+
}
|
|
235
|
+
export declare function format(type: DdbType, value: DdbValue, le: boolean): any;
|
|
192
236
|
export declare class DdbVoid extends DdbObj<undefined> {
|
|
193
237
|
constructor();
|
|
194
238
|
}
|
|
@@ -235,7 +279,7 @@ export declare class DdbVectorString extends DdbObj<string[]> {
|
|
|
235
279
|
constructor(strings: string[], name?: string);
|
|
236
280
|
}
|
|
237
281
|
export declare class DdbVectorAny extends DdbObj {
|
|
238
|
-
constructor(objs: DdbObj
|
|
282
|
+
constructor(objs: (DdbObj | string | boolean)[], name?: string);
|
|
239
283
|
}
|
|
240
284
|
export declare class DdbVectorSymbol extends DdbObj<DdbSymbolExtendedValue> {
|
|
241
285
|
constructor(strings: string[], name?: string);
|
|
@@ -249,6 +293,14 @@ export declare class DdbSetDouble extends DdbObj<Float64Array> {
|
|
|
249
293
|
export declare class DdbSetString extends DdbObj<string[]> {
|
|
250
294
|
constructor(strings: string[] | Set<string>);
|
|
251
295
|
}
|
|
296
|
+
/** Constructs a DdbDict object, which supports two usages:
|
|
297
|
+
- 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>
|
|
298
|
+
- Pass in js object (type is Record<string, boolean | string | DdbObj>), automatically converted to DdbDict of dict<string, any>
|
|
299
|
+
*/
|
|
300
|
+
export declare class DdbDict extends DdbObj<DdbDictValue> {
|
|
301
|
+
constructor(obj: Record<string, boolean | string | DdbObj>);
|
|
302
|
+
constructor(keys: DdbObj<DdbVectorValue>, values: DdbObj<DdbVectorValue>);
|
|
303
|
+
}
|
|
252
304
|
export declare class DdbTable extends DdbObj<DdbObj[]> {
|
|
253
305
|
constructor(columns: DdbObj[], name?: string);
|
|
254
306
|
}
|
|
@@ -467,10 +519,6 @@ export declare class DDB {
|
|
|
467
519
|
}): Promise<DdbObj<DdbValue>>;
|
|
468
520
|
/** 解析服务端响应报文,返回去掉 header 的 data buf */
|
|
469
521
|
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
522
|
}
|
|
475
523
|
export interface DdbMessageListener {
|
|
476
524
|
(message: DdbMessage, _this: DDB): any;
|
package/browser.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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"));
|
|
@@ -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,19 @@ 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[DdbChartType["stack"] = 9] = "stack";
|
|
111
|
+
})(DdbChartType = exports.DdbChartType || (exports.DdbChartType = {}));
|
|
98
112
|
exports.nulls = {
|
|
99
113
|
int8: -0x80,
|
|
100
114
|
int16: -32768,
|
|
@@ -199,7 +213,8 @@ class DdbObj {
|
|
|
199
213
|
value,
|
|
200
214
|
});
|
|
201
215
|
}
|
|
202
|
-
case DdbForm.dict:
|
|
216
|
+
case DdbForm.dict:
|
|
217
|
+
case DdbForm.chart: {
|
|
203
218
|
// <Buffer 19 05 type = any, form = dict
|
|
204
219
|
// 12 01 keys.type = string, keys.form = vector
|
|
205
220
|
// 03 00 00 00 01 00 00 00 keys.cols = 3, keys.rows = 1
|
|
@@ -211,9 +226,9 @@ class DdbObj {
|
|
|
211
226
|
keys.length += 2;
|
|
212
227
|
let values = this.parse_vector(buf_data.subarray(keys.length + 2), le, buf_data[keys.length]);
|
|
213
228
|
values.length += 2;
|
|
214
|
-
|
|
229
|
+
let dict = new this({
|
|
215
230
|
le,
|
|
216
|
-
form,
|
|
231
|
+
form: DdbForm.dict,
|
|
217
232
|
type,
|
|
218
233
|
length: i_data + keys.length + values.length,
|
|
219
234
|
rows: keys.rows,
|
|
@@ -223,6 +238,30 @@ class DdbObj {
|
|
|
223
238
|
values
|
|
224
239
|
],
|
|
225
240
|
});
|
|
241
|
+
if (form === DdbForm.dict)
|
|
242
|
+
return dict;
|
|
243
|
+
else {
|
|
244
|
+
const { chartType: type, stacking, title: titles, extras, data, ...others } = dict.to_dict();
|
|
245
|
+
const [chart, x_axis, y_axis] = titles.value;
|
|
246
|
+
const { multiYAxes: multi_y_axis, ...extras_others } = extras.to_dict({ strip: true });
|
|
247
|
+
dict.form = DdbForm.chart;
|
|
248
|
+
dict.value = {
|
|
249
|
+
type: type.value,
|
|
250
|
+
stacking: stacking.value,
|
|
251
|
+
titles: {
|
|
252
|
+
chart,
|
|
253
|
+
x_axis,
|
|
254
|
+
y_axis,
|
|
255
|
+
},
|
|
256
|
+
extras: {
|
|
257
|
+
multi_y_axis,
|
|
258
|
+
...extras_others,
|
|
259
|
+
},
|
|
260
|
+
data,
|
|
261
|
+
...others,
|
|
262
|
+
};
|
|
263
|
+
return dict;
|
|
264
|
+
}
|
|
226
265
|
}
|
|
227
266
|
case DdbForm.matrix: {
|
|
228
267
|
// rename!(
|
|
@@ -792,6 +831,23 @@ class DdbObj {
|
|
|
792
831
|
value[0].pack(),
|
|
793
832
|
value[1].pack(),
|
|
794
833
|
];
|
|
834
|
+
case DdbForm.chart: {
|
|
835
|
+
const { type, stacking, titles: { chart, x_axis, y_axis, }, extras: { multi_y_axis, ...extras_other }, data } = this.value;
|
|
836
|
+
const { value: [keys, values] } = new DdbDict({
|
|
837
|
+
chartType: new DdbInt(type),
|
|
838
|
+
stacking,
|
|
839
|
+
title: new DdbVectorString([chart, x_axis, y_axis]),
|
|
840
|
+
extras: new DdbDict({
|
|
841
|
+
multiYAxis: multi_y_axis,
|
|
842
|
+
...extras_other
|
|
843
|
+
}),
|
|
844
|
+
data,
|
|
845
|
+
});
|
|
846
|
+
return [
|
|
847
|
+
keys.pack(),
|
|
848
|
+
values.pack(),
|
|
849
|
+
];
|
|
850
|
+
}
|
|
795
851
|
case DdbForm.matrix: {
|
|
796
852
|
const { rows, cols, data } = value;
|
|
797
853
|
return [
|
|
@@ -804,7 +860,7 @@ class DdbObj {
|
|
|
804
860
|
];
|
|
805
861
|
}
|
|
806
862
|
default:
|
|
807
|
-
throw new Error(`${DdbForm[form]}
|
|
863
|
+
throw new Error(`${DdbForm[form]} Serialization is not currently supported`);
|
|
808
864
|
}
|
|
809
865
|
})();
|
|
810
866
|
if (!body)
|
|
@@ -917,6 +973,8 @@ class DdbObj {
|
|
|
917
973
|
return `table[${this.rows}r][${this.cols}c]`;
|
|
918
974
|
case DdbForm.dict:
|
|
919
975
|
return `dict<${DdbType[this.value[0].type]}, ${DdbType[this.value[1].type]}>`;
|
|
976
|
+
case DdbForm.chart:
|
|
977
|
+
return `chart<${DdbChartType[this.value.type]}>`;
|
|
920
978
|
case DdbForm.matrix:
|
|
921
979
|
return `matrix<${tname}>[${this.rows}r][${this.cols}c]`;
|
|
922
980
|
default:
|
|
@@ -1010,6 +1068,24 @@ class DdbObj {
|
|
|
1010
1068
|
})();
|
|
1011
1069
|
return `${type}(${this.name ? `'${this.name}', ` : ''}${data})\n`;
|
|
1012
1070
|
}
|
|
1071
|
+
/** 自动转换 js string, boolean 为 DdbObj */
|
|
1072
|
+
static to_ddbobj(value) {
|
|
1073
|
+
if (value && value instanceof DdbObj)
|
|
1074
|
+
return value;
|
|
1075
|
+
const type = typeof value;
|
|
1076
|
+
switch (type) {
|
|
1077
|
+
case 'string':
|
|
1078
|
+
return new DdbString(value);
|
|
1079
|
+
case 'boolean':
|
|
1080
|
+
return new DdbBool(value);
|
|
1081
|
+
default:
|
|
1082
|
+
throw new Error(`Cannot automatically convert ${type} to DdbObj`);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
/** 转换 js 数组为 DdbObj[] */
|
|
1086
|
+
static to_ddbobjs(values) {
|
|
1087
|
+
return values.map(value => this.to_ddbobj(value));
|
|
1088
|
+
}
|
|
1013
1089
|
to_cols() {
|
|
1014
1090
|
return this.value.map(col => {
|
|
1015
1091
|
let col_ = {
|
|
@@ -1063,13 +1139,22 @@ class DdbObj {
|
|
|
1063
1139
|
}
|
|
1064
1140
|
return rows;
|
|
1065
1141
|
}
|
|
1066
|
-
to_dict() {
|
|
1142
|
+
to_dict({ strip, deep, } = {}) {
|
|
1067
1143
|
if (this.form !== DdbForm.dict)
|
|
1068
|
-
throw new Error('this.form is not DdbForm.dict
|
|
1069
|
-
const [{ value: keys }, { value: values }] = this.value;
|
|
1144
|
+
throw new Error('this.form is not DdbForm.dict and cannot be converted to js object');
|
|
1145
|
+
const [{ value: keys, type: key_type }, { value: values, type: value_type }] = this.value;
|
|
1146
|
+
if (key_type !== DdbType.string || value_type !== DdbType.any)
|
|
1147
|
+
throw new Error('Not dict<string, any>, automatic conversion to js object is not supported for the time being');
|
|
1148
|
+
if (deep && !strip)
|
|
1149
|
+
throw new Error('strip = true must be set when deep = true');
|
|
1070
1150
|
let obj = {};
|
|
1071
|
-
for (let i = 0; i < this.rows; i++)
|
|
1072
|
-
|
|
1151
|
+
for (let i = 0; i < this.rows; i++) {
|
|
1152
|
+
let value = values[i];
|
|
1153
|
+
if (deep && value.form === DdbForm.dict)
|
|
1154
|
+
obj[keys[i]] = value.to_dict({ strip, deep });
|
|
1155
|
+
else
|
|
1156
|
+
obj[keys[i]] = strip ? value.value : value;
|
|
1157
|
+
}
|
|
1073
1158
|
return obj;
|
|
1074
1159
|
}
|
|
1075
1160
|
}
|
|
@@ -1401,7 +1486,7 @@ class DdbVectorAny extends DdbObj {
|
|
|
1401
1486
|
type: DdbType.any,
|
|
1402
1487
|
rows: objs.length,
|
|
1403
1488
|
cols: 1,
|
|
1404
|
-
value: objs,
|
|
1489
|
+
value: DdbObj.to_ddbobjs(objs),
|
|
1405
1490
|
name,
|
|
1406
1491
|
});
|
|
1407
1492
|
}
|
|
@@ -1493,6 +1578,36 @@ class DdbSetString extends DdbObj {
|
|
|
1493
1578
|
}
|
|
1494
1579
|
}
|
|
1495
1580
|
exports.DdbSetString = DdbSetString;
|
|
1581
|
+
/** Constructs a DdbDict object, which supports two usages:
|
|
1582
|
+
- 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>
|
|
1583
|
+
- Pass in js object (type is Record<string, boolean | string | DdbObj>), automatically converted to DdbDict of dict<string, any>
|
|
1584
|
+
*/
|
|
1585
|
+
class DdbDict extends DdbObj {
|
|
1586
|
+
constructor(arg0, arg1) {
|
|
1587
|
+
if (arg1)
|
|
1588
|
+
super({
|
|
1589
|
+
form: DdbForm.dict,
|
|
1590
|
+
type: arg1.type,
|
|
1591
|
+
rows: arg0.rows,
|
|
1592
|
+
cols: 2,
|
|
1593
|
+
value: [arg0, arg1]
|
|
1594
|
+
});
|
|
1595
|
+
else {
|
|
1596
|
+
const keys = Object.keys(arg0);
|
|
1597
|
+
super({
|
|
1598
|
+
form: DdbForm.dict,
|
|
1599
|
+
type: DdbType.any,
|
|
1600
|
+
rows: keys.length,
|
|
1601
|
+
cols: 2,
|
|
1602
|
+
value: [
|
|
1603
|
+
new DdbVectorString(keys),
|
|
1604
|
+
new DdbVectorAny(Object.values(arg0))
|
|
1605
|
+
]
|
|
1606
|
+
});
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
exports.DdbDict = DdbDict;
|
|
1496
1611
|
class DdbTable extends DdbObj {
|
|
1497
1612
|
constructor(columns, name = '') {
|
|
1498
1613
|
super({
|
|
@@ -1989,7 +2104,7 @@ class DDB {
|
|
|
1989
2104
|
reject(error);
|
|
1990
2105
|
}
|
|
1991
2106
|
};
|
|
1992
|
-
args =
|
|
2107
|
+
args = DdbObj.to_ddbobjs(args);
|
|
1993
2108
|
const command = this.enc.encode((() => {
|
|
1994
2109
|
switch (type) {
|
|
1995
2110
|
case 'function':
|
|
@@ -2057,7 +2172,7 @@ class DDB {
|
|
|
2057
2172
|
args = [
|
|
2058
2173
|
new DdbVectorString(nodes),
|
|
2059
2174
|
func,
|
|
2060
|
-
new DdbVectorAny(
|
|
2175
|
+
new DdbVectorAny(args),
|
|
2061
2176
|
...(() => {
|
|
2062
2177
|
if (typeof add_node_alias !== 'undefined')
|
|
2063
2178
|
return [add_node_alias];
|
|
@@ -2138,24 +2253,6 @@ class DDB {
|
|
|
2138
2253
|
})
|
|
2139
2254
|
};
|
|
2140
2255
|
}
|
|
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
2256
|
}
|
|
2160
2257
|
exports.DDB = DDB;
|
|
2161
2258
|
/** little endian (client) */
|