dolphindb 2.0.500 → 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 +13 -3
- package/README.zh.md +13 -3
- package/browser.d.ts +13 -10
- package/browser.js +60 -49
- package/browser.js.map +1 -1
- package/index.d.ts +13 -10
- package/index.js +60 -49
- package/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -330,14 +330,15 @@ async upload (
|
|
|
330
330
|
```
|
|
331
331
|
|
|
332
332
|
|
|
333
|
-
###
|
|
333
|
+
### Some Examples
|
|
334
334
|
```ts
|
|
335
|
-
import { nulls, DdbInt, timestamp2str, DdbVectorSymbol } from 'dolphindb'
|
|
335
|
+
import { nulls, DdbInt, timestamp2str, DdbVectorSymbol, DdbTable, DdbVectorDouble } from 'dolphindb'
|
|
336
336
|
|
|
337
337
|
// Format timestamp in DolphinDB as string
|
|
338
338
|
timestamp2str(
|
|
339
339
|
(
|
|
340
|
-
await ddb.call
|
|
340
|
+
await ddb.call('now', [false])
|
|
341
|
+
// TypeScript: await ddb.call<DdbObj<bigint>>('now', [false])
|
|
341
342
|
).value
|
|
342
343
|
) === '2022.02.23 17:23:13.494'
|
|
343
344
|
|
|
@@ -353,5 +354,14 @@ av[0] = 0.1
|
|
|
353
354
|
av[1] = nulls.double
|
|
354
355
|
av[2] = 0.3
|
|
355
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
|
+
)
|
|
356
366
|
```
|
|
357
367
|
|
package/README.zh.md
CHANGED
|
@@ -331,14 +331,15 @@ async upload (
|
|
|
331
331
|
```
|
|
332
332
|
|
|
333
333
|
|
|
334
|
-
###
|
|
334
|
+
### 一些例子
|
|
335
335
|
```ts
|
|
336
|
-
import { nulls, DdbInt, timestamp2str, DdbVectorSymbol } from 'dolphindb'
|
|
336
|
+
import { nulls, DdbInt, timestamp2str, DdbVectorSymbol, DdbTable, DdbVectorDouble } from 'dolphindb'
|
|
337
337
|
|
|
338
338
|
// 将 DolphinDB 中的 timestamp 格式化为 string
|
|
339
339
|
timestamp2str(
|
|
340
340
|
(
|
|
341
|
-
await ddb.call
|
|
341
|
+
await ddb.call('now', [false])
|
|
342
|
+
// TypeScript: await ddb.call<DdbObj<bigint>>('now', [false])
|
|
342
343
|
).value
|
|
343
344
|
) === '2022.02.23 17:23:13.494'
|
|
344
345
|
|
|
@@ -354,4 +355,13 @@ av[0] = 0.1
|
|
|
354
355
|
av[1] = nulls.double
|
|
355
356
|
av[2] = 0.3
|
|
356
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
|
+
)
|
|
357
367
|
```
|
package/browser.d.ts
CHANGED
|
@@ -180,26 +180,29 @@ export declare class DdbTimeStamp extends DdbObj<bigint> {
|
|
|
180
180
|
export declare class DdbNanoTimeStamp extends DdbObj<bigint> {
|
|
181
181
|
constructor(value: bigint | null);
|
|
182
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);
|
|
188
|
+
}
|
|
183
189
|
export declare class DdbVectorInt extends DdbObj<Int32Array> {
|
|
184
|
-
constructor(
|
|
190
|
+
constructor(ints: (number | null)[] | Int32Array, name?: string);
|
|
185
191
|
}
|
|
186
192
|
export declare class DdbVectorString extends DdbObj<string[]> {
|
|
187
|
-
constructor(
|
|
193
|
+
constructor(strings: string[], name?: string);
|
|
188
194
|
}
|
|
189
195
|
export declare class DdbVectorDouble extends DdbObj<Float64Array> {
|
|
190
|
-
constructor(
|
|
196
|
+
constructor(doubles: (number | null)[] | Float64Array, name?: string);
|
|
191
197
|
}
|
|
192
198
|
export declare class DdbVectorAny extends DdbObj {
|
|
193
|
-
constructor(
|
|
199
|
+
constructor(objs: DdbObj<DdbValue>[], name?: string);
|
|
194
200
|
}
|
|
195
201
|
export declare class DdbVectorSymbol extends DdbObj<DdbSymbolExtendedValue> {
|
|
196
|
-
constructor(
|
|
202
|
+
constructor(strings: string[], name?: string);
|
|
197
203
|
}
|
|
198
|
-
export declare class
|
|
199
|
-
constructor(
|
|
200
|
-
}
|
|
201
|
-
export declare class DdbFunction extends DdbObj<DdbFunctionDefValue> {
|
|
202
|
-
constructor(name: string, type: DdbFunctionType);
|
|
204
|
+
export declare class DdbTable extends DdbObj<DdbObj[]> {
|
|
205
|
+
constructor(columns: DdbObj[], name?: string);
|
|
203
206
|
}
|
|
204
207
|
export declare function date2str(date: number, format?: string): string;
|
|
205
208
|
export declare function datetime2str(datetime: number, format?: string): string;
|
package/browser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ddb = exports.DDB = exports.str2nanotimestamp = exports.nanotimestamp2str = exports.str2timestamp = exports.timestamp2str = exports.datetime2str = exports.date2str = exports.
|
|
3
|
+
exports.ddb = exports.DDB = exports.str2nanotimestamp = exports.nanotimestamp2str = exports.str2timestamp = exports.timestamp2str = exports.datetime2str = exports.date2str = exports.DdbTable = exports.DdbVectorSymbol = exports.DdbVectorAny = exports.DdbVectorDouble = exports.DdbVectorString = exports.DdbVectorInt = exports.DdbFunction = exports.DdbPair = exports.DdbNanoTimeStamp = exports.DdbTimeStamp = exports.DdbDateTime = exports.DdbDouble = exports.DdbLong = exports.DdbString = exports.DdbInt = exports.DdbChar = exports.DdbBool = exports.DdbVoid = exports.DdbObj = exports.timezone_offset = exports.nulls = exports.DdbFunctionType = exports.DdbType = exports.DdbForm = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
6
6
|
const customParseFormat_js_1 = tslib_1.__importDefault(require("dayjs/plugin/customParseFormat.js"));
|
|
@@ -709,15 +709,12 @@ class DdbObj {
|
|
|
709
709
|
case DdbForm.table:
|
|
710
710
|
return [
|
|
711
711
|
Uint32Array.of(this.rows, this.cols),
|
|
712
|
-
DdbObj.enc.encode(this.name),
|
|
712
|
+
DdbObj.enc.encode(this.name || ''),
|
|
713
|
+
// column names
|
|
713
714
|
Uint8Array.of(0),
|
|
714
|
-
...DdbObj.pack_vector_body(this.value.map(col => col.name), DdbType.string, this.cols),
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
for (let i = 0; i < cols.length; i++)
|
|
718
|
-
cols[i] = this.value[i].pack();
|
|
719
|
-
return cols;
|
|
720
|
-
})()
|
|
715
|
+
...DdbObj.pack_vector_body(this.value.map((col, i) => col.name || `col${i}`), DdbType.string, this.cols),
|
|
716
|
+
// column vectors
|
|
717
|
+
...this.value.map(col => col.pack())
|
|
721
718
|
];
|
|
722
719
|
case DdbForm.dict:
|
|
723
720
|
return [
|
|
@@ -1032,18 +1029,42 @@ class DdbNanoTimeStamp extends DdbObj {
|
|
|
1032
1029
|
}
|
|
1033
1030
|
}
|
|
1034
1031
|
exports.DdbNanoTimeStamp = DdbNanoTimeStamp;
|
|
1032
|
+
class DdbPair extends DdbObj {
|
|
1033
|
+
constructor(l, r = null) {
|
|
1034
|
+
super({
|
|
1035
|
+
form: DdbForm.pair,
|
|
1036
|
+
type: DdbType.int,
|
|
1037
|
+
length: 0,
|
|
1038
|
+
rows: 2,
|
|
1039
|
+
cols: 1,
|
|
1040
|
+
value: Int32Array.of(l === null ? exports.nulls.int32 : l, r === null ? exports.nulls.int32 : r)
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
exports.DdbPair = DdbPair;
|
|
1045
|
+
class DdbFunction extends DdbObj {
|
|
1046
|
+
constructor(name, type) {
|
|
1047
|
+
super({
|
|
1048
|
+
form: DdbForm.scalar,
|
|
1049
|
+
type: DdbType.functiondef,
|
|
1050
|
+
length: 0,
|
|
1051
|
+
value: { type, name }
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
exports.DdbFunction = DdbFunction;
|
|
1035
1056
|
class DdbVectorInt extends DdbObj {
|
|
1036
|
-
constructor(
|
|
1057
|
+
constructor(ints, name) {
|
|
1037
1058
|
super({
|
|
1038
1059
|
form: DdbForm.vector,
|
|
1039
1060
|
type: DdbType.int,
|
|
1040
1061
|
length: 0,
|
|
1041
|
-
rows:
|
|
1062
|
+
rows: ints.length,
|
|
1042
1063
|
cols: 1,
|
|
1043
|
-
value:
|
|
1044
|
-
|
|
1064
|
+
value: ints instanceof Int32Array ?
|
|
1065
|
+
ints
|
|
1045
1066
|
:
|
|
1046
|
-
Int32Array.from(
|
|
1067
|
+
Int32Array.from(ints, v => v === null ?
|
|
1047
1068
|
exports.nulls.int32
|
|
1048
1069
|
:
|
|
1049
1070
|
v),
|
|
@@ -1053,31 +1074,31 @@ class DdbVectorInt extends DdbObj {
|
|
|
1053
1074
|
}
|
|
1054
1075
|
exports.DdbVectorInt = DdbVectorInt;
|
|
1055
1076
|
class DdbVectorString extends DdbObj {
|
|
1056
|
-
constructor(
|
|
1077
|
+
constructor(strings, name) {
|
|
1057
1078
|
super({
|
|
1058
1079
|
form: DdbForm.vector,
|
|
1059
1080
|
type: DdbType.string,
|
|
1060
1081
|
length: 0,
|
|
1061
|
-
rows:
|
|
1082
|
+
rows: strings.length,
|
|
1062
1083
|
cols: 1,
|
|
1063
|
-
value,
|
|
1084
|
+
value: strings,
|
|
1064
1085
|
name,
|
|
1065
1086
|
});
|
|
1066
1087
|
}
|
|
1067
1088
|
}
|
|
1068
1089
|
exports.DdbVectorString = DdbVectorString;
|
|
1069
1090
|
class DdbVectorDouble extends DdbObj {
|
|
1070
|
-
constructor(
|
|
1091
|
+
constructor(doubles, name) {
|
|
1071
1092
|
super({
|
|
1072
1093
|
form: DdbForm.vector,
|
|
1073
1094
|
type: DdbType.double,
|
|
1074
1095
|
length: 0,
|
|
1075
|
-
rows:
|
|
1096
|
+
rows: doubles.length,
|
|
1076
1097
|
cols: 1,
|
|
1077
|
-
value:
|
|
1078
|
-
|
|
1098
|
+
value: doubles instanceof Float64Array ?
|
|
1099
|
+
doubles
|
|
1079
1100
|
:
|
|
1080
|
-
Float64Array.from(
|
|
1101
|
+
Float64Array.from(doubles, v => v === null ?
|
|
1081
1102
|
exports.nulls.double
|
|
1082
1103
|
:
|
|
1083
1104
|
v),
|
|
@@ -1087,27 +1108,27 @@ class DdbVectorDouble extends DdbObj {
|
|
|
1087
1108
|
}
|
|
1088
1109
|
exports.DdbVectorDouble = DdbVectorDouble;
|
|
1089
1110
|
class DdbVectorAny extends DdbObj {
|
|
1090
|
-
constructor(
|
|
1111
|
+
constructor(objs, name) {
|
|
1091
1112
|
super({
|
|
1092
1113
|
form: DdbForm.vector,
|
|
1093
1114
|
type: DdbType.any,
|
|
1094
1115
|
length: 0,
|
|
1095
|
-
rows:
|
|
1116
|
+
rows: objs.length,
|
|
1096
1117
|
cols: 1,
|
|
1097
|
-
value,
|
|
1118
|
+
value: objs,
|
|
1098
1119
|
name,
|
|
1099
1120
|
});
|
|
1100
1121
|
}
|
|
1101
1122
|
}
|
|
1102
1123
|
exports.DdbVectorAny = DdbVectorAny;
|
|
1103
1124
|
class DdbVectorSymbol extends DdbObj {
|
|
1104
|
-
constructor(
|
|
1125
|
+
constructor(strings, name) {
|
|
1105
1126
|
let map = new Map([
|
|
1106
1127
|
['', 0]
|
|
1107
1128
|
]);
|
|
1108
|
-
let data = new Uint32Array(
|
|
1109
|
-
for (let i = 0; i <
|
|
1110
|
-
const x =
|
|
1129
|
+
let data = new Uint32Array(strings.length);
|
|
1130
|
+
for (let i = 0; i < strings.length; i++) {
|
|
1131
|
+
const x = strings[i];
|
|
1111
1132
|
let index = map.get(x);
|
|
1112
1133
|
if (index === undefined) {
|
|
1113
1134
|
index = map.size;
|
|
@@ -1119,7 +1140,7 @@ class DdbVectorSymbol extends DdbObj {
|
|
|
1119
1140
|
form: DdbForm.vector,
|
|
1120
1141
|
type: DdbType.symbol_extended,
|
|
1121
1142
|
length: 0,
|
|
1122
|
-
rows:
|
|
1143
|
+
rows: strings.length,
|
|
1123
1144
|
cols: 1,
|
|
1124
1145
|
value: {
|
|
1125
1146
|
base: [...map.keys()],
|
|
@@ -1131,30 +1152,20 @@ class DdbVectorSymbol extends DdbObj {
|
|
|
1131
1152
|
}
|
|
1132
1153
|
}
|
|
1133
1154
|
exports.DdbVectorSymbol = DdbVectorSymbol;
|
|
1134
|
-
class
|
|
1135
|
-
constructor(
|
|
1155
|
+
class DdbTable extends DdbObj {
|
|
1156
|
+
constructor(columns, name = '') {
|
|
1136
1157
|
super({
|
|
1137
|
-
form: DdbForm.
|
|
1138
|
-
type: DdbType.
|
|
1139
|
-
length: 0,
|
|
1140
|
-
rows: 2,
|
|
1141
|
-
cols: 1,
|
|
1142
|
-
value: Int32Array.of(l === null ? exports.nulls.int32 : l, r === null ? exports.nulls.int32 : r)
|
|
1143
|
-
});
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
exports.DdbPair = DdbPair;
|
|
1147
|
-
class DdbFunction extends DdbObj {
|
|
1148
|
-
constructor(name, type) {
|
|
1149
|
-
super({
|
|
1150
|
-
form: DdbForm.scalar,
|
|
1151
|
-
type: DdbType.functiondef,
|
|
1158
|
+
form: DdbForm.table,
|
|
1159
|
+
type: DdbType.void,
|
|
1152
1160
|
length: 0,
|
|
1153
|
-
|
|
1161
|
+
rows: columns[0].rows,
|
|
1162
|
+
cols: columns.length,
|
|
1163
|
+
name,
|
|
1164
|
+
value: columns,
|
|
1154
1165
|
});
|
|
1155
1166
|
}
|
|
1156
1167
|
}
|
|
1157
|
-
exports.
|
|
1168
|
+
exports.DdbTable = DdbTable;
|
|
1158
1169
|
function date2str(date, format = 'YYYY.MM.DD') {
|
|
1159
1170
|
return date === exports.nulls.int32 ?
|
|
1160
1171
|
''
|