dolphindb 3.0.40 → 3.0.42

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.js CHANGED
@@ -1670,7 +1670,7 @@ let _formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
1670
1670
  let _datetime_formatter = new Intl.DateTimeFormat('zh-CN', { dateStyle: 'short', timeStyle: 'medium', timeZone: 'UTC', hour12: false });
1671
1671
  /** 根据 DdbType 格式化单个元素 (value) 为字符串 */
1672
1672
  export function format(type, value, le, options = {}) {
1673
- const { nullstr = false, colors = false, quote = false, grouping = true } = options;
1673
+ const { nullstr = false, colors = false, quote = false, grouping = true, timestamp = 'ms' } = options;
1674
1674
  const formatter = (() => {
1675
1675
  const decimals = options.decimals ?? _decimals;
1676
1676
  if (decimals !== _decimals || grouping !== _grouping) {
@@ -1698,7 +1698,7 @@ export function format(type, value, le, options = {}) {
1698
1698
  let str;
1699
1699
  // formatter 可能会在 value 不属于 new Date() 有效值时,调用 抛出错误,这里统一处理
1700
1700
  try {
1701
- str = formatter(value);
1701
+ str = formatter(value, (type === DdbType.timestamp && timestamp === 's') ? 'YYYY.MM.DD HH:mm:ss' : undefined);
1702
1702
  }
1703
1703
  catch (error) {
1704
1704
  if (error instanceof RangeError)
@@ -1957,7 +1957,7 @@ export function formati(obj, index, options = {}) {
1957
1957
  }
1958
1958
  }
1959
1959
  }
1960
- export function convert(type, value, le, { blob = 'string' } = {}) {
1960
+ export function convert(type, value, le, { blob = 'string', timestamp = 'ms' } = {}) {
1961
1961
  switch (type) {
1962
1962
  case DdbType.void:
1963
1963
  return value === DdbVoidType.null ? null : undefined;
@@ -2012,7 +2012,7 @@ export function convert(type, value, le, { blob = 'string' } = {}) {
2012
2012
  case DdbType.decimal32:
2013
2013
  case DdbType.decimal64:
2014
2014
  case DdbType.decimal128:
2015
- return format(type, value, le, { colors: false });
2015
+ return format(type, value, le, { colors: false, timestamp });
2016
2016
  default:
2017
2017
  throw new Error(String(DdbType[type] || type) + t(' 暂时不支持转换为 js 对象'));
2018
2018
  }
@@ -3283,8 +3283,7 @@ export class DDB {
3283
3283
  let first = true;
3284
3284
  let win = {
3285
3285
  offset: 0,
3286
- rows: 0,
3287
- segments: [],
3286
+ data: [],
3288
3287
  objs: []
3289
3288
  };
3290
3289
  let schema;
@@ -3338,19 +3337,17 @@ export class DDB {
3338
3337
  data: seq(rows, i => zip_object(columns, seq(columns.length, j => _data[j][i])))
3339
3338
  };
3340
3339
  }
3341
- win.rows += rows;
3342
- win.segments.push(data);
3340
+ data.data.forEach(row => { win.data.push(row); });
3343
3341
  win.objs.push(obj);
3344
- if (win.rows >= winsize * 2 && win.segments.length >= 2) {
3342
+ if (win.data.length >= winsize * 2 && win.objs.length >= 2) {
3345
3343
  let winsize_ = 0;
3346
- let i = win.segments.length - 1;
3344
+ let i = win.objs.length - 1;
3347
3345
  // 往前移动至首个累计 winsize_ 超过 winsize 的位置
3348
3346
  for (; winsize_ < winsize; i--)
3349
- winsize_ += win.segments[i].data.length;
3350
- win.segments = win.segments.slice(i);
3347
+ winsize_ += win.objs[i].value[0].rows;
3348
+ win.offset += win.data.length - winsize_;
3349
+ win.data = win.data.slice(-winsize_);
3351
3350
  win.objs = win.objs.slice(i);
3352
- win.offset += win.rows - winsize_;
3353
- win.rows = winsize_;
3354
3351
  }
3355
3352
  }
3356
3353
  this.streaming.handler({