dolphindb 3.1.13 → 3.1.14
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/README.md +11 -2
- package/README.zh.md +10 -2
- package/browser.js +8 -27
- package/browser.js.map +1 -1
- package/common.d.ts +1 -0
- package/common.js +19 -0
- package/common.js.map +1 -1
- package/index.js +13 -32
- package/index.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -102,8 +102,11 @@ let ddb = new DDB('ws://127.0.0.1:8848')
|
|
|
102
102
|
// Use HTTPS encryption
|
|
103
103
|
// let ddb = new DDB('wss://dolphindb.com')
|
|
104
104
|
|
|
105
|
-
// 2.3
|
|
106
|
-
await ddb.
|
|
105
|
+
// 2.3 Call the DolphinDB add function, automatically connecting to the database (requires DolphinDB version 1.30.16 or 2.00.4 or higher)
|
|
106
|
+
console.log(await ddb.invoke('add', [1, 2])) // Output 3
|
|
107
|
+
|
|
108
|
+
// 2.4 Disconnect after use to release resources
|
|
109
|
+
ddb.disconnect()
|
|
107
110
|
```
|
|
108
111
|
|
|
109
112
|
#### Code completion and function prompt
|
|
@@ -539,6 +542,12 @@ console.log(
|
|
|
539
542
|
)
|
|
540
543
|
```
|
|
541
544
|
|
|
545
|
+
### Close the connection
|
|
546
|
+
```ts
|
|
547
|
+
ddb.disconnect()
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
|
|
542
551
|
### Other Examples
|
|
543
552
|
|
|
544
553
|
```ts
|
package/README.zh.md
CHANGED
|
@@ -98,8 +98,11 @@ let ddb = new DDB('ws://127.0.0.1:8848')
|
|
|
98
98
|
// 使用 HTTPS 加密
|
|
99
99
|
// let ddb = new DDB('wss://dolphindb.com')
|
|
100
100
|
|
|
101
|
-
// 2.3
|
|
102
|
-
await ddb.
|
|
101
|
+
// 2.3 调用 DolphinDB add 函数,调用时自动连接到数据库(要求 DolphinDB 数据库版本不低于 1.30.16 或 2.00.4)
|
|
102
|
+
console.log(await ddb.invoke('add', [1, 2])) // 输出 3
|
|
103
|
+
|
|
104
|
+
// 2.4 使用完毕,断开连接释放资源
|
|
105
|
+
ddb.disconnect()
|
|
103
106
|
```
|
|
104
107
|
|
|
105
108
|
#### 代码补全、函数提示数据
|
|
@@ -519,6 +522,11 @@ console.log(
|
|
|
519
522
|
)
|
|
520
523
|
```
|
|
521
524
|
|
|
525
|
+
### 关闭连接
|
|
526
|
+
```ts
|
|
527
|
+
ddb.disconnect()
|
|
528
|
+
```
|
|
529
|
+
|
|
522
530
|
### 其他例子
|
|
523
531
|
|
|
524
532
|
```ts
|
package/browser.js
CHANGED
|
@@ -3,7 +3,7 @@ import { blue, cyan, green, grey, magenta } from 'xshell/chalk.browser.js';
|
|
|
3
3
|
import { concat, assert, Lock, genid, seq, zip_object, decode, delay, check } from 'xshell/utils.browser.js';
|
|
4
4
|
import { connect_websocket } from 'xshell/net.browser.js';
|
|
5
5
|
import { t } from "./i18n/index.js";
|
|
6
|
-
import { date2str, datehour2str, datetime2str, ddb_tensor_bytes, DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType, DdbVoidType, dictables, function_definition_patterns, generate_array_type, get_big_int_128, get_time_ddbobj, get_duration_unit, get_type_name, int1282str, ipaddr2str, is_decimal_null_value, is_decimal_type, minute2str, month2str, nanotime2str, nanotimestamp2str, nulls, second2str, set_big_int_128, time2str, timestamp2str, uuid2str, get_times_ddbobj, funcdefs } from "./common.js";
|
|
6
|
+
import { date2str, datehour2str, datetime2str, ddb_tensor_bytes, DdbChartType, DdbDurationUnit, DdbForm, DdbFunctionType, DdbType, DdbVoidType, dictables, function_definition_patterns, generate_array_type, get_big_int_128, get_time_ddbobj, get_duration_unit, get_type_name, int1282str, ipaddr2str, is_decimal_null_value, is_decimal_type, minute2str, month2str, nanotime2str, nanotimestamp2str, nulls, second2str, set_big_int_128, time2str, timestamp2str, uuid2str, get_times_ddbobj, funcdefs, get_number_formatter } from "./common.js";
|
|
7
7
|
export * from "./common.js";
|
|
8
8
|
/** 可以表示所有 DolphinDB 数据库中的数据类型 Can represent data types in all DolphinDB databases */
|
|
9
9
|
export class DdbObj {
|
|
@@ -1566,29 +1566,10 @@ export class DdbObj {
|
|
|
1566
1566
|
return obj;
|
|
1567
1567
|
}
|
|
1568
1568
|
}
|
|
1569
|
-
/** 整数一定用这个 number formatter, InspectOptions.decimals 不传也用这个 */
|
|
1570
|
-
let default_formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
|
|
1571
|
-
let _decimals = 20;
|
|
1572
|
-
let _grouping = true;
|
|
1573
|
-
/** 缓存,为了优化性能,通常 options.decimals 都是不变的 */
|
|
1574
|
-
let _formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20 });
|
|
1575
1569
|
/** 根据 DdbType 格式化单个元素 (value) 为字符串 */
|
|
1576
1570
|
export function format(type, value, le, options = {}) {
|
|
1577
|
-
const { nullstr = false, colors = false, quote = false,
|
|
1578
|
-
const
|
|
1579
|
-
const decimals = options.decimals ?? _decimals;
|
|
1580
|
-
if (decimals !== _decimals || grouping !== _grouping) {
|
|
1581
|
-
_decimals = decimals;
|
|
1582
|
-
_grouping = grouping;
|
|
1583
|
-
default_formatter = new Intl.NumberFormat('en-US', { maximumFractionDigits: 20, useGrouping: grouping });
|
|
1584
|
-
_formatter = new Intl.NumberFormat('en-US', {
|
|
1585
|
-
maximumFractionDigits: decimals,
|
|
1586
|
-
minimumFractionDigits: decimals,
|
|
1587
|
-
useGrouping: grouping
|
|
1588
|
-
});
|
|
1589
|
-
}
|
|
1590
|
-
return options.decimals === undefined || options.decimals === null ? default_formatter : _formatter;
|
|
1591
|
-
})();
|
|
1571
|
+
const { nullstr = false, colors = false, quote = false, timestamp = 'ms' } = options;
|
|
1572
|
+
const number_formatter = get_number_formatter(options.decimals, options.grouping);
|
|
1592
1573
|
function get_nullstr() {
|
|
1593
1574
|
const str = value === DdbVoidType.default ? 'default' : 'null';
|
|
1594
1575
|
return nullstr ?
|
|
@@ -1641,21 +1622,21 @@ export function format(type, value, le, options = {}) {
|
|
|
1641
1622
|
if (value === null || value === nulls.int16)
|
|
1642
1623
|
return get_nullstr();
|
|
1643
1624
|
else {
|
|
1644
|
-
const str =
|
|
1625
|
+
const str = number_formatter.format(value);
|
|
1645
1626
|
return colors ? green(str) : str;
|
|
1646
1627
|
}
|
|
1647
1628
|
case DdbType.int:
|
|
1648
1629
|
if (value === null || value === nulls.int32)
|
|
1649
1630
|
return get_nullstr();
|
|
1650
1631
|
else {
|
|
1651
|
-
const str =
|
|
1632
|
+
const str = number_formatter.format(value);
|
|
1652
1633
|
return colors ? green(str) : str;
|
|
1653
1634
|
}
|
|
1654
1635
|
case DdbType.long:
|
|
1655
1636
|
if (value === null || value === nulls.int64)
|
|
1656
1637
|
return get_nullstr();
|
|
1657
1638
|
else {
|
|
1658
|
-
const str =
|
|
1639
|
+
const str = number_formatter.format(value);
|
|
1659
1640
|
return colors ? green(str) : str;
|
|
1660
1641
|
}
|
|
1661
1642
|
case DdbType.date:
|
|
@@ -1680,14 +1661,14 @@ export function format(type, value, le, options = {}) {
|
|
|
1680
1661
|
if (value === null || value === nulls.float32)
|
|
1681
1662
|
return get_nullstr();
|
|
1682
1663
|
else {
|
|
1683
|
-
const str =
|
|
1664
|
+
const str = number_formatter.format(value);
|
|
1684
1665
|
return colors ? green(str) : str;
|
|
1685
1666
|
}
|
|
1686
1667
|
case DdbType.double:
|
|
1687
1668
|
if (value === null || value === nulls.double)
|
|
1688
1669
|
return get_nullstr();
|
|
1689
1670
|
else {
|
|
1690
|
-
const str =
|
|
1671
|
+
const str = number_formatter.format(value);
|
|
1691
1672
|
return colors ? green(str) : str;
|
|
1692
1673
|
}
|
|
1693
1674
|
case DdbType.symbol:
|