dolphindb 2.0.529 → 2.0.532
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 +2 -1
- package/browser.js +37 -31
- package/browser.js.map +1 -1
- package/index.js +6 -2
- package/index.js.map +1 -1
- package/package.json +5 -5
package/browser.d.ts
CHANGED
|
@@ -206,7 +206,8 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
|
|
|
206
206
|
];
|
|
207
207
|
pack(): Uint8Array;
|
|
208
208
|
static pack_vector_body(value: DdbVectorValue, type: DdbType, length: number): ArrayBufferView[];
|
|
209
|
-
toString(): any;
|
|
209
|
+
toString(colors?: boolean): any;
|
|
210
|
+
inspect_type(): string;
|
|
210
211
|
/** 自动转换 js string, boolean 为 DdbObj */
|
|
211
212
|
static to_ddbobj(value: DdbObj | string | boolean): DdbObj;
|
|
212
213
|
/** 转换 js 数组为 DdbObj[] */
|
package/browser.js
CHANGED
|
@@ -4,6 +4,7 @@ dayjs.extend(DayjsCustomParseFormat);
|
|
|
4
4
|
import ipaddrjs from 'ipaddr.js';
|
|
5
5
|
const { fromByteArray: buf2ipaddr } = ipaddrjs;
|
|
6
6
|
import 'xshell/prototype.browser.js';
|
|
7
|
+
import { blue } from 'xshell/chalk.browser.js';
|
|
7
8
|
import { concat } from 'xshell/utils.browser.js';
|
|
8
9
|
import { connect_websocket } from 'xshell/net.browser.js';
|
|
9
10
|
export var DdbForm;
|
|
@@ -415,7 +416,9 @@ export class DdbObj {
|
|
|
415
416
|
case DdbType.symbol:
|
|
416
417
|
case DdbType.code:
|
|
417
418
|
case DdbType.handle:
|
|
418
|
-
case DdbType.functiondef:
|
|
419
|
+
case DdbType.functiondef:
|
|
420
|
+
// mysql 插件 connect 方法会返回 resource 类型的对象
|
|
421
|
+
case DdbType.resource: {
|
|
419
422
|
const i_head = type === DdbType.functiondef ? 1 : 0;
|
|
420
423
|
let i_zero = buf.indexOf(0, i_head);
|
|
421
424
|
let i_end; // 整个字符串(包括 0)的末尾,excluding
|
|
@@ -793,6 +796,7 @@ export class DdbObj {
|
|
|
793
796
|
case DdbType.symbol:
|
|
794
797
|
case DdbType.code:
|
|
795
798
|
case DdbType.handle:
|
|
799
|
+
case DdbType.resource:
|
|
796
800
|
return [
|
|
797
801
|
DdbObj.enc.encode(value),
|
|
798
802
|
Uint8Array.of(0),
|
|
@@ -988,34 +992,8 @@ export class DdbObj {
|
|
|
988
992
|
throw new Error(`vector ${DdbType[type]} 暂不支持序列化`);
|
|
989
993
|
}
|
|
990
994
|
}
|
|
991
|
-
toString() {
|
|
992
|
-
const type = (
|
|
993
|
-
const tname = DdbType[this.type];
|
|
994
|
-
switch (this.form) {
|
|
995
|
-
case DdbForm.scalar:
|
|
996
|
-
if (this.type === DdbType.functiondef)
|
|
997
|
-
return `functiondef<${DdbFunctionType[this.value.type]}>`;
|
|
998
|
-
return tname;
|
|
999
|
-
case DdbForm.vector:
|
|
1000
|
-
if (64 <= this.type && this.type < 128)
|
|
1001
|
-
return `${DdbType[this.type - 64]}[][${this.rows}]`;
|
|
1002
|
-
return `${tname}[${this.rows}]`;
|
|
1003
|
-
case DdbForm.pair:
|
|
1004
|
-
return `pair<${tname}>`;
|
|
1005
|
-
case DdbForm.set:
|
|
1006
|
-
return `set<${tname}>[${this.rows}]`;
|
|
1007
|
-
case DdbForm.table:
|
|
1008
|
-
return `table[${this.rows}r][${this.cols}c]`;
|
|
1009
|
-
case DdbForm.dict:
|
|
1010
|
-
return `dict<${DdbType[this.value[0].type]}, ${DdbType[this.value[1].type]}>`;
|
|
1011
|
-
case DdbForm.chart:
|
|
1012
|
-
return `chart<${DdbChartType[this.value.type]}>`;
|
|
1013
|
-
case DdbForm.matrix:
|
|
1014
|
-
return `matrix<${tname}>[${this.rows}r][${this.cols}c]`;
|
|
1015
|
-
default:
|
|
1016
|
-
return `${DdbForm[this.form]} ${tname}`;
|
|
1017
|
-
}
|
|
1018
|
-
})();
|
|
995
|
+
toString(colors = false) {
|
|
996
|
+
const type = this.inspect_type();
|
|
1019
997
|
const data = (() => {
|
|
1020
998
|
switch (this.form) {
|
|
1021
999
|
case DdbForm.scalar:
|
|
@@ -1103,7 +1081,34 @@ export class DdbObj {
|
|
|
1103
1081
|
}
|
|
1104
1082
|
return String(this.value);
|
|
1105
1083
|
})();
|
|
1106
|
-
return `${type}(${this.name ? `'${this.name}', ` : ''}${data})\n`;
|
|
1084
|
+
return `${colors ? blue(type) : type}(${this.name ? `'${this.name}', ` : ''}${data})\n`;
|
|
1085
|
+
}
|
|
1086
|
+
inspect_type() {
|
|
1087
|
+
const tname = DdbType[this.type];
|
|
1088
|
+
switch (this.form) {
|
|
1089
|
+
case DdbForm.scalar:
|
|
1090
|
+
if (this.type === DdbType.functiondef)
|
|
1091
|
+
return `functiondef<${DdbFunctionType[this.value.type]}>`;
|
|
1092
|
+
return tname;
|
|
1093
|
+
case DdbForm.vector:
|
|
1094
|
+
if (64 <= this.type && this.type < 128)
|
|
1095
|
+
return `${DdbType[this.type - 64]}[][${this.rows}]`;
|
|
1096
|
+
return `${tname}[${this.rows}]`;
|
|
1097
|
+
case DdbForm.pair:
|
|
1098
|
+
return `pair<${tname}>`;
|
|
1099
|
+
case DdbForm.set:
|
|
1100
|
+
return `set<${tname}>[${this.rows}]`;
|
|
1101
|
+
case DdbForm.table:
|
|
1102
|
+
return `table[${this.rows}r][${this.cols}c]`;
|
|
1103
|
+
case DdbForm.dict:
|
|
1104
|
+
return `dict<${DdbType[this.value[0].type]}, ${DdbType[this.value[1].type]}>`;
|
|
1105
|
+
case DdbForm.chart:
|
|
1106
|
+
return `chart<${DdbChartType[this.value.type]}>`;
|
|
1107
|
+
case DdbForm.matrix:
|
|
1108
|
+
return `matrix<${tname}>[${this.rows}r][${this.cols}c]`;
|
|
1109
|
+
default:
|
|
1110
|
+
return `${DdbForm[this.form]} ${tname}`;
|
|
1111
|
+
}
|
|
1107
1112
|
}
|
|
1108
1113
|
/** 自动转换 js string, boolean 为 DdbObj */
|
|
1109
1114
|
static to_ddbobj(value) {
|
|
@@ -1291,6 +1296,7 @@ export function format(type, value, le) {
|
|
|
1291
1296
|
return value.name.quote('single');
|
|
1292
1297
|
case DdbType.handle:
|
|
1293
1298
|
case DdbType.code:
|
|
1299
|
+
case DdbType.resource:
|
|
1294
1300
|
return value.quote('single');
|
|
1295
1301
|
case DdbType.datehour:
|
|
1296
1302
|
return (value === null || value === nulls.int32) ?
|
|
@@ -1949,7 +1955,7 @@ export class DDB {
|
|
|
1949
1955
|
this.websocket = websocket;
|
|
1950
1956
|
await this.rpc('connect', {});
|
|
1951
1957
|
},
|
|
1952
|
-
on_message: event => {
|
|
1958
|
+
on_message: (event) => {
|
|
1953
1959
|
this.on_message(event);
|
|
1954
1960
|
}
|
|
1955
1961
|
});
|