dolphindb 0.0.14 → 2.0.501

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 CHANGED
@@ -220,6 +220,15 @@ const obj = new DdbObj({
220
220
  })
221
221
  ```
222
222
 
223
+ ##### NULL object in the form of scalar, the value corresponding to DdbObj is null in JavaScript
224
+ ```ts
225
+ ;(await ddb.eval('double()')).value === null
226
+
227
+ // create NULL object
228
+ new DdbInt(null)
229
+ new DdbDouble(null)
230
+ ```
231
+
223
232
 
224
233
  #### `call` Method Declaration
225
234
  ```ts
@@ -321,18 +330,38 @@ async upload (
321
330
  ```
322
331
 
323
332
 
324
- ### Notes
333
+ ### Some Examples
325
334
  ```ts
326
- import { nulls, DdbInt, timestamp2str } from 'dolphindb'
335
+ import { nulls, DdbInt, timestamp2str, DdbVectorSymbol, DdbTable, DdbVectorDouble } from 'dolphindb'
327
336
 
328
- // create DolphinDB null integer value (the smallest 32-bit integer)
329
- new DdbInt(nulls.int32)
330
-
331
- // convert DolphinDB timestamp value to string
337
+ // Format timestamp in DolphinDB as string
332
338
  timestamp2str(
333
339
  (
334
- await ddb.call<DdbObj<bigint>>('now', [false])
340
+ await ddb.call('now', [false])
341
+ // TypeScript: await ddb.call<DdbObj<bigint>>('now', [false])
335
342
  ).value
336
343
  ) === '2022.02.23 17:23:13.494'
344
+
345
+ // create symbol vector
346
+ new DdbVectorSymbol(['aaa', 'aaa', 'aaa', 'aaa', 'aaa', 'bbb'])
347
+
348
+ // Create a double vector with NULL values using JavaScript native arrays
349
+ new DdbVectorDouble([0.1, null, 0.3])
350
+
351
+ // More efficient and memory efficient double vector creation using JavaScript TypedArray
352
+ let av = new Float64Array(3)
353
+ av[0] = 0.1
354
+ av[1] = nulls.double
355
+ av[2] = 0.3
356
+ new DdbVectorDouble(av)
357
+
358
+ // create DdbTable
359
+ new DdbTable(
360
+ [
361
+ new DdbVectorDouble([0.1, 0.2, null], 'col0'),
362
+ new DdbVectorSymbol(['a', 'b', 'c'], 'col1')
363
+ ],
364
+ 'mytable'
365
+ )
337
366
  ```
338
367
 
package/README.zh.md CHANGED
@@ -221,6 +221,15 @@ const obj = new DdbObj({
221
221
  })
222
222
  ```
223
223
 
224
+ ##### scalar 形式的 NULL 对象, 对应 DdbObj 的 value 为 JavaScript 中的 null
225
+ ```ts
226
+ ;(await ddb.eval('double()')).value === null
227
+
228
+ // 创建 NULL 对象
229
+ new DdbInt(null)
230
+ new DdbDouble(null)
231
+ ```
232
+
224
233
 
225
234
  #### `call` 方法声明
226
235
  ```ts
@@ -322,17 +331,37 @@ async upload (
322
331
  ```
323
332
 
324
333
 
325
- ### Notes
334
+ ### 一些例子
326
335
  ```ts
327
- import { nulls, DdbInt, timestamp2str } from 'dolphindb'
328
-
329
- // 创建 DolphinDB 空值 (最小的 32-bit 整数)
330
- new DdbInt(nulls.int32)
336
+ import { nulls, DdbInt, timestamp2str, DdbVectorSymbol, DdbTable, DdbVectorDouble } from 'dolphindb'
331
337
 
332
338
  // 将 DolphinDB 中的 timestamp 格式化为 string
333
339
  timestamp2str(
334
340
  (
335
- await ddb.call<DdbObj<bigint>>('now', [false])
341
+ await ddb.call('now', [false])
342
+ // TypeScript: await ddb.call<DdbObj<bigint>>('now', [false])
336
343
  ).value
337
344
  ) === '2022.02.23 17:23:13.494'
345
+
346
+ // 创建 symbol vector
347
+ new DdbVectorSymbol(['aaa', 'aaa', 'aaa', 'aaa', 'aaa', 'bbb'])
348
+
349
+ // 使用 JavaScript 原生数组创建含有 NULL 值的 double vector
350
+ new DdbVectorDouble([0.1, null, 0.3])
351
+
352
+ // 使用 JavaScript TypedArray 更加高效且节约内存的创建 double vector
353
+ let av = new Float64Array(3)
354
+ av[0] = 0.1
355
+ av[1] = nulls.double
356
+ av[2] = 0.3
357
+ new DdbVectorDouble(av)
358
+
359
+ // 创建 DdbTable
360
+ new DdbTable(
361
+ [
362
+ new DdbVectorDouble([0.1, 0.2, null], 'col0'),
363
+ new DdbVectorSymbol(['a', 'b', 'c'], 'col1')
364
+ ],
365
+ 'mytable'
366
+ )
338
367
  ```
package/browser.d.ts CHANGED
@@ -78,10 +78,15 @@ export interface DdbArrayVectorBlock {
78
78
  export declare type DdbValue = null | boolean | number | [number, number] | bigint | string | string[] | Uint8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | Uint8Array[] | DdbObj[] | DdbFunctionDefValue | DdbSymbolExtendedValue | DdbArrayVectorBlock[];
79
79
  export declare type DdbVectorValue = string | string[] | Uint8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array | Uint8Array[] | DdbObj[] | DdbSymbolExtendedValue | DdbArrayVectorBlock[];
80
80
  export declare const nulls: {
81
+ readonly bool: 128;
81
82
  readonly char: "€";
82
83
  readonly int16: -32768;
83
84
  readonly int32: -2147483648;
84
85
  readonly int64: -9223372036854775808n;
86
+ readonly float32: -3.4028234663852886e+38;
87
+ /** -Number.MAX_VALUE */
88
+ readonly double: number;
89
+ readonly bytes16: Uint8Array;
85
90
  };
86
91
  export declare const timezone_offset: number;
87
92
  /** 可以表示所有 DolphinDB 数据库中的数据类型 */
@@ -149,57 +154,85 @@ export declare class DdbVoid extends DdbObj<undefined> {
149
154
  constructor();
150
155
  }
151
156
  export declare class DdbBool extends DdbObj<boolean> {
152
- constructor(value: boolean);
157
+ constructor(value: boolean | null);
153
158
  }
154
159
  export declare class DdbChar extends DdbObj<string> {
155
- constructor(value: string);
160
+ constructor(value: string | null);
156
161
  }
157
162
  export declare class DdbInt extends DdbObj<number> {
158
- constructor(value: number);
163
+ constructor(value: number | null);
159
164
  }
160
165
  export declare class DdbString extends DdbObj<string> {
161
166
  constructor(value: string);
162
167
  }
163
168
  export declare class DdbLong extends DdbObj<bigint> {
164
- constructor(value: bigint);
169
+ constructor(value: bigint | null);
165
170
  }
166
171
  export declare class DdbDouble extends DdbObj<number> {
167
- constructor(value: number);
172
+ constructor(value: number | null);
168
173
  }
169
174
  export declare class DdbDateTime extends DdbObj<number> {
170
- constructor(value: number);
175
+ constructor(value: number | null);
171
176
  }
172
177
  export declare class DdbTimeStamp extends DdbObj<bigint> {
173
- constructor(value: bigint);
178
+ constructor(value: bigint | null);
174
179
  }
175
180
  export declare class DdbNanoTimeStamp extends DdbObj<bigint> {
176
- constructor(value: bigint);
181
+ constructor(value: bigint | null);
182
+ }
183
+ export declare class DdbPair extends DdbObj<Int32Array> {
184
+ constructor(l: number | null, r?: number | null);
185
+ }
186
+ export declare class DdbFunction extends DdbObj<DdbFunctionDefValue> {
187
+ constructor(name: string, type: DdbFunctionType);
177
188
  }
178
189
  export declare class DdbVectorInt extends DdbObj<Int32Array> {
179
- constructor(value: number[], name?: string);
190
+ constructor(ints: (number | null)[] | Int32Array, name?: string);
180
191
  }
181
192
  export declare class DdbVectorString extends DdbObj<string[]> {
182
- constructor(value: string[], name?: string);
193
+ constructor(strings: string[], name?: string);
183
194
  }
184
195
  export declare class DdbVectorDouble extends DdbObj<Float64Array> {
185
- constructor(value: number[], name?: string);
196
+ constructor(doubles: (number | null)[] | Float64Array, name?: string);
186
197
  }
187
198
  export declare class DdbVectorAny extends DdbObj {
188
- constructor(value: DdbObj<DdbValue>[], name?: string);
199
+ constructor(objs: DdbObj<DdbValue>[], name?: string);
189
200
  }
190
- export declare class DdbPair extends DdbObj<Int32Array> {
191
- constructor(l: number, r?: number);
201
+ export declare class DdbVectorSymbol extends DdbObj<DdbSymbolExtendedValue> {
202
+ constructor(strings: string[], name?: string);
192
203
  }
193
- export declare class DdbFunction extends DdbObj<DdbFunctionDefValue> {
194
- constructor(name: string, type: DdbFunctionType);
204
+ export declare class DdbTable extends DdbObj<DdbObj[]> {
205
+ constructor(columns: DdbObj[], name?: string);
195
206
  }
196
207
  export declare function date2str(date: number, format?: string): string;
197
208
  export declare function datetime2str(datetime: number, format?: string): string;
198
- export declare function timestamp2str(timestamp: bigint): string;
209
+ /** format timestamp (bigint) to string
210
+ - timestamp: bigint value
211
+ - format?:
212
+ format string, default to `YYYY.MM.DD HH:mm:ss.SSS`
213
+ https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
214
+ */
215
+ export declare function timestamp2str(timestamp: bigint, format?: string): string;
216
+ /** parse timestamp string to bigint value
217
+ - str: timestamp string, If it is an empty string, it will return the corresponding empty value (nulls.int64)
218
+ - format?:
219
+ The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSS`
220
+ https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
221
+ */
222
+ export declare function str2timestamp(str: string, format?: string): bigint;
223
+ /** format nanotimestamp value (bigint) to string
224
+ - nanotimestamp: bigint value
225
+ - format?:
226
+ format string, default is `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
227
+ Seconds are in the format ss (must be included); nanoseconds are in the format SSSSSSSSS (must be included)
228
+ https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
229
+ */
199
230
  export declare function nanotimestamp2str(nanotimestamp: bigint, format?: string): string;
200
231
  /** parse nano timestamp string to bigint value
201
- - str: nano timestamp string, 如果为空字符串会返回对应的空值 (nulls.int64)
202
- - format?: Format string up to and including seconds of the passed string, default is `YYYY.MM.DD HH:mm:ss`
232
+ - str: nano timestamp string, If it is an empty string, it will return the corresponding empty value (nulls.int64)
233
+ - format?:
234
+ The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
235
+ Seconds are in the format ss (must be included); nanoseconds are in the format SSSSSSSSS (must be included)
203
236
  https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
204
237
  */
205
238
  export declare function str2nanotimestamp(str: string, format?: string): bigint;
@@ -227,6 +260,7 @@ export declare class DDB {
227
260
  presolver(buf: Uint8Array): void;
228
261
  prejector(error: Error): void;
229
262
  presult: Promise<Uint8Array>;
263
+ get connected(): boolean;
230
264
  /**
231
265
  Initialize an instance of DolphinDB Client using the WebSocket URL
232
266
  (without establishing an actual network connection)
@@ -327,7 +361,7 @@ export declare class DDB {
327
361
  };
328
362
  /** 自动转换 js string, boolean 为 DdbObj */
329
363
  to_ddbobj(value: DdbObj | string | boolean): DdbObj;
330
- /** 转换 js 数组为 DdbObj[] (in place, 会修改原数组) */
364
+ /** 转换 js 数组为 DdbObj[] */
331
365
  to_ddbobjs(values: any[]): DdbObj<DdbValue>[];
332
366
  }
333
367
  export declare let ddb: DDB;