dolphindb 2.0.527 → 2.0.530

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
@@ -128,8 +128,8 @@ export interface DdbChartValue {
128
128
  x_axis: string;
129
129
  y_axis: string;
130
130
  };
131
- extras: {
132
- multi_y_axis: boolean;
131
+ extras?: {
132
+ multi_y_axes: boolean;
133
133
  };
134
134
  data: DdbObj<DdbMatrixValue>;
135
135
  }
@@ -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
@@ -269,7 +269,6 @@ export class DdbObj {
269
269
  else {
270
270
  const { chartType: type, stacking, title: titles, extras, data, ...others } = dict.to_dict();
271
271
  const [chart, x_axis, y_axis] = titles.value;
272
- const { multiYAxes: multi_y_axis, ...extras_others } = extras.to_dict({ strip: true });
273
272
  dict.form = DdbForm.chart;
274
273
  dict.value = {
275
274
  type: type.value,
@@ -279,10 +278,15 @@ export class DdbObj {
279
278
  x_axis,
280
279
  y_axis,
281
280
  },
282
- extras: {
283
- multi_y_axis,
284
- ...extras_others,
285
- },
281
+ ...extras ? (() => {
282
+ const { multiYAxes: multi_y_axes = false, ...extras_others } = extras.to_dict({ strip: true });
283
+ return {
284
+ extras: {
285
+ multi_y_axes,
286
+ ...extras_others,
287
+ }
288
+ };
289
+ })() : {},
286
290
  data,
287
291
  ...others,
288
292
  };
@@ -858,15 +862,20 @@ export class DdbObj {
858
862
  value[1].pack(),
859
863
  ];
860
864
  case DdbForm.chart: {
861
- const { type, stacking, titles: { chart, x_axis, y_axis, }, extras: { multi_y_axis, ...extras_other }, data } = this.value;
865
+ const { type, stacking, titles: { chart, x_axis, y_axis, }, extras, data } = this.value;
862
866
  const { value: [keys, values] } = new DdbDict({
863
867
  chartType: new DdbInt(type),
864
868
  stacking,
865
869
  title: new DdbVectorString([chart, x_axis, y_axis]),
866
- extras: new DdbDict({
867
- multiYAxis: multi_y_axis,
868
- ...extras_other
869
- }),
870
+ ...extras ? (() => {
871
+ const { multi_y_axes, ...extras_other } = extras;
872
+ return {
873
+ extras: new DdbDict({
874
+ multiYAxes: multi_y_axes,
875
+ ...extras_other
876
+ })
877
+ };
878
+ })() : {},
870
879
  data,
871
880
  });
872
881
  return [
@@ -980,33 +989,7 @@ export class DdbObj {
980
989
  }
981
990
  }
982
991
  [inspect.custom](depth, options, _inspect) {
983
- const type = (() => {
984
- const tname = DdbType[this.type];
985
- switch (this.form) {
986
- case DdbForm.scalar:
987
- if (this.type === DdbType.functiondef)
988
- return `functiondef<${DdbFunctionType[this.value.type]}>`;
989
- return tname;
990
- case DdbForm.vector:
991
- if (64 <= this.type && this.type < 128)
992
- return `${DdbType[this.type - 64]}[][${this.rows}]`;
993
- return `${tname}[${this.rows}]`;
994
- case DdbForm.pair:
995
- return `pair<${tname}>`;
996
- case DdbForm.set:
997
- return `set<${tname}>[${this.rows}]`;
998
- case DdbForm.table:
999
- return `table[${this.rows}r][${this.cols}c]`;
1000
- case DdbForm.dict:
1001
- return `dict<${DdbType[this.value[0].type]}, ${DdbType[this.value[1].type]}>`;
1002
- case DdbForm.chart:
1003
- return `chart<${DdbChartType[this.value.type]}>`;
1004
- case DdbForm.matrix:
1005
- return `matrix<${tname}>[${this.rows}r][${this.cols}c]`;
1006
- default:
1007
- return `${DdbForm[this.form]} ${tname}`;
1008
- }
1009
- })();
992
+ const type = this.inspect_type();
1010
993
  const data = (() => {
1011
994
  switch (this.form) {
1012
995
  case DdbForm.scalar:
@@ -1096,6 +1079,33 @@ export class DdbObj {
1096
1079
  })();
1097
1080
  return `${options.colors ? type.blue : type}(${this.name ? `${inspect(this.name, options)}, ` : ''}${data})`;
1098
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
+ }
1099
1109
  /** 自动转换 js string, boolean 为 DdbObj */
1100
1110
  static to_ddbobj(value) {
1101
1111
  if (value && value instanceof DdbObj)