dolphindb 0.0.12 → 0.0.13

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.js CHANGED
@@ -152,7 +152,7 @@ class DdbObj {
152
152
  le,
153
153
  form,
154
154
  type,
155
- length: 2 + length,
155
+ length: i_data + length,
156
156
  value,
157
157
  });
158
158
  }
@@ -160,7 +160,7 @@ class DdbObj {
160
160
  case DdbForm.pair:
161
161
  case DdbForm.set: {
162
162
  let vector = this.parse_vector(buf_data, le, type);
163
- vector.length += 2;
163
+ vector.length += i_data;
164
164
  vector.form = form;
165
165
  return vector;
166
166
  }
@@ -191,17 +191,17 @@ class DdbObj {
191
191
  let i_start = i_items_start + len_items;
192
192
  for (let i = 0; i < cols; i++) {
193
193
  const type = buf_data[i_start];
194
- const i_vector_head = i_start + 2;
195
- let col = this.parse_vector(buf_data.subarray(i_vector_head), le, type);
194
+ let col = this.parse_vector(buf_data.subarray(i_start + 2), le, type);
195
+ col.length += 2;
196
196
  col.name = colnames[i];
197
197
  value[i] = col;
198
- i_start = i_vector_head + col.length;
198
+ i_start += col.length;
199
199
  }
200
200
  return new this({
201
201
  le,
202
202
  form,
203
203
  type,
204
- length: i_start,
204
+ length: i_data + i_start,
205
205
  name,
206
206
  rows,
207
207
  cols,
@@ -224,7 +224,7 @@ class DdbObj {
224
224
  le,
225
225
  form,
226
226
  type,
227
- length: 2 + keys.length + values.length,
227
+ length: i_data + keys.length + values.length,
228
228
  rows: keys.rows,
229
229
  cols: 2,
230
230
  value: [
@@ -257,7 +257,7 @@ class DdbObj {
257
257
  le,
258
258
  form,
259
259
  type,
260
- length: 11 + len_items,
260
+ length: i_data + 11 + len_items,
261
261
  rows,
262
262
  cols,
263
263
  datatype,
@@ -269,7 +269,7 @@ class DdbObj {
269
269
  le,
270
270
  form,
271
271
  type,
272
- length: buf_data.length,
272
+ length: i_data + buf_data.length,
273
273
  value: buf_data
274
274
  });
275
275
  }
@@ -810,7 +810,7 @@ class DdbObj {
810
810
  throw new Error(`vector ${DdbType[type]} 暂不支持序列化`);
811
811
  }
812
812
  }
813
- [utils_js_1.inspect.custom]() {
813
+ [utils_js_1.inspect.custom](depth, options, _inspect) {
814
814
  const type = (() => {
815
815
  const tname = DdbType[this.type];
816
816
  switch (this.form) {
@@ -825,7 +825,7 @@ class DdbObj {
825
825
  case DdbForm.pair:
826
826
  return `pair<${tname}>`;
827
827
  case DdbForm.set:
828
- return `set<${tname}>`;
828
+ return `set<${tname}>[${this.rows}]`;
829
829
  case DdbForm.table:
830
830
  return `table[${this.rows} rows][${this.cols} cols]`;
831
831
  case DdbForm.dict:
@@ -838,14 +838,37 @@ class DdbObj {
838
838
  })();
839
839
  const data = (() => {
840
840
  if (this.form === DdbForm.pair)
841
- return `${(0, utils_js_1.inspect)(this.value[0])}, ${(0, utils_js_1.inspect)(this.value[1])}`;
841
+ return `${(0, utils_js_1.inspect)(this.value[0], options)}, ${(0, utils_js_1.inspect)(this.value[1], options)}`;
842
842
  if (this.form === DdbForm.scalar && this.type === DdbType.functiondef)
843
- return (0, utils_js_1.inspect)(this.value.name);
843
+ return (0, utils_js_1.inspect)(this.value.name, options);
844
844
  if (this.value instanceof Uint8Array)
845
- return (0, utils_js_1.inspect)((0, utils_js_1.typed_array_to_buffer)(this.value));
846
- return (0, utils_js_1.inspect)(this.value);
845
+ return (0, utils_js_1.inspect)((0, utils_js_1.typed_array_to_buffer)(this.value), options);
846
+ return (0, utils_js_1.inspect)(this.value, options);
847
847
  })();
848
- return `${type.blue}(${this.name ? `${(0, utils_js_1.inspect)(this.name)}, ` : ''}${data})`;
848
+ return `${options.colors ? type.blue : type}(${this.name ? `${(0, utils_js_1.inspect)(this.name, options)}, ` : ''}${data})`;
849
+ }
850
+ to_rows() {
851
+ if (this.form !== DdbForm.table)
852
+ throw new Error('this.form is not DdbForm.table, cannot call to_rows');
853
+ let rows = new Array(this.rows);
854
+ for (let i = 0; i < this.rows; i++) {
855
+ let row = {};
856
+ for (let j = 0; j < this.cols; j++) {
857
+ const { type, name, value } = this.value[j]; // column
858
+ switch (type) {
859
+ case DdbType.bool:
860
+ row[name] = Boolean(value[i]);
861
+ break;
862
+ case DdbType.ipaddr:
863
+ row[name] = value.subarray(16 * i, 16 * (i + 1));
864
+ break;
865
+ default:
866
+ row[name] = value[i];
867
+ }
868
+ }
869
+ rows[i] = row;
870
+ }
871
+ return rows;
849
872
  }
850
873
  to_dict() {
851
874
  if (this.form !== DdbForm.dict)