dolphindb 3.0.114 → 3.0.118

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 CHANGED
@@ -555,7 +555,7 @@ export interface StreamingParams {
555
555
  offset 与流数据表创建时的第一行对应。如果某些行因为内存限制被删除,在决定订阅开始的位置时,这些行仍然考虑在内。 */
556
556
  offset?: number;
557
557
  filters?: {
558
- /** https://docs.dolphindb.cn/zh/help/FunctionsandCommands/FunctionReferences/s/subscribeTable.html#:~:text=%E8%BF%9E%E6%8E%A5%E6%96%B0%E7%9A%84%20leader%E3%80%82-,filter%20%E5%8F%82%E6%95%B0%E9%9C%80%E8%A6%81%E9%85%8D%E5%90%88,-setStreamTableFilterColumn%20%E5%87%BD%E6%95%B0%E4%B8%80%E8%B5%B7 */
558
+ /** https://test.dolphindb.cn/zh/funcs/s/subscribeTable.html#:~:text=filter%20%E5%8F%82%E6%95%B0%E9%9C%80%E8%A6%81%E9%85%8D%E5%90%88%20setStreamTableFilterColumn%20%E5%87%BD%E6%95%B0%E4%B8%80%E8%B5%B7%E4%BD%BF%E7%94%A8 */
559
559
  column?: DdbObj;
560
560
  /** 过滤条件的 DolphinDB 表达式 https://dolphindb1.atlassian.net/wiki/spaces/dev/pages/760840447/WebSocketConsole */
561
561
  expression?: string;
@@ -594,6 +594,9 @@ export interface DdbEvalOptions {
594
594
  urgent?: boolean;
595
595
  listener?: DdbMessageListener;
596
596
  parse_object?: boolean;
597
+ iife?: boolean;
598
+ }
599
+ export interface DdbExecuteOptions extends DdbEvalOptions, ConvertOptions {
597
600
  }
598
601
  type DdbRpcType = 'script' | 'function' | 'variable' | 'connect';
599
602
  export interface DdbRpcOptions extends DdbEvalOptions {
@@ -642,6 +645,8 @@ export interface DdbCallOptions extends DdbEvalOptions {
642
645
  skip_connection_check?: boolean;
643
646
  on_more_messages?: DdbRpcOptions['on_more_messages'];
644
647
  }
648
+ export interface DdbInvokeOptions extends DdbCallOptions, ConvertOptions {
649
+ }
645
650
  export declare class DDB {
646
651
  /** 当前的 session id (http 或 tcp) */
647
652
  sid: string;
@@ -779,8 +784,9 @@ export declare class DDB {
779
784
  不做解析,以便后续转发、序列化
780
785
  Set parse_object during this rpc, and restore the original after the end.
781
786
  When it is false, the returned DdbObj only contains buffer and le without parsing,
782
- so as to facilitate subsequent forwarding and serialization */
783
- eval<T extends DdbObj>(script: string, { urgent, listener, parse_object, }?: DdbEvalOptions): Promise<T>;
787
+ so as to facilitate subsequent forwarding and serialization
788
+ - iife?: 使用 `def () { ... } ()` 包裹脚本,return 最后一行,避免变量泄漏 */
789
+ eval<T extends DdbObj>(script: string, { urgent, listener, parse_object, iife, }?: DdbEvalOptions): Promise<T>;
784
790
  /** call function through websocket (function command)
785
791
  - func: 函数名 function name
786
792
  - args?: `[ ]` 调用参数 (传入的原生 string 和 boolean 会被自动转换为 DdbObj<string> 和 DdbObj<boolean>)
@@ -818,13 +824,13 @@ export declare class DDB {
818
824
  - func_type?: 设置 node 参数且参数数组为空时必传,需指定函数类型,其它情况下不传
819
825
  - add_node_alias?: 设置 nodes 参数时选传,其它情况不传
820
826
  - listener?: 处理本次 rpc 期间的消息 (DdbMessage) */
821
- invoke<TResult = any>(func: string, args?: any[], options?: DdbCallOptions): Promise<TResult>;
827
+ invoke<TResult = any>(func: string, args?: any[], options?: DdbInvokeOptions): Promise<TResult>;
822
828
  /** 执行 dolphindb 脚本,返回 js 原生对象或值(调用 DdbObj.data() 后的结果)
823
829
  - script?: 执行的脚本
824
830
  - options?: 执行选项
825
831
  - urgent?: 紧急 flag,确保提交的脚本使用 urgent worker 处理,防止被其它作业阻塞
826
832
  - listener?: 处理本次 rpc 期间的消息 (DdbMessage) */
827
- execute<TResult = any>(script: string, options?: DdbEvalOptions): Promise<TResult>;
833
+ execute<TResult = any>(script: string, options?: DdbExecuteOptions): Promise<TResult>;
828
834
  /** upload variable through websocket (variable command) */
829
835
  upload(
830
836
  /** 上传的变量名 Uploaded variables' name */
package/browser.js CHANGED
@@ -3104,8 +3104,19 @@ export class DDB {
3104
3104
  不做解析,以便后续转发、序列化
3105
3105
  Set parse_object during this rpc, and restore the original after the end.
3106
3106
  When it is false, the returned DdbObj only contains buffer and le without parsing,
3107
- so as to facilitate subsequent forwarding and serialization */
3108
- async eval(script, { urgent, listener, parse_object, } = {}) {
3107
+ so as to facilitate subsequent forwarding and serialization
3108
+ - iife?: 使用 `def () { ... } ()` 包裹脚本,return 最后一行,避免变量泄漏 */
3109
+ async eval(script, { urgent, listener, parse_object, iife, } = {}) {
3110
+ if (iife) {
3111
+ const lines = script.split_lines();
3112
+ if (lines.length < 2)
3113
+ throw new Error(t('iife 执行的脚本行数应该至少为 2 行'));
3114
+ script =
3115
+ 'def () {\n' +
3116
+ lines.slice(0, -1).indent().join_lines() +
3117
+ ` return ${lines.last}\n`;
3118
+ '} ()\n';
3119
+ }
3109
3120
  return this.rpc('script', { script, urgent, listener, parse_object });
3110
3121
  }
3111
3122
  /** call function through websocket (function command)
@@ -3221,7 +3232,7 @@ export class DDB {
3221
3232
  const result = simple
3222
3233
  ? await this.call(func, args, options)
3223
3234
  : await this.call('invoke', [func, JSON.stringify(args)], options);
3224
- return result.data();
3235
+ return result.data(options);
3225
3236
  }
3226
3237
  /** 执行 dolphindb 脚本,返回 js 原生对象或值(调用 DdbObj.data() 后的结果)
3227
3238
  - script?: 执行的脚本
@@ -3230,7 +3241,7 @@ export class DDB {
3230
3241
  - listener?: 处理本次 rpc 期间的消息 (DdbMessage) */
3231
3242
  async execute(script, options) {
3232
3243
  return (await this.eval(script, options))
3233
- .data();
3244
+ .data(options);
3234
3245
  }
3235
3246
  /** upload variable through websocket (variable command) */
3236
3247
  async upload(