dolphindb 2.0.929 → 2.0.931
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 +7 -8
- package/browser.js +15 -27
- package/browser.js.map +1 -1
- package/index.d.ts +7 -8
- package/index.js +15 -27
- package/index.js.map +1 -1
- package/package.json +4 -8
package/index.d.ts
CHANGED
|
@@ -498,9 +498,9 @@ export declare class DDB {
|
|
|
498
498
|
pnode_run_defined: boolean;
|
|
499
499
|
/** DdbMessage listeners */
|
|
500
500
|
listeners: DdbMessageListener[];
|
|
501
|
-
pconnect:
|
|
502
|
-
ppnoderun:
|
|
503
|
-
presult:
|
|
501
|
+
pconnect: import("xshell").Deferred<void>;
|
|
502
|
+
ppnoderun: import("xshell").Deferred<void>;
|
|
503
|
+
presult: import("xshell").Deferred<DdbObj<DdbValue>>;
|
|
504
504
|
get connected(): boolean;
|
|
505
505
|
/**
|
|
506
506
|
使用 WebSocket URL 初始化连接到 DolphinDB 的实例(不建立实际的网络连接)
|
|
@@ -569,9 +569,8 @@ export declare class DDB {
|
|
|
569
569
|
- vars?: type === 'variable' 时必传,variable 指令中待上传的变量名
|
|
570
570
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage)
|
|
571
571
|
- parse_object?: 在本次 rpc 期间设置 parse_object, 结束后恢复原有
|
|
572
|
-
为 false 时返回的 DdbObj 仅含有 buffer 和 le,不做解析,以便后续转发、序列化
|
|
573
|
-
|
|
574
|
-
rpc<T extends DdbObj = DdbObj>(type: DdbRpcType, options: DdbRpcOptions): Promise<T>;
|
|
572
|
+
为 false 时返回的 DdbObj 仅含有 buffer 和 le,不做解析,以便后续转发、序列化 */
|
|
573
|
+
rpc<TResult extends DdbObj = DdbObj>(type: DdbRpcType, options: DdbRpcOptions): Promise<TResult>;
|
|
575
574
|
/** eval script through websocket (script command)
|
|
576
575
|
- script?: 执行的脚本 Script to execute
|
|
577
576
|
- options?: 执行选项 execution options
|
|
@@ -612,7 +611,7 @@ export declare class DDB {
|
|
|
612
611
|
When it is false, the returned DdbObj only contains buffer and le without parsing,
|
|
613
612
|
so as to facilitate subsequent forwarding and serialization
|
|
614
613
|
*/
|
|
615
|
-
call<
|
|
614
|
+
call<TResult extends DdbObj>(func: string, args?: (DdbObj | string | boolean)[], { urgent, node, nodes, func_type, add_node_alias, listener, parse_object, }?: {
|
|
616
615
|
urgent?: boolean;
|
|
617
616
|
node?: string;
|
|
618
617
|
nodes?: string[];
|
|
@@ -620,7 +619,7 @@ export declare class DDB {
|
|
|
620
619
|
add_node_alias?: boolean;
|
|
621
620
|
listener?: DdbMessageListener;
|
|
622
621
|
parse_object?: boolean;
|
|
623
|
-
}): Promise<
|
|
622
|
+
}): Promise<TResult>;
|
|
624
623
|
/** upload variable through websocket (variable command) */
|
|
625
624
|
upload(
|
|
626
625
|
/** 上传的变量名 Uploaded variables' name */
|
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import DayjsCustomParseFormat from 'dayjs/plugin/customParseFormat.js';
|
|
|
4
4
|
dayjs.extend(DayjsCustomParseFormat);
|
|
5
5
|
import ipaddrjs from 'ipaddr.js';
|
|
6
6
|
const { fromByteArray: buf2ipaddr } = ipaddrjs;
|
|
7
|
-
import { concat, assert, inspect, typed_array_to_buffer, connect_websocket, WebSocket, WebSocketConnectionError } from 'xshell';
|
|
7
|
+
import { concat, assert, inspect, typed_array_to_buffer, connect_websocket, WebSocket, WebSocketConnectionError, defer } from 'xshell';
|
|
8
8
|
import { t } from './i18n/index.js';
|
|
9
9
|
export var DdbForm;
|
|
10
10
|
(function (DdbForm) {
|
|
@@ -1519,7 +1519,7 @@ export function formati(obj, index, options = {}) {
|
|
|
1519
1519
|
case DdbType.decimal32:
|
|
1520
1520
|
case DdbType.decimal64:
|
|
1521
1521
|
const x = data[acc_len + i];
|
|
1522
|
-
if (x === nulls.int64 /* &&
|
|
1522
|
+
if (x === nulls.int64 /* && type_ === DdbType.decimal64 一定成立 */ ||
|
|
1523
1523
|
x === nulls.int32 && type_ === DdbType.decimal32)
|
|
1524
1524
|
return '';
|
|
1525
1525
|
const { scale } = obj.value;
|
|
@@ -2166,9 +2166,9 @@ export class DDB {
|
|
|
2166
2166
|
pnode_run_defined = false;
|
|
2167
2167
|
/** DdbMessage listeners */
|
|
2168
2168
|
listeners = [];
|
|
2169
|
-
pconnect =
|
|
2170
|
-
ppnoderun =
|
|
2171
|
-
presult =
|
|
2169
|
+
pconnect = defer(null);
|
|
2170
|
+
ppnoderun = defer(null);
|
|
2171
|
+
presult = defer(null);
|
|
2172
2172
|
get connected() {
|
|
2173
2173
|
return this.websocket?.readyState === WebSocket.OPEN;
|
|
2174
2174
|
}
|
|
@@ -2217,17 +2217,14 @@ export class DDB {
|
|
|
2217
2217
|
if (this.connected)
|
|
2218
2218
|
return;
|
|
2219
2219
|
const ptail = this.pconnect;
|
|
2220
|
-
|
|
2221
|
-
this.pconnect = new Promise((_resolve, _reject) => {
|
|
2222
|
-
resolve = _resolve;
|
|
2223
|
-
});
|
|
2220
|
+
const pconnect = this.pconnect = defer();
|
|
2224
2221
|
await ptail;
|
|
2225
2222
|
try {
|
|
2226
2223
|
if (!this.connected) {
|
|
2227
2224
|
this.on_message = buffer => {
|
|
2228
2225
|
assert(false, t('这是在调用 this.rpc 之前默认的 on_message, 不应该被调用到,除非建立连接后 server 先推送了 message'));
|
|
2229
2226
|
};
|
|
2230
|
-
this.presult =
|
|
2227
|
+
this.presult = defer(null);
|
|
2231
2228
|
this.pnode_run_defined = false;
|
|
2232
2229
|
try {
|
|
2233
2230
|
this.websocket = await connect_websocket(this.url, {
|
|
@@ -2258,7 +2255,7 @@ export class DDB {
|
|
|
2258
2255
|
}
|
|
2259
2256
|
}
|
|
2260
2257
|
finally {
|
|
2261
|
-
resolve();
|
|
2258
|
+
pconnect.resolve();
|
|
2262
2259
|
}
|
|
2263
2260
|
}
|
|
2264
2261
|
get_rpc_options({ urgent = false, secondary = false, async: _async = false, pickle = false, clear = false, api = false, compress = false, cancellable = true, priority = urgent ? 8 : 4, parallelism = 8, root_id = '', limit, } = {}) {
|
|
@@ -2305,8 +2302,7 @@ export class DDB {
|
|
|
2305
2302
|
- vars?: type === 'variable' 时必传,variable 指令中待上传的变量名
|
|
2306
2303
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage)
|
|
2307
2304
|
- parse_object?: 在本次 rpc 期间设置 parse_object, 结束后恢复原有
|
|
2308
|
-
为 false 时返回的 DdbObj 仅含有 buffer 和 le,不做解析,以便后续转发、序列化
|
|
2309
|
-
*/
|
|
2305
|
+
为 false 时返回的 DdbObj 仅含有 buffer 和 le,不做解析,以便后续转发、序列化 */
|
|
2310
2306
|
async rpc(type, options) {
|
|
2311
2307
|
if (!this.websocket)
|
|
2312
2308
|
await this.connect();
|
|
@@ -2317,10 +2313,7 @@ export class DDB {
|
|
|
2317
2313
|
if (func === 'pnode_run' && !this.pnode_run_defined) {
|
|
2318
2314
|
// 保证并发调用 rpc 时只定义一次 pnode_run
|
|
2319
2315
|
const ptail = this.ppnoderun;
|
|
2320
|
-
|
|
2321
|
-
this.ppnoderun = new Promise((_resolve, _reject) => {
|
|
2322
|
-
resolve = _resolve;
|
|
2323
|
-
});
|
|
2316
|
+
const ppnoderun = this.ppnoderun = defer();
|
|
2324
2317
|
await ptail;
|
|
2325
2318
|
try {
|
|
2326
2319
|
if (!this.pnode_run_defined)
|
|
@@ -2361,7 +2354,7 @@ export class DDB {
|
|
|
2361
2354
|
'}\n', { urgent: true });
|
|
2362
2355
|
}
|
|
2363
2356
|
finally {
|
|
2364
|
-
resolve();
|
|
2357
|
+
ppnoderun.resolve();
|
|
2365
2358
|
}
|
|
2366
2359
|
}
|
|
2367
2360
|
// this 上的当前配置需要在 message 到达后使用,先保存起来
|
|
@@ -2373,12 +2366,7 @@ export class DDB {
|
|
|
2373
2366
|
// 1. 并发多个请求只返回第一个结果(阻塞,需后续请求疏通)
|
|
2374
2367
|
// 2. windows 下 ddb server 返回多个相同的结果
|
|
2375
2368
|
const ptail = this.presult;
|
|
2376
|
-
|
|
2377
|
-
let reject;
|
|
2378
|
-
const presult = this.presult = new Promise((_resolve, _reject) => {
|
|
2379
|
-
resolve = _resolve;
|
|
2380
|
-
reject = _reject;
|
|
2381
|
-
});
|
|
2369
|
+
const presult = this.presult = defer();
|
|
2382
2370
|
try {
|
|
2383
2371
|
await ptail;
|
|
2384
2372
|
}
|
|
@@ -2400,15 +2388,15 @@ export class DDB {
|
|
|
2400
2388
|
console.log(data);
|
|
2401
2389
|
return;
|
|
2402
2390
|
case 'object':
|
|
2403
|
-
resolve(data);
|
|
2391
|
+
presult.resolve(data);
|
|
2404
2392
|
return;
|
|
2405
2393
|
case 'error':
|
|
2406
|
-
reject(data);
|
|
2394
|
+
presult.reject(data);
|
|
2407
2395
|
return;
|
|
2408
2396
|
}
|
|
2409
2397
|
}
|
|
2410
2398
|
catch (error) {
|
|
2411
|
-
reject(error);
|
|
2399
|
+
presult.reject(error);
|
|
2412
2400
|
}
|
|
2413
2401
|
};
|
|
2414
2402
|
args = DdbObj.to_ddbobjs(args);
|