dolphindb 3.1.0 → 3.1.2

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
@@ -185,7 +185,7 @@ export interface InspectOptions {
185
185
  export declare function format(type: DdbType, value: DdbValue, le: boolean, options?: InspectOptions): string;
186
186
  /** 格式化向量、集合中的第 index 项为字符串,空值返回 'null' 字符串 formatted vector, the index-th item in the collection is a string, a null value returns a 'null' string */
187
187
  export declare function formati(obj: DdbVectorObj, index: number, options?: InspectOptions): string;
188
- export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, char, timestamp }?: ConvertOptions): string | number | bigint | boolean | string[] | number[] | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbSymbolExtendedValue | DdbTensorValue | Uint8Array<ArrayBufferLike> | Int8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | BigInt64Array<ArrayBufferLike> | BigInt128Array | Uint8Array<ArrayBufferLike>[] | DdbObj<DdbValue>[] | IotVectorItemValue | DdbArrayVectorValue | DdbDecimal128VectorValue | DdbDurationVectorValue | DdbMatrixValue | DdbChartValue;
188
+ export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, char, timestamp }?: ConvertOptions): string | number | bigint | boolean | number[] | Uint8Array<ArrayBufferLike> | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | Int8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | BigInt64Array<ArrayBufferLike> | BigInt128Array | string[] | Uint8Array<ArrayBufferLike>[] | DdbObj<DdbValue>[] | IotVectorItemValue | DdbSymbolExtendedValue | DdbArrayVectorValue | DdbDecimal32VectorValue | DdbDecimal64VectorValue | DdbDecimal128VectorValue | DdbDurationVectorValue | DdbMatrixValue | DdbChartValue | DdbTensorValue;
189
189
  /** 转换一个向量到 js 原生数组 */
190
190
  export declare function converts(type: DdbType, value: DdbVectorValue, rows: number, le: boolean, options?: ConvertOptions): any[] | Uint8Array;
191
191
  /** 构造 void 类型,默认为 `DdbVoidType.undefined` */
@@ -581,6 +581,8 @@ export declare class DDB {
581
581
  /** 定义函数并保存,避免下次重复执行定义,会自动提取脚本中的函数名,作为缓存 key,
582
582
  也同时作为返回值
583
583
  - definition: 函数完整定义
584
+ - options?:
585
+ - urgent?: 紧急 flag,确保提交的脚本使用 urgent worker 处理,防止被其它作业阻塞
584
586
  @example
585
587
  await ddb.invoke(
586
588
  await ddb.define(
@@ -588,7 +590,9 @@ export declare class DDB {
588
590
  ' print(bar)\n' +
589
591
  '}\n'),
590
592
  ['hello']) */
591
- define(definition: string): Promise<string>;
593
+ define(definition: string, { urgent }?: {
594
+ urgent?: boolean;
595
+ }): Promise<string>;
592
596
  }
593
597
  export interface DdbMessageListener {
594
598
  (message: DdbMessage, _this: DDB): any;
package/browser.js CHANGED
@@ -2957,7 +2957,7 @@ export class DDB {
2957
2957
  }
2958
2958
  let result;
2959
2959
  if (function_definition_pattern.test(func))
2960
- func = await this.define(func);
2960
+ func = await this.define(func, { urgent: options?.urgent });
2961
2961
  if (convertable)
2962
2962
  result = await this.call(func, args, options);
2963
2963
  else {
@@ -3172,6 +3172,8 @@ export class DDB {
3172
3172
  /** 定义函数并保存,避免下次重复执行定义,会自动提取脚本中的函数名,作为缓存 key,
3173
3173
  也同时作为返回值
3174
3174
  - definition: 函数完整定义
3175
+ - options?:
3176
+ - urgent?: 紧急 flag,确保提交的脚本使用 urgent worker 处理,防止被其它作业阻塞
3175
3177
  @example
3176
3178
  await ddb.invoke(
3177
3179
  await ddb.define(
@@ -3179,7 +3181,7 @@ export class DDB {
3179
3181
  ' print(bar)\n' +
3180
3182
  '}\n'),
3181
3183
  ['hello']) */
3182
- async define(definition) {
3184
+ async define(definition, { urgent } = {}) {
3183
3185
  const matches = function_definition_pattern.exec(definition);
3184
3186
  if (!matches)
3185
3187
  throw new Error(t('DDB.define 方法传入的 definition 不符合函数定义格式 def xxx ()'));
@@ -3190,7 +3192,7 @@ export class DDB {
3190
3192
  // 防止并发调用 define 时多次重复定义
3191
3193
  let promise = this.pdefinitions.get(func_name);
3192
3194
  if (!promise)
3193
- this.pdefinitions.set(func_name, promise = this.execute(definition));
3195
+ this.pdefinitions.set(func_name, promise = this.execute(definition, { urgent }));
3194
3196
  await promise;
3195
3197
  this.definitions.set(func_name, definition);
3196
3198
  // 成功定义之后,definitions 中有了,就不需要通过 promise 来防止并发了,清理掉