dolphindb 2.0.528 → 2.0.531

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/index.d.ts CHANGED
@@ -209,6 +209,7 @@ export declare class DdbObj<T extends DdbValue = DdbValue> {
209
209
  pack(): Uint8Array;
210
210
  static pack_vector_body(value: DdbVectorValue, type: DdbType, length: number): ArrayBufferView[];
211
211
  [inspect.custom](depth: number, options: InspectOptions, _inspect: any): string;
212
+ inspect_type(): string;
212
213
  /** 自动转换 js string, boolean 为 DdbObj */
213
214
  static to_ddbobj(value: DdbObj | string | boolean): DdbObj;
214
215
  /** 转换 js 数组为 DdbObj[] */
package/index.js CHANGED
@@ -989,33 +989,7 @@ export class DdbObj {
989
989
  }
990
990
  }
991
991
  [inspect.custom](depth, options, _inspect) {
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
- })();
992
+ const type = this.inspect_type();
1019
993
  const data = (() => {
1020
994
  switch (this.form) {
1021
995
  case DdbForm.scalar:
@@ -1105,6 +1079,33 @@ export class DdbObj {
1105
1079
  })();
1106
1080
  return `${options.colors ? type.blue : type}(${this.name ? `${inspect(this.name, options)}, ` : ''}${data})`;
1107
1081
  }
1082
+ inspect_type() {
1083
+ const tname = DdbType[this.type];
1084
+ switch (this.form) {
1085
+ case DdbForm.scalar:
1086
+ if (this.type === DdbType.functiondef)
1087
+ return `functiondef<${DdbFunctionType[this.value.type]}>`;
1088
+ return tname;
1089
+ case DdbForm.vector:
1090
+ if (64 <= this.type && this.type < 128)
1091
+ return `${DdbType[this.type - 64]}[][${this.rows}]`;
1092
+ return `${tname}[${this.rows}]`;
1093
+ case DdbForm.pair:
1094
+ return `pair<${tname}>`;
1095
+ case DdbForm.set:
1096
+ return `set<${tname}>[${this.rows}]`;
1097
+ case DdbForm.table:
1098
+ return `table[${this.rows}r][${this.cols}c]`;
1099
+ case DdbForm.dict:
1100
+ return `dict<${DdbType[this.value[0].type]}, ${DdbType[this.value[1].type]}>`;
1101
+ case DdbForm.chart:
1102
+ return `chart<${DdbChartType[this.value.type]}>`;
1103
+ case DdbForm.matrix:
1104
+ return `matrix<${tname}>[${this.rows}r][${this.cols}c]`;
1105
+ default:
1106
+ return `${DdbForm[this.form]} ${tname}`;
1107
+ }
1108
+ }
1108
1109
  /** 自动转换 js string, boolean 为 DdbObj */
1109
1110
  static to_ddbobj(value) {
1110
1111
  if (value && value instanceof DdbObj)