dolphindb 2.0.1102 → 2.0.1103
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 +4 -5
- package/browser.js +32 -66
- package/browser.js.map +1 -1
- package/index.d.ts +3 -4
- package/index.js +29 -74
- package/index.js.map +1 -1
- package/package.json +7 -7
- 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
|
@@ -194,7 +194,7 @@ 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
200
|
constructor();
|
|
@@ -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
|
@@ -951,7 +951,7 @@ export class DdbObj {
|
|
|
951
951
|
case DdbType.complex:
|
|
952
952
|
case DdbType.point:
|
|
953
953
|
return [value];
|
|
954
|
-
case DdbType.duration:
|
|
954
|
+
case DdbType.duration: {
|
|
955
955
|
let bufs = new Int32Array(length * 2);
|
|
956
956
|
for (let i = 0; i < length; i++) {
|
|
957
957
|
const { data, unit } = value[i];
|
|
@@ -959,6 +959,7 @@ export class DdbObj {
|
|
|
959
959
|
bufs[2 * i + 1] = unit;
|
|
960
960
|
}
|
|
961
961
|
return [bufs];
|
|
962
|
+
}
|
|
962
963
|
case DdbType.any: {
|
|
963
964
|
// [1, 2, 'a', 'aaa']
|
|
964
965
|
// any[4](<Buffer
|
|
@@ -1303,6 +1304,22 @@ export function format(type, value, le, options = {}) {
|
|
|
1303
1304
|
:
|
|
1304
1305
|
'';
|
|
1305
1306
|
}
|
|
1307
|
+
function format_time(formatter, _null) {
|
|
1308
|
+
if (value === null || value === _null)
|
|
1309
|
+
return get_nullstr();
|
|
1310
|
+
let str;
|
|
1311
|
+
// formatter 可能会在 value 不属于 new Date() 有效值时,调用 抛出错误,这里统一处理
|
|
1312
|
+
try {
|
|
1313
|
+
str = formatter(value);
|
|
1314
|
+
}
|
|
1315
|
+
catch (error) {
|
|
1316
|
+
if (error instanceof RangeError)
|
|
1317
|
+
str = 'Invalid Date';
|
|
1318
|
+
else
|
|
1319
|
+
throw error;
|
|
1320
|
+
}
|
|
1321
|
+
return colors ? magenta(str) : str;
|
|
1322
|
+
}
|
|
1306
1323
|
switch (type) {
|
|
1307
1324
|
case DdbType.bool:
|
|
1308
1325
|
if (value === null || value === nulls.int8)
|
|
@@ -1348,68 +1365,23 @@ export function format(type, value, le, options = {}) {
|
|
|
1348
1365
|
return colors ? green(str) : str;
|
|
1349
1366
|
}
|
|
1350
1367
|
case DdbType.date:
|
|
1351
|
-
|
|
1352
|
-
return get_nullstr();
|
|
1353
|
-
else {
|
|
1354
|
-
const str = date2str(value);
|
|
1355
|
-
return colors ? magenta(str) : str;
|
|
1356
|
-
}
|
|
1368
|
+
return format_time(date2str, nulls.int32);
|
|
1357
1369
|
case DdbType.month:
|
|
1358
|
-
|
|
1359
|
-
return get_nullstr();
|
|
1360
|
-
else {
|
|
1361
|
-
const str = month2str(value);
|
|
1362
|
-
return colors ? magenta(str) : str;
|
|
1363
|
-
}
|
|
1370
|
+
return format_time(month2str, nulls.int32);
|
|
1364
1371
|
case DdbType.time:
|
|
1365
|
-
|
|
1366
|
-
return get_nullstr();
|
|
1367
|
-
else {
|
|
1368
|
-
const str = time2str(value);
|
|
1369
|
-
return colors ? magenta(str) : str;
|
|
1370
|
-
}
|
|
1372
|
+
return format_time(time2str, nulls.int32);
|
|
1371
1373
|
case DdbType.minute:
|
|
1372
|
-
|
|
1373
|
-
return get_nullstr();
|
|
1374
|
-
else {
|
|
1375
|
-
const str = minute2str(value);
|
|
1376
|
-
return colors ? magenta(str) : str;
|
|
1377
|
-
}
|
|
1374
|
+
return format_time(minute2str, nulls.int32);
|
|
1378
1375
|
case DdbType.second:
|
|
1379
|
-
|
|
1380
|
-
return get_nullstr();
|
|
1381
|
-
else {
|
|
1382
|
-
const str = second2str(value);
|
|
1383
|
-
return colors ? magenta(str) : str;
|
|
1384
|
-
}
|
|
1376
|
+
return format_time(second2str, nulls.int32);
|
|
1385
1377
|
case DdbType.datetime:
|
|
1386
|
-
|
|
1387
|
-
return get_nullstr();
|
|
1388
|
-
else {
|
|
1389
|
-
const str = datetime2str(value);
|
|
1390
|
-
return colors ? magenta(str) : str;
|
|
1391
|
-
}
|
|
1378
|
+
return format_time(datetime2str, nulls.int32);
|
|
1392
1379
|
case DdbType.timestamp:
|
|
1393
|
-
|
|
1394
|
-
return get_nullstr();
|
|
1395
|
-
else {
|
|
1396
|
-
const str = timestamp2str(value);
|
|
1397
|
-
return colors ? magenta(str) : str;
|
|
1398
|
-
}
|
|
1380
|
+
return format_time(timestamp2str, nulls.int64);
|
|
1399
1381
|
case DdbType.nanotime:
|
|
1400
|
-
|
|
1401
|
-
return get_nullstr();
|
|
1402
|
-
else {
|
|
1403
|
-
const str = nanotime2str(value);
|
|
1404
|
-
return colors ? magenta(str) : str;
|
|
1405
|
-
}
|
|
1382
|
+
return format_time(nanotime2str, nulls.int64);
|
|
1406
1383
|
case DdbType.nanotimestamp:
|
|
1407
|
-
|
|
1408
|
-
return get_nullstr();
|
|
1409
|
-
else {
|
|
1410
|
-
const str = nanotimestamp2str(value);
|
|
1411
|
-
return colors ? magenta(str) : str;
|
|
1412
|
-
}
|
|
1384
|
+
return format_time(nanotimestamp2str, nulls.int64);
|
|
1413
1385
|
case DdbType.float:
|
|
1414
1386
|
if (value === null || value === nulls.float32)
|
|
1415
1387
|
return get_nullstr();
|
|
@@ -1447,12 +1419,7 @@ export function format(type, value, le, options = {}) {
|
|
|
1447
1419
|
return colors ? cyan(str) : str;
|
|
1448
1420
|
}
|
|
1449
1421
|
case DdbType.datehour:
|
|
1450
|
-
|
|
1451
|
-
return get_nullstr();
|
|
1452
|
-
else {
|
|
1453
|
-
const str = datehour2str(value);
|
|
1454
|
-
return colors ? magenta(str) : str;
|
|
1455
|
-
}
|
|
1422
|
+
return format_time(datehour2str, nulls.int32);
|
|
1456
1423
|
case DdbType.ipaddr: {
|
|
1457
1424
|
const str = ipaddr2str(value, le);
|
|
1458
1425
|
return colors ? cyan(str) : str;
|
|
@@ -1496,7 +1463,7 @@ export function format(type, value, le, options = {}) {
|
|
|
1496
1463
|
return value === null ? get_nullstr() : String(value);
|
|
1497
1464
|
}
|
|
1498
1465
|
}
|
|
1499
|
-
/** 格式化向量、集合中的第 index
|
|
1466
|
+
/** 格式化向量、集合中的第 index 项为字符串,空值返回 'null' 字符串 formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
|
|
1500
1467
|
export function formati(obj, index, options = {}) {
|
|
1501
1468
|
assert(index < obj.rows, 'index < obj.rows');
|
|
1502
1469
|
if (64 <= obj.type && obj.type < 128) { // array vector
|
|
@@ -2002,6 +1969,7 @@ export function datetime2str(datetime, format = 'YYYY.MM.DD HH:mm:ss') {
|
|
|
2002
1969
|
:
|
|
2003
1970
|
dayjs(datetime2ms(datetime)).format(format);
|
|
2004
1971
|
}
|
|
1972
|
+
/** _datetime_formatter.format 会在 date 为 Invalid Date 时抛出错误 */
|
|
2005
1973
|
export function timestamp2ms(timestamp) {
|
|
2006
1974
|
if (timestamp === null || timestamp === nulls.int64)
|
|
2007
1975
|
return null;
|
|
@@ -2012,8 +1980,7 @@ export function timestamp2ms(timestamp) {
|
|
|
2012
1980
|
- timestamp: bigint value
|
|
2013
1981
|
- format?:
|
|
2014
1982
|
格式串,默认是 `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
|
-
*/
|
|
1983
|
+
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens */
|
|
2017
1984
|
export function timestamp2str(timestamp, format = 'YYYY.MM.DD HH:mm:ss.SSS') {
|
|
2018
1985
|
return (timestamp === null || timestamp === nulls.int64) ?
|
|
2019
1986
|
'null'
|
|
@@ -2038,8 +2005,7 @@ export function datehour2str(datehour, format = 'YYYY.MM.DDTHH') {
|
|
|
2038
2005
|
- format?:
|
|
2039
2006
|
对应传入字符串的格式串,默认是 `YYYY.MM.DD HH:mm:ss.SSS`
|
|
2040
2007
|
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
|
-
*/
|
|
2008
|
+
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens */
|
|
2043
2009
|
export function str2timestamp(str, format = 'YYYY.MM.DD HH:mm:ss.SSS') {
|
|
2044
2010
|
if (!str || str === 'null')
|
|
2045
2011
|
return nulls.int64;
|