dolphindb 3.0.126 → 3.0.128
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 +9 -4
- package/browser.js +21 -3
- package/browser.js.map +1 -1
- package/index.d.ts +9 -4
- package/index.js +21 -3
- package/index.js.map +1 -1
- package/package.json +5 -5
package/browser.d.ts
CHANGED
|
@@ -410,10 +410,12 @@ export declare function formati(obj: DdbVectorObj, index: number, options?: Insp
|
|
|
410
410
|
export interface ConvertOptions {
|
|
411
411
|
/** `'string'` blob 类型数据的格式 */
|
|
412
412
|
blob?: 'string' | 'binary';
|
|
413
|
-
/**
|
|
413
|
+
/** `'string'` char 类型数据的格式: string 解析成 string[],number 解析为 number[] */
|
|
414
|
+
char?: 'string' | 'number';
|
|
415
|
+
/** `'ms'` timestamp 类型转换为字符串表示时显示到秒还是毫秒 */
|
|
414
416
|
timestamp?: 's' | 'ms';
|
|
415
417
|
}
|
|
416
|
-
export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, timestamp }?: ConvertOptions): string | number | bigint | boolean | Uint8Array |
|
|
418
|
+
export declare function convert(type: DdbType, value: DdbValue, le: boolean, { blob, char, timestamp }?: ConvertOptions): string | number | bigint | boolean | Uint8Array | DdbFunctionDefValue | DdbDurationValue | DdbDecimal32Value | DdbDecimal64Value | DdbDecimal32VectorValue | Int32Array | DdbDecimal64VectorValue | BigInt64Array | DdbDecimal128VectorValue | BigInt128Array | DdbSymbolExtendedValue | string[] | Int8Array | Int16Array | Float32Array | Float64Array | DdbArrayVectorValue | DdbMatrixValue | Uint8Array[] | DdbObj<DdbValue>[] | IotVectorItemValue | DdbDurationVectorValue | number[] | DdbTensorValue | DdbChartValue;
|
|
417
419
|
/** 转换一个向量到 js 原生数组 */
|
|
418
420
|
export declare function converts(type: DdbType, value: DdbVectorValue, rows: number, le: boolean, options?: ConvertOptions): any[];
|
|
419
421
|
export declare class DdbVoid extends DdbObj<undefined> {
|
|
@@ -432,7 +434,7 @@ export declare class DdbString extends DdbObj<string> {
|
|
|
432
434
|
constructor(value: string);
|
|
433
435
|
}
|
|
434
436
|
export declare class DdbLong extends DdbObj<bigint> {
|
|
435
|
-
constructor(value: bigint | null);
|
|
437
|
+
constructor(value: bigint | number | null);
|
|
436
438
|
}
|
|
437
439
|
export declare class DdbDouble extends DdbObj<number> {
|
|
438
440
|
constructor(value: number | null);
|
|
@@ -441,7 +443,10 @@ export declare class DdbDateTime extends DdbObj<number> {
|
|
|
441
443
|
constructor(value: number | null);
|
|
442
444
|
}
|
|
443
445
|
export declare class DdbTimeStamp extends DdbObj<bigint> {
|
|
444
|
-
|
|
446
|
+
/** @example
|
|
447
|
+
new DdbTimeStamp(new Date().getTime())
|
|
448
|
+
new DdbTimeStamp(dayjs().valueOf()) */
|
|
449
|
+
constructor(value?: bigint | null | number);
|
|
445
450
|
}
|
|
446
451
|
export declare class DdbNanoTimeStamp extends DdbObj<bigint> {
|
|
447
452
|
constructor(value: bigint | null);
|
package/browser.js
CHANGED
|
@@ -834,7 +834,7 @@ export class DdbObj {
|
|
|
834
834
|
for (let i = 1; i < length; i++) {
|
|
835
835
|
const sub_vector = anys[i];
|
|
836
836
|
const sub_type = sub_vector.type;
|
|
837
|
-
sub_vecs.set(sub_type,
|
|
837
|
+
sub_vecs.set(sub_type, sub_vector.data());
|
|
838
838
|
}
|
|
839
839
|
return [
|
|
840
840
|
len,
|
|
@@ -1980,12 +1980,20 @@ export function formati(obj, index, options = {}) {
|
|
|
1980
1980
|
}
|
|
1981
1981
|
}
|
|
1982
1982
|
}
|
|
1983
|
-
export function convert(type, value, le, { blob = 'string', timestamp = 'ms' } = {}) {
|
|
1983
|
+
export function convert(type, value, le, { blob = 'string', char = 'string', timestamp = 'ms' } = {}) {
|
|
1984
1984
|
switch (type) {
|
|
1985
1985
|
case DdbType.void:
|
|
1986
1986
|
return value === DdbVoidType.null ? null : undefined;
|
|
1987
1987
|
case DdbType.char:
|
|
1988
|
-
return
|
|
1988
|
+
return char === 'string'
|
|
1989
|
+
? value === null || value === nulls.int8
|
|
1990
|
+
? ''
|
|
1991
|
+
: // ascii printable
|
|
1992
|
+
// http://facweb.cs.depaul.edu/sjost/it212/documents/ascii-pr.htm
|
|
1993
|
+
(32 <= value && value <= 126)
|
|
1994
|
+
? String.fromCharCode(value)
|
|
1995
|
+
: `\\${value}`
|
|
1996
|
+
: value;
|
|
1989
1997
|
case DdbType.bool:
|
|
1990
1998
|
return value === null || value === nulls.int8 ? null : Boolean(value);
|
|
1991
1999
|
case DdbType.short:
|
|
@@ -2183,6 +2191,8 @@ export class DdbString extends DdbObj {
|
|
|
2183
2191
|
}
|
|
2184
2192
|
export class DdbLong extends DdbObj {
|
|
2185
2193
|
constructor(value) {
|
|
2194
|
+
if (typeof value === 'number')
|
|
2195
|
+
value = BigInt(value);
|
|
2186
2196
|
super({
|
|
2187
2197
|
form: DdbForm.scalar,
|
|
2188
2198
|
type: DdbType.long,
|
|
@@ -2209,7 +2219,15 @@ export class DdbDateTime extends DdbObj {
|
|
|
2209
2219
|
}
|
|
2210
2220
|
}
|
|
2211
2221
|
export class DdbTimeStamp extends DdbObj {
|
|
2222
|
+
/** @example
|
|
2223
|
+
new DdbTimeStamp(new Date().getTime())
|
|
2224
|
+
new DdbTimeStamp(dayjs().valueOf()) */
|
|
2212
2225
|
constructor(value) {
|
|
2226
|
+
if (value === undefined)
|
|
2227
|
+
value = new Date().getTime();
|
|
2228
|
+
if (typeof value === 'number')
|
|
2229
|
+
value = BigInt(-(1000 * 60 * new Date(value).getTimezoneOffset()) +
|
|
2230
|
+
value);
|
|
2213
2231
|
super({
|
|
2214
2232
|
form: DdbForm.scalar,
|
|
2215
2233
|
type: DdbType.timestamp,
|