dolphindb 2.0.1024 → 2.0.1026
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 +53 -13
- package/browser.js.map +1 -1
- package/docs.en.json +21 -14
- package/docs.zh.json +36 -15
- package/index.d.ts +1 -0
- package/index.js +53 -14
- package/index.js.map +1 -1
- package/package.json +9 -9
- package/test.js +16 -8
- package/test.js.map +1 -1
package/browser.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import 'xshell/prototype.browser.js';
|
|
|
2
2
|
import { Lock } from 'xshell/utils.browser.js';
|
|
3
3
|
import { type WebSocketConnectionError } from 'xshell/net.browser.js';
|
|
4
4
|
import { type DdbDecimal128Value, type DdbDecimal128VectorValue } from './data-types/decimal-128.js';
|
|
5
|
-
import { BigInt128Array } from './shared/bigint-128-array.js';
|
|
5
|
+
import type { BigInt128Array } from './shared/bigint-128-array.js';
|
|
6
6
|
import { DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType } from './shared/constants.js';
|
|
7
7
|
export * from './shared/constants.js';
|
|
8
8
|
export type { DdbDecimal128Value, DdbDecimal128VectorValue } from './data-types/decimal-128.js';
|
|
@@ -163,6 +163,7 @@ export declare class DdbObj<TValue extends DdbValue = DdbValue> {
|
|
|
163
163
|
dataIndex: string;
|
|
164
164
|
render: (value: any) => string;
|
|
165
165
|
}[];
|
|
166
|
+
/** 将 table 转换为 rows,空值转换为 null */
|
|
166
167
|
to_rows<T extends Record<string, any> = Record<string, any>>(): T[];
|
|
167
168
|
/** 将 dict<string, any> 自动转换为 js object (Record<string, any>) Automatically convert dict<string, any> to js object (Record<string, any>)
|
|
168
169
|
- options?:
|
package/browser.js
CHANGED
|
@@ -1027,14 +1027,14 @@ export class DdbObj {
|
|
|
1027
1027
|
case DdbType.decimal64:
|
|
1028
1028
|
case DdbType.decimal128:
|
|
1029
1029
|
const x = data[acc_len + i];
|
|
1030
|
-
if (is_decimal_null_value(type_, x))
|
|
1030
|
+
if (is_decimal_null_value(type_, x))
|
|
1031
1031
|
items[i] = '';
|
|
1032
|
-
|
|
1032
|
+
else {
|
|
1033
|
+
const { scale } = this.value;
|
|
1034
|
+
const s = String(x < 0 ? -x : x).padStart(scale, '0');
|
|
1035
|
+
const str = (x < 0 ? '-' : '') + (scale ? `${s.slice(0, -scale) || '0'}.${s.slice(-scale)}` : s);
|
|
1036
|
+
items[i] = options.colors ? green(str) : str;
|
|
1033
1037
|
}
|
|
1034
|
-
const { scale } = this.value;
|
|
1035
|
-
const s = String(x < 0 ? -x : x).padStart(scale, '0');
|
|
1036
|
-
const str = (x < 0 ? '-' : '') + (scale ? `${s.slice(0, -scale) || '0'}.${s.slice(-scale)}` : s);
|
|
1037
|
-
items[i] = options.colors ? green(str) : str;
|
|
1038
1038
|
break;
|
|
1039
1039
|
case DdbType.complex:
|
|
1040
1040
|
case DdbType.point: {
|
|
@@ -1176,6 +1176,7 @@ export class DdbObj {
|
|
|
1176
1176
|
render: value => format(col.type, value, col.le, { nullstr: false, quote: false })
|
|
1177
1177
|
}));
|
|
1178
1178
|
}
|
|
1179
|
+
/** 将 table 转换为 rows,空值转换为 null */
|
|
1179
1180
|
to_rows() {
|
|
1180
1181
|
assert(this.form === DdbForm.table, t('form 必须是 DdbForm.table, 否则不能 to_rows'));
|
|
1181
1182
|
let rows = new Array(this.rows);
|
|
@@ -1192,6 +1193,42 @@ export class DdbObj {
|
|
|
1192
1193
|
Boolean(value);
|
|
1193
1194
|
break;
|
|
1194
1195
|
}
|
|
1196
|
+
case DdbType.char:
|
|
1197
|
+
row[name] = values[i] === nulls.int8 ? null : values[i];
|
|
1198
|
+
break;
|
|
1199
|
+
case DdbType.short:
|
|
1200
|
+
row[name] = values[i] === nulls.int16 ? null : values[i];
|
|
1201
|
+
break;
|
|
1202
|
+
case DdbType.int:
|
|
1203
|
+
case DdbType.date:
|
|
1204
|
+
case DdbType.month:
|
|
1205
|
+
case DdbType.time:
|
|
1206
|
+
case DdbType.minute:
|
|
1207
|
+
case DdbType.second:
|
|
1208
|
+
case DdbType.datetime:
|
|
1209
|
+
case DdbType.datehour:
|
|
1210
|
+
row[name] = values[i] === nulls.int32 ? null : values[i];
|
|
1211
|
+
break;
|
|
1212
|
+
case DdbType.long:
|
|
1213
|
+
case DdbType.timestamp:
|
|
1214
|
+
case DdbType.nanotime:
|
|
1215
|
+
case DdbType.nanotimestamp:
|
|
1216
|
+
row[name] = values[i] === nulls.int64 ? null : values[i];
|
|
1217
|
+
break;
|
|
1218
|
+
case DdbType.int128:
|
|
1219
|
+
row[name] = values[i] === nulls.int128 ? null : values[i];
|
|
1220
|
+
break;
|
|
1221
|
+
case DdbType.float:
|
|
1222
|
+
row[name] = values[i] === nulls.float32 ? null : values[i];
|
|
1223
|
+
break;
|
|
1224
|
+
case DdbType.double:
|
|
1225
|
+
row[name] = values[i] === nulls.double ? null : values[i];
|
|
1226
|
+
break;
|
|
1227
|
+
case DdbType.decimal32:
|
|
1228
|
+
case DdbType.decimal64:
|
|
1229
|
+
case DdbType.decimal128:
|
|
1230
|
+
row[name] = is_decimal_null_value(type, values[i]) ? null : values[i];
|
|
1231
|
+
break;
|
|
1195
1232
|
case DdbType.ipaddr:
|
|
1196
1233
|
row[name] = values.subarray(16 * i, 16 * (i + 1));
|
|
1197
1234
|
break;
|
|
@@ -1457,6 +1494,8 @@ export function formati(obj, index, options = {}) {
|
|
|
1457
1494
|
// av
|
|
1458
1495
|
const type_ = obj.type - 64;
|
|
1459
1496
|
let offset = 0;
|
|
1497
|
+
// array vector 中每一项如果为 null 都展示,避免多个逗号堆在一起的情况
|
|
1498
|
+
options = { ...options, nullstr: true };
|
|
1460
1499
|
for (const { lengths, data, rows } of obj.value) {
|
|
1461
1500
|
let acc_len = 0;
|
|
1462
1501
|
if (offset + rows <= index) {
|
|
@@ -1477,14 +1516,15 @@ export function formati(obj, index, options = {}) {
|
|
|
1477
1516
|
case DdbType.decimal64:
|
|
1478
1517
|
case DdbType.decimal128:
|
|
1479
1518
|
const x = data[acc_len + i];
|
|
1480
|
-
if (is_decimal_null_value(type_, x))
|
|
1481
|
-
items[i] = '';
|
|
1482
|
-
|
|
1519
|
+
if (is_decimal_null_value(type_, x))
|
|
1520
|
+
items[i] = options.colors ? grey('null') : 'null';
|
|
1521
|
+
else {
|
|
1522
|
+
const { scale } = obj.value;
|
|
1523
|
+
const s = String(x < 0 ? -x : x).padStart(scale, '0');
|
|
1524
|
+
const str = (x < 0 ? '-' : '') + (scale ? `${s.slice(0, -scale) || '0'}.${s.slice(-scale)}` : s);
|
|
1525
|
+
if (options.colors)
|
|
1526
|
+
items[i] = green(str);
|
|
1483
1527
|
}
|
|
1484
|
-
const { scale } = obj.value;
|
|
1485
|
-
const s = String(x < 0 ? -x : x).padStart(scale, '0');
|
|
1486
|
-
const str = (x < 0 ? '-' : '') + (scale ? `${s.slice(0, -scale) || '0'}.${s.slice(-scale)}` : s);
|
|
1487
|
-
items[i] = options.colors ? green(str) : str;
|
|
1488
1528
|
break;
|
|
1489
1529
|
case DdbType.complex:
|
|
1490
1530
|
case DdbType.point: {
|