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/index.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/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DDB = exports.str2nanotimestamp = exports.nanotimestamp2str = exports.str2timestamp = exports.timestamp2str = exports.datetime2str = exports.date2str = exports.
|
|
3
|
+
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.ddb_sizes = exports.DdbType = exports.DdbForm = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const ws_1 = require("ws");
|
|
6
6
|
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
@@ -746,15 +746,12 @@ class DdbObj {
|
|
|
746
746
|
case DdbForm.table:
|
|
747
747
|
return [
|
|
748
748
|
Uint32Array.of(this.rows, this.cols),
|
|
749
|
-
DdbObj.enc.encode(this.name),
|
|
749
|
+
DdbObj.enc.encode(this.name || ''),
|
|
750
|
+
// column names
|
|
750
751
|
Uint8Array.of(0),
|
|
751
|
-
...DdbObj.pack_vector_body(this.value.map(col => col.name), DdbType.string, this.cols),
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
for (let i = 0; i < cols.length; i++)
|
|
755
|
-
cols[i] = this.value[i].pack();
|
|
756
|
-
return cols;
|
|
757
|
-
})()
|
|
752
|
+
...DdbObj.pack_vector_body(this.value.map((col, i) => col.name || `col${i}`), DdbType.string, this.cols),
|
|
753
|
+
// column vectors
|
|
754
|
+
...this.value.map(col => col.pack())
|
|
758
755
|
];
|
|
759
756
|
case DdbForm.dict:
|
|
760
757
|
return [
|
|
@@ -1053,18 +1050,42 @@ class DdbNanoTimeStamp extends DdbObj {
|
|
|
1053
1050
|
}
|
|
1054
1051
|
}
|
|
1055
1052
|
exports.DdbNanoTimeStamp = DdbNanoTimeStamp;
|
|
1053
|
+
class DdbPair extends DdbObj {
|
|
1054
|
+
constructor(l, r = null) {
|
|
1055
|
+
super({
|
|
1056
|
+
form: DdbForm.pair,
|
|
1057
|
+
type: DdbType.int,
|
|
1058
|
+
length: 0,
|
|
1059
|
+
rows: 2,
|
|
1060
|
+
cols: 1,
|
|
1061
|
+
value: Int32Array.of(l === null ? exports.nulls.int32 : l, r === null ? exports.nulls.int32 : r)
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
exports.DdbPair = DdbPair;
|
|
1066
|
+
class DdbFunction extends DdbObj {
|
|
1067
|
+
constructor(name, type) {
|
|
1068
|
+
super({
|
|
1069
|
+
form: DdbForm.scalar,
|
|
1070
|
+
type: DdbType.functiondef,
|
|
1071
|
+
length: 0,
|
|
1072
|
+
value: { type, name }
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
exports.DdbFunction = DdbFunction;
|
|
1056
1077
|
class DdbVectorInt extends DdbObj {
|
|
1057
|
-
constructor(
|
|
1078
|
+
constructor(ints, name) {
|
|
1058
1079
|
super({
|
|
1059
1080
|
form: DdbForm.vector,
|
|
1060
1081
|
type: DdbType.int,
|
|
1061
1082
|
length: 0,
|
|
1062
|
-
rows:
|
|
1083
|
+
rows: ints.length,
|
|
1063
1084
|
cols: 1,
|
|
1064
|
-
value:
|
|
1065
|
-
|
|
1085
|
+
value: ints instanceof Int32Array ?
|
|
1086
|
+
ints
|
|
1066
1087
|
:
|
|
1067
|
-
Int32Array.from(
|
|
1088
|
+
Int32Array.from(ints, v => v === null ?
|
|
1068
1089
|
exports.nulls.int32
|
|
1069
1090
|
:
|
|
1070
1091
|
v),
|
|
@@ -1074,31 +1095,31 @@ class DdbVectorInt extends DdbObj {
|
|
|
1074
1095
|
}
|
|
1075
1096
|
exports.DdbVectorInt = DdbVectorInt;
|
|
1076
1097
|
class DdbVectorString extends DdbObj {
|
|
1077
|
-
constructor(
|
|
1098
|
+
constructor(strings, name) {
|
|
1078
1099
|
super({
|
|
1079
1100
|
form: DdbForm.vector,
|
|
1080
1101
|
type: DdbType.string,
|
|
1081
1102
|
length: 0,
|
|
1082
|
-
rows:
|
|
1103
|
+
rows: strings.length,
|
|
1083
1104
|
cols: 1,
|
|
1084
|
-
value,
|
|
1105
|
+
value: strings,
|
|
1085
1106
|
name,
|
|
1086
1107
|
});
|
|
1087
1108
|
}
|
|
1088
1109
|
}
|
|
1089
1110
|
exports.DdbVectorString = DdbVectorString;
|
|
1090
1111
|
class DdbVectorDouble extends DdbObj {
|
|
1091
|
-
constructor(
|
|
1112
|
+
constructor(doubles, name) {
|
|
1092
1113
|
super({
|
|
1093
1114
|
form: DdbForm.vector,
|
|
1094
1115
|
type: DdbType.double,
|
|
1095
1116
|
length: 0,
|
|
1096
|
-
rows:
|
|
1117
|
+
rows: doubles.length,
|
|
1097
1118
|
cols: 1,
|
|
1098
|
-
value:
|
|
1099
|
-
|
|
1119
|
+
value: doubles instanceof Float64Array ?
|
|
1120
|
+
doubles
|
|
1100
1121
|
:
|
|
1101
|
-
Float64Array.from(
|
|
1122
|
+
Float64Array.from(doubles, v => v === null ?
|
|
1102
1123
|
exports.nulls.double
|
|
1103
1124
|
:
|
|
1104
1125
|
v),
|
|
@@ -1108,27 +1129,27 @@ class DdbVectorDouble extends DdbObj {
|
|
|
1108
1129
|
}
|
|
1109
1130
|
exports.DdbVectorDouble = DdbVectorDouble;
|
|
1110
1131
|
class DdbVectorAny extends DdbObj {
|
|
1111
|
-
constructor(
|
|
1132
|
+
constructor(objs, name) {
|
|
1112
1133
|
super({
|
|
1113
1134
|
form: DdbForm.vector,
|
|
1114
1135
|
type: DdbType.any,
|
|
1115
1136
|
length: 0,
|
|
1116
|
-
rows:
|
|
1137
|
+
rows: objs.length,
|
|
1117
1138
|
cols: 1,
|
|
1118
|
-
value,
|
|
1139
|
+
value: objs,
|
|
1119
1140
|
name,
|
|
1120
1141
|
});
|
|
1121
1142
|
}
|
|
1122
1143
|
}
|
|
1123
1144
|
exports.DdbVectorAny = DdbVectorAny;
|
|
1124
1145
|
class DdbVectorSymbol extends DdbObj {
|
|
1125
|
-
constructor(
|
|
1146
|
+
constructor(strings, name) {
|
|
1126
1147
|
let map = new Map([
|
|
1127
1148
|
['', 0]
|
|
1128
1149
|
]);
|
|
1129
|
-
let data = new Uint32Array(
|
|
1130
|
-
for (let i = 0; i <
|
|
1131
|
-
const x =
|
|
1150
|
+
let data = new Uint32Array(strings.length);
|
|
1151
|
+
for (let i = 0; i < strings.length; i++) {
|
|
1152
|
+
const x = strings[i];
|
|
1132
1153
|
let index = map.get(x);
|
|
1133
1154
|
if (index === undefined) {
|
|
1134
1155
|
index = map.size;
|
|
@@ -1140,7 +1161,7 @@ class DdbVectorSymbol extends DdbObj {
|
|
|
1140
1161
|
form: DdbForm.vector,
|
|
1141
1162
|
type: DdbType.symbol_extended,
|
|
1142
1163
|
length: 0,
|
|
1143
|
-
rows:
|
|
1164
|
+
rows: strings.length,
|
|
1144
1165
|
cols: 1,
|
|
1145
1166
|
value: {
|
|
1146
1167
|
base: [...map.keys()],
|
|
@@ -1152,30 +1173,20 @@ class DdbVectorSymbol extends DdbObj {
|
|
|
1152
1173
|
}
|
|
1153
1174
|
}
|
|
1154
1175
|
exports.DdbVectorSymbol = DdbVectorSymbol;
|
|
1155
|
-
class
|
|
1156
|
-
constructor(
|
|
1176
|
+
class DdbTable extends DdbObj {
|
|
1177
|
+
constructor(columns, name = '') {
|
|
1157
1178
|
super({
|
|
1158
|
-
form: DdbForm.
|
|
1159
|
-
type: DdbType.
|
|
1160
|
-
length: 0,
|
|
1161
|
-
rows: 2,
|
|
1162
|
-
cols: 1,
|
|
1163
|
-
value: Int32Array.of(l === null ? exports.nulls.int32 : l, r === null ? exports.nulls.int32 : r)
|
|
1164
|
-
});
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
exports.DdbPair = DdbPair;
|
|
1168
|
-
class DdbFunction extends DdbObj {
|
|
1169
|
-
constructor(name, type) {
|
|
1170
|
-
super({
|
|
1171
|
-
form: DdbForm.scalar,
|
|
1172
|
-
type: DdbType.functiondef,
|
|
1179
|
+
form: DdbForm.table,
|
|
1180
|
+
type: DdbType.void,
|
|
1173
1181
|
length: 0,
|
|
1174
|
-
|
|
1182
|
+
rows: columns[0].rows,
|
|
1183
|
+
cols: columns.length,
|
|
1184
|
+
name,
|
|
1185
|
+
value: columns,
|
|
1175
1186
|
});
|
|
1176
1187
|
}
|
|
1177
1188
|
}
|
|
1178
|
-
exports.
|
|
1189
|
+
exports.DdbTable = DdbTable;
|
|
1179
1190
|
function date2str(date, format = 'YYYY.MM.DD') {
|
|
1180
1191
|
return date === exports.nulls.int32 ?
|
|
1181
1192
|
''
|