dolphindb 2.0.1102 → 2.0.1130
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 +6 -7
- package/browser.js +41 -77
- package/browser.js.map +1 -1
- package/index.d.ts +5 -6
- package/index.js +38 -84
- package/index.js.map +1 -1
- package/language.d.ts +1 -1
- package/language.js +1 -0
- package/language.js.map +1 -1
- package/package.json +8 -8
- package/shared/constants.d.ts +5 -0
- package/shared/constants.js +9 -0
- package/shared/constants.js.map +1 -1
- package/shared/utils.js.map +1 -1
- package/test.js +4 -1
- package/test.js.map +1 -1
- package/shared/utils/decimal-type.d.ts +0 -3
- package/shared/utils/decimal-type.js +0 -10
- package/shared/utils/decimal-type.js.map +0 -1
package/browser.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ 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
5
|
import type { BigInt128Array } from './shared/bigint-128-array.js';
|
|
6
|
-
import { DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType } from './shared/constants.js';
|
|
6
|
+
import { DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType, DdbVoidType } from './shared/constants.js';
|
|
7
7
|
export * from './shared/constants.js';
|
|
8
8
|
export type { DdbDecimal128Value, DdbDecimal128VectorValue } from './data-types/decimal-128.js';
|
|
9
9
|
export interface DdbFunctionDefValue {
|
|
@@ -194,10 +194,10 @@ export interface InspectOptions {
|
|
|
194
194
|
}
|
|
195
195
|
/** 根据 DdbType 格式化单个元素 (value) 为字符串 Formats a single element (value) as a string according to DdbType, null returns a 'null' string */
|
|
196
196
|
export declare function format(type: DdbType, value: DdbValue, le: boolean, options?: InspectOptions): string;
|
|
197
|
-
/** 格式化向量、集合中的第 index
|
|
197
|
+
/** 格式化向量、集合中的第 index 项为字符串,空值返回 'null' 字符串 formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
|
|
198
198
|
export declare function formati(obj: DdbVectorObj, index: number, options?: InspectOptions): string;
|
|
199
199
|
export declare class DdbVoid extends DdbObj<undefined> {
|
|
200
|
-
constructor();
|
|
200
|
+
constructor(value?: DdbVoidType);
|
|
201
201
|
}
|
|
202
202
|
export declare class DdbBool extends DdbObj<boolean> {
|
|
203
203
|
constructor(value: boolean | null);
|
|
@@ -286,13 +286,13 @@ export declare function second2ms(second: number | null): number | null;
|
|
|
286
286
|
export declare function second2str(second: number | null, format?: string): string;
|
|
287
287
|
export declare function datetime2ms(datetime: number | null): number | null;
|
|
288
288
|
export declare function datetime2str(datetime: number | null, format?: string): string;
|
|
289
|
+
/** _datetime_formatter.format 会在 date 为 Invalid Date 时抛出错误 */
|
|
289
290
|
export declare function timestamp2ms(timestamp: bigint | null): number | null;
|
|
290
291
|
/** format timestamp (bigint) to string
|
|
291
292
|
- timestamp: bigint value
|
|
292
293
|
- format?:
|
|
293
294
|
格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSS` format string, default to `YYYY.MM.DD HH:mm:ss.SSS`
|
|
294
|
-
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
295
|
-
*/
|
|
295
|
+
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens */
|
|
296
296
|
export declare function timestamp2str(timestamp: bigint | null, format?: string): string;
|
|
297
297
|
export declare function datehour2ms(datehour: number | null): number | null;
|
|
298
298
|
export declare function datehour2str(datehour: number | null, format?: string): string;
|
|
@@ -302,8 +302,7 @@ export declare function datehour2str(datehour: number | null, format?: string):
|
|
|
302
302
|
- format?:
|
|
303
303
|
对应传入字符串的格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSS`
|
|
304
304
|
The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSS`
|
|
305
|
-
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
306
|
-
*/
|
|
305
|
+
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens */
|
|
307
306
|
export declare function str2timestamp(str: string, format?: string): bigint;
|
|
308
307
|
export declare function nanotime2ns(nanotime: bigint | null): bigint | null;
|
|
309
308
|
export declare function nanotime2str(nanotime: bigint | null, format?: string): string;
|
package/browser.js
CHANGED
|
@@ -10,7 +10,7 @@ import { connect_websocket } from 'xshell/net.browser.js';
|
|
|
10
10
|
import { t } from './i18n/index.js';
|
|
11
11
|
import { DdbDecimal128Serializor } from './data-types/decimal-128.js';
|
|
12
12
|
import { is_decimal_type, is_decimal_null_value, get_duration_unit } from './shared/utils.js';
|
|
13
|
-
import { nulls, DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType } from './shared/constants.js';
|
|
13
|
+
import { nulls, DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType, DdbVoidType } from './shared/constants.js';
|
|
14
14
|
export * from './shared/constants.js';
|
|
15
15
|
/** 可以表示所有 DolphinDB 数据库中的数据类型 Can represent data types in all DolphinDB databases */
|
|
16
16
|
export class DdbObj {
|
|
@@ -261,13 +261,12 @@ export class DdbObj {
|
|
|
261
261
|
}
|
|
262
262
|
static parse_scalar(buf, le, type) {
|
|
263
263
|
switch (type) {
|
|
264
|
-
case DdbType.void:
|
|
265
|
-
return [1, null];
|
|
266
264
|
case DdbType.bool: {
|
|
267
265
|
const dv = new DataView(buf.buffer, buf.byteOffset);
|
|
268
266
|
const value = dv.getInt8(0);
|
|
269
267
|
return [1, value === nulls.int8 ? null : Boolean(value)];
|
|
270
268
|
}
|
|
269
|
+
case DdbType.void:
|
|
271
270
|
case DdbType.char: {
|
|
272
271
|
const dv = new DataView(buf.buffer, buf.byteOffset);
|
|
273
272
|
const value = dv.getInt8(0);
|
|
@@ -716,10 +715,7 @@ export class DdbObj {
|
|
|
716
715
|
case DdbForm.scalar:
|
|
717
716
|
switch (type) {
|
|
718
717
|
case DdbType.void:
|
|
719
|
-
|
|
720
|
-
// Void::serialize()
|
|
721
|
-
// isNothing() ? 0 : 1;
|
|
722
|
-
return [Uint8Array.of(0)];
|
|
718
|
+
return [Uint8Array.of(Number(value))];
|
|
723
719
|
case DdbType.bool:
|
|
724
720
|
return [
|
|
725
721
|
Int8Array.of(value === null ?
|
|
@@ -898,7 +894,6 @@ export class DdbObj {
|
|
|
898
894
|
case DdbType.void:
|
|
899
895
|
return [];
|
|
900
896
|
case DdbType.bool:
|
|
901
|
-
return [value];
|
|
902
897
|
case DdbType.char:
|
|
903
898
|
return [value];
|
|
904
899
|
case DdbType.short:
|
|
@@ -951,7 +946,7 @@ export class DdbObj {
|
|
|
951
946
|
case DdbType.complex:
|
|
952
947
|
case DdbType.point:
|
|
953
948
|
return [value];
|
|
954
|
-
case DdbType.duration:
|
|
949
|
+
case DdbType.duration: {
|
|
955
950
|
let bufs = new Int32Array(length * 2);
|
|
956
951
|
for (let i = 0; i < length; i++) {
|
|
957
952
|
const { data, unit } = value[i];
|
|
@@ -959,6 +954,7 @@ export class DdbObj {
|
|
|
959
954
|
bufs[2 * i + 1] = unit;
|
|
960
955
|
}
|
|
961
956
|
return [bufs];
|
|
957
|
+
}
|
|
962
958
|
case DdbType.any: {
|
|
963
959
|
// [1, 2, 'a', 'aaa']
|
|
964
960
|
// any[4](<Buffer
|
|
@@ -1298,12 +1294,31 @@ export function format(type, value, le, options = {}) {
|
|
|
1298
1294
|
return options.decimals === undefined || options.decimals === null ? default_formatter : _formatter;
|
|
1299
1295
|
})();
|
|
1300
1296
|
function get_nullstr() {
|
|
1297
|
+
const str = value === DdbVoidType.default ? 'default' : 'null';
|
|
1301
1298
|
return nullstr ?
|
|
1302
|
-
colors ? grey(
|
|
1299
|
+
colors ? grey(str) : str
|
|
1303
1300
|
:
|
|
1304
1301
|
'';
|
|
1305
1302
|
}
|
|
1303
|
+
function format_time(formatter, _null) {
|
|
1304
|
+
if (value === null || value === _null)
|
|
1305
|
+
return get_nullstr();
|
|
1306
|
+
let str;
|
|
1307
|
+
// formatter 可能会在 value 不属于 new Date() 有效值时,调用 抛出错误,这里统一处理
|
|
1308
|
+
try {
|
|
1309
|
+
str = formatter(value);
|
|
1310
|
+
}
|
|
1311
|
+
catch (error) {
|
|
1312
|
+
if (error instanceof RangeError)
|
|
1313
|
+
str = 'Invalid Date';
|
|
1314
|
+
else
|
|
1315
|
+
throw error;
|
|
1316
|
+
}
|
|
1317
|
+
return colors ? magenta(str) : str;
|
|
1318
|
+
}
|
|
1306
1319
|
switch (type) {
|
|
1320
|
+
case DdbType.void:
|
|
1321
|
+
return get_nullstr();
|
|
1307
1322
|
case DdbType.bool:
|
|
1308
1323
|
if (value === null || value === nulls.int8)
|
|
1309
1324
|
return get_nullstr();
|
|
@@ -1348,68 +1363,23 @@ export function format(type, value, le, options = {}) {
|
|
|
1348
1363
|
return colors ? green(str) : str;
|
|
1349
1364
|
}
|
|
1350
1365
|
case DdbType.date:
|
|
1351
|
-
|
|
1352
|
-
return get_nullstr();
|
|
1353
|
-
else {
|
|
1354
|
-
const str = date2str(value);
|
|
1355
|
-
return colors ? magenta(str) : str;
|
|
1356
|
-
}
|
|
1366
|
+
return format_time(date2str, nulls.int32);
|
|
1357
1367
|
case DdbType.month:
|
|
1358
|
-
|
|
1359
|
-
return get_nullstr();
|
|
1360
|
-
else {
|
|
1361
|
-
const str = month2str(value);
|
|
1362
|
-
return colors ? magenta(str) : str;
|
|
1363
|
-
}
|
|
1368
|
+
return format_time(month2str, nulls.int32);
|
|
1364
1369
|
case DdbType.time:
|
|
1365
|
-
|
|
1366
|
-
return get_nullstr();
|
|
1367
|
-
else {
|
|
1368
|
-
const str = time2str(value);
|
|
1369
|
-
return colors ? magenta(str) : str;
|
|
1370
|
-
}
|
|
1370
|
+
return format_time(time2str, nulls.int32);
|
|
1371
1371
|
case DdbType.minute:
|
|
1372
|
-
|
|
1373
|
-
return get_nullstr();
|
|
1374
|
-
else {
|
|
1375
|
-
const str = minute2str(value);
|
|
1376
|
-
return colors ? magenta(str) : str;
|
|
1377
|
-
}
|
|
1372
|
+
return format_time(minute2str, nulls.int32);
|
|
1378
1373
|
case DdbType.second:
|
|
1379
|
-
|
|
1380
|
-
return get_nullstr();
|
|
1381
|
-
else {
|
|
1382
|
-
const str = second2str(value);
|
|
1383
|
-
return colors ? magenta(str) : str;
|
|
1384
|
-
}
|
|
1374
|
+
return format_time(second2str, nulls.int32);
|
|
1385
1375
|
case DdbType.datetime:
|
|
1386
|
-
|
|
1387
|
-
return get_nullstr();
|
|
1388
|
-
else {
|
|
1389
|
-
const str = datetime2str(value);
|
|
1390
|
-
return colors ? magenta(str) : str;
|
|
1391
|
-
}
|
|
1376
|
+
return format_time(datetime2str, nulls.int32);
|
|
1392
1377
|
case DdbType.timestamp:
|
|
1393
|
-
|
|
1394
|
-
return get_nullstr();
|
|
1395
|
-
else {
|
|
1396
|
-
const str = timestamp2str(value);
|
|
1397
|
-
return colors ? magenta(str) : str;
|
|
1398
|
-
}
|
|
1378
|
+
return format_time(timestamp2str, nulls.int64);
|
|
1399
1379
|
case DdbType.nanotime:
|
|
1400
|
-
|
|
1401
|
-
return get_nullstr();
|
|
1402
|
-
else {
|
|
1403
|
-
const str = nanotime2str(value);
|
|
1404
|
-
return colors ? magenta(str) : str;
|
|
1405
|
-
}
|
|
1380
|
+
return format_time(nanotime2str, nulls.int64);
|
|
1406
1381
|
case DdbType.nanotimestamp:
|
|
1407
|
-
|
|
1408
|
-
return get_nullstr();
|
|
1409
|
-
else {
|
|
1410
|
-
const str = nanotimestamp2str(value);
|
|
1411
|
-
return colors ? magenta(str) : str;
|
|
1412
|
-
}
|
|
1382
|
+
return format_time(nanotimestamp2str, nulls.int64);
|
|
1413
1383
|
case DdbType.float:
|
|
1414
1384
|
if (value === null || value === nulls.float32)
|
|
1415
1385
|
return get_nullstr();
|
|
@@ -1447,12 +1417,7 @@ export function format(type, value, le, options = {}) {
|
|
|
1447
1417
|
return colors ? cyan(str) : str;
|
|
1448
1418
|
}
|
|
1449
1419
|
case DdbType.datehour:
|
|
1450
|
-
|
|
1451
|
-
return get_nullstr();
|
|
1452
|
-
else {
|
|
1453
|
-
const str = datehour2str(value);
|
|
1454
|
-
return colors ? magenta(str) : str;
|
|
1455
|
-
}
|
|
1420
|
+
return format_time(datehour2str, nulls.int32);
|
|
1456
1421
|
case DdbType.ipaddr: {
|
|
1457
1422
|
const str = ipaddr2str(value, le);
|
|
1458
1423
|
return colors ? cyan(str) : str;
|
|
@@ -1496,7 +1461,7 @@ export function format(type, value, le, options = {}) {
|
|
|
1496
1461
|
return value === null ? get_nullstr() : String(value);
|
|
1497
1462
|
}
|
|
1498
1463
|
}
|
|
1499
|
-
/** 格式化向量、集合中的第 index
|
|
1464
|
+
/** 格式化向量、集合中的第 index 项为字符串,空值返回 'null' 字符串 formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
|
|
1500
1465
|
export function formati(obj, index, options = {}) {
|
|
1501
1466
|
assert(index < obj.rows, 'index < obj.rows');
|
|
1502
1467
|
if (64 <= obj.type && obj.type < 128) { // array vector
|
|
@@ -1600,11 +1565,11 @@ export function formati(obj, index, options = {}) {
|
|
|
1600
1565
|
}
|
|
1601
1566
|
}
|
|
1602
1567
|
export class DdbVoid extends DdbObj {
|
|
1603
|
-
constructor() {
|
|
1568
|
+
constructor(value = DdbVoidType.undefined) {
|
|
1604
1569
|
super({
|
|
1605
1570
|
form: DdbForm.scalar,
|
|
1606
1571
|
type: DdbType.void,
|
|
1607
|
-
value
|
|
1572
|
+
value,
|
|
1608
1573
|
});
|
|
1609
1574
|
}
|
|
1610
1575
|
}
|
|
@@ -2002,6 +1967,7 @@ export function datetime2str(datetime, format = 'YYYY.MM.DD HH:mm:ss') {
|
|
|
2002
1967
|
:
|
|
2003
1968
|
dayjs(datetime2ms(datetime)).format(format);
|
|
2004
1969
|
}
|
|
1970
|
+
/** _datetime_formatter.format 会在 date 为 Invalid Date 时抛出错误 */
|
|
2005
1971
|
export function timestamp2ms(timestamp) {
|
|
2006
1972
|
if (timestamp === null || timestamp === nulls.int64)
|
|
2007
1973
|
return null;
|
|
@@ -2012,8 +1978,7 @@ export function timestamp2ms(timestamp) {
|
|
|
2012
1978
|
- timestamp: bigint value
|
|
2013
1979
|
- format?:
|
|
2014
1980
|
格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSS` format string, default to `YYYY.MM.DD HH:mm:ss.SSS`
|
|
2015
|
-
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
2016
|
-
*/
|
|
1981
|
+
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens */
|
|
2017
1982
|
export function timestamp2str(timestamp, format = 'YYYY.MM.DD HH:mm:ss.SSS') {
|
|
2018
1983
|
return (timestamp === null || timestamp === nulls.int64) ?
|
|
2019
1984
|
'null'
|
|
@@ -2038,8 +2003,7 @@ export function datehour2str(datehour, format = 'YYYY.MM.DDTHH') {
|
|
|
2038
2003
|
- format?:
|
|
2039
2004
|
对应传入字符串的格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSS`
|
|
2040
2005
|
The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSS`
|
|
2041
|
-
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
2042
|
-
*/
|
|
2006
|
+
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens */
|
|
2043
2007
|
export function str2timestamp(str, format = 'YYYY.MM.DD HH:mm:ss.SSS') {
|
|
2044
2008
|
if (!str || str === 'null')
|
|
2045
2009
|
return nulls.int64;
|