dolphindb 0.0.9 → 0.0.12
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 +25 -5
- package/browser.js +91 -11
- package/browser.js.map +1 -1
- package/index.d.ts +26 -6
- package/index.js +99 -19
- package/index.js.map +1 -1
- package/package.json +1 -1
package/browser.d.ts
CHANGED
|
@@ -151,6 +151,9 @@ export declare class DdbVoid extends DdbObj<undefined> {
|
|
|
151
151
|
export declare class DdbBool extends DdbObj<boolean> {
|
|
152
152
|
constructor(value: boolean);
|
|
153
153
|
}
|
|
154
|
+
export declare class DdbChar extends DdbObj<string> {
|
|
155
|
+
constructor(value: string);
|
|
156
|
+
}
|
|
154
157
|
export declare class DdbInt extends DdbObj<number> {
|
|
155
158
|
constructor(value: number);
|
|
156
159
|
}
|
|
@@ -163,17 +166,26 @@ export declare class DdbLong extends DdbObj<bigint> {
|
|
|
163
166
|
export declare class DdbDouble extends DdbObj<number> {
|
|
164
167
|
constructor(value: number);
|
|
165
168
|
}
|
|
169
|
+
export declare class DdbDateTime extends DdbObj<number> {
|
|
170
|
+
constructor(value: number);
|
|
171
|
+
}
|
|
172
|
+
export declare class DdbTimeStamp extends DdbObj<bigint> {
|
|
173
|
+
constructor(value: bigint);
|
|
174
|
+
}
|
|
175
|
+
export declare class DdbNanoTimeStamp extends DdbObj<bigint> {
|
|
176
|
+
constructor(value: bigint);
|
|
177
|
+
}
|
|
166
178
|
export declare class DdbVectorInt extends DdbObj<Int32Array> {
|
|
167
|
-
constructor(value: number[]);
|
|
179
|
+
constructor(value: number[], name?: string);
|
|
168
180
|
}
|
|
169
181
|
export declare class DdbVectorString extends DdbObj<string[]> {
|
|
170
|
-
constructor(value: string[]);
|
|
182
|
+
constructor(value: string[], name?: string);
|
|
171
183
|
}
|
|
172
184
|
export declare class DdbVectorDouble extends DdbObj<Float64Array> {
|
|
173
|
-
constructor(value: number[]);
|
|
185
|
+
constructor(value: number[], name?: string);
|
|
174
186
|
}
|
|
175
187
|
export declare class DdbVectorAny extends DdbObj {
|
|
176
|
-
constructor(value: DdbObj<DdbValue>[]);
|
|
188
|
+
constructor(value: DdbObj<DdbValue>[], name?: string);
|
|
177
189
|
}
|
|
178
190
|
export declare class DdbPair extends DdbObj<Int32Array> {
|
|
179
191
|
constructor(l: number, r?: number);
|
|
@@ -181,8 +193,16 @@ export declare class DdbPair extends DdbObj<Int32Array> {
|
|
|
181
193
|
export declare class DdbFunction extends DdbObj<DdbFunctionDefValue> {
|
|
182
194
|
constructor(name: string, type: DdbFunctionType);
|
|
183
195
|
}
|
|
184
|
-
export declare function date2str(date: number): string;
|
|
196
|
+
export declare function date2str(date: number, format?: string): string;
|
|
197
|
+
export declare function datetime2str(datetime: number, format?: string): string;
|
|
185
198
|
export declare function timestamp2str(timestamp: bigint): string;
|
|
199
|
+
export declare function nanotimestamp2str(nanotimestamp: bigint, format?: string): string;
|
|
200
|
+
/** 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`
|
|
203
|
+
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
204
|
+
*/
|
|
205
|
+
export declare function str2nanotimestamp(str: string, format?: string): bigint;
|
|
186
206
|
export declare class DDB {
|
|
187
207
|
/** 当前的 session id (http 或 tcp) */
|
|
188
208
|
sid: string;
|
package/browser.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ddb = exports.DDB = exports.timestamp2str = exports.date2str = exports.DdbFunction = exports.DdbPair = exports.DdbVectorAny = exports.DdbVectorDouble = exports.DdbVectorString = exports.DdbVectorInt = exports.DdbDouble = exports.DdbLong = exports.DdbString = exports.DdbInt = exports.DdbBool = exports.DdbVoid = exports.DdbObj = exports.timezone_offset = exports.nulls = exports.DdbFunctionType = exports.DdbType = exports.DdbForm = void 0;
|
|
3
|
+
exports.ddb = exports.DDB = exports.str2nanotimestamp = exports.nanotimestamp2str = exports.timestamp2str = exports.datetime2str = exports.date2str = exports.DdbFunction = exports.DdbPair = exports.DdbVectorAny = exports.DdbVectorDouble = exports.DdbVectorString = exports.DdbVectorInt = 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
|
+
const customParseFormat_js_1 = tslib_1.__importDefault(require("dayjs/plugin/customParseFormat.js"));
|
|
7
|
+
dayjs_1.default.extend(customParseFormat_js_1.default);
|
|
6
8
|
require("xshell/prototype.browser");
|
|
7
9
|
const utils_browser_1 = require("xshell/utils.browser");
|
|
8
10
|
var DdbForm;
|
|
@@ -844,7 +846,7 @@ class DdbObj {
|
|
|
844
846
|
}
|
|
845
847
|
to_dict() {
|
|
846
848
|
if (this.form !== DdbForm.dict)
|
|
847
|
-
throw new Error('this.form
|
|
849
|
+
throw new Error('this.form is not DdbForm.dict, cannot convert to Object');
|
|
848
850
|
const [{ value: keys }, { value: values }] = this.value;
|
|
849
851
|
let obj = {};
|
|
850
852
|
for (let i = 0; i < this.rows; i++)
|
|
@@ -880,6 +882,17 @@ class DdbBool extends DdbObj {
|
|
|
880
882
|
}
|
|
881
883
|
}
|
|
882
884
|
exports.DdbBool = DdbBool;
|
|
885
|
+
class DdbChar extends DdbObj {
|
|
886
|
+
constructor(value) {
|
|
887
|
+
super({
|
|
888
|
+
form: DdbForm.scalar,
|
|
889
|
+
type: DdbType.char,
|
|
890
|
+
length: 1,
|
|
891
|
+
value,
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
exports.DdbChar = DdbChar;
|
|
883
896
|
class DdbInt extends DdbObj {
|
|
884
897
|
constructor(value) {
|
|
885
898
|
super({
|
|
@@ -924,8 +937,41 @@ class DdbDouble extends DdbObj {
|
|
|
924
937
|
}
|
|
925
938
|
}
|
|
926
939
|
exports.DdbDouble = DdbDouble;
|
|
927
|
-
class
|
|
940
|
+
class DdbDateTime extends DdbObj {
|
|
941
|
+
constructor(value) {
|
|
942
|
+
super({
|
|
943
|
+
form: DdbForm.scalar,
|
|
944
|
+
type: DdbType.datetime,
|
|
945
|
+
length: 4,
|
|
946
|
+
value
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
exports.DdbDateTime = DdbDateTime;
|
|
951
|
+
class DdbTimeStamp extends DdbObj {
|
|
928
952
|
constructor(value) {
|
|
953
|
+
super({
|
|
954
|
+
form: DdbForm.scalar,
|
|
955
|
+
type: DdbType.timestamp,
|
|
956
|
+
length: 8,
|
|
957
|
+
value
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
exports.DdbTimeStamp = DdbTimeStamp;
|
|
962
|
+
class DdbNanoTimeStamp extends DdbObj {
|
|
963
|
+
constructor(value) {
|
|
964
|
+
super({
|
|
965
|
+
form: DdbForm.scalar,
|
|
966
|
+
type: DdbType.nanotimestamp,
|
|
967
|
+
length: 8,
|
|
968
|
+
value
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
exports.DdbNanoTimeStamp = DdbNanoTimeStamp;
|
|
973
|
+
class DdbVectorInt extends DdbObj {
|
|
974
|
+
constructor(value, name) {
|
|
929
975
|
super({
|
|
930
976
|
form: DdbForm.vector,
|
|
931
977
|
type: DdbType.int,
|
|
@@ -933,45 +979,49 @@ class DdbVectorInt extends DdbObj {
|
|
|
933
979
|
rows: value.length,
|
|
934
980
|
cols: 1,
|
|
935
981
|
value: Int32Array.from(value),
|
|
982
|
+
name,
|
|
936
983
|
});
|
|
937
984
|
}
|
|
938
985
|
}
|
|
939
986
|
exports.DdbVectorInt = DdbVectorInt;
|
|
940
987
|
class DdbVectorString extends DdbObj {
|
|
941
|
-
constructor(value) {
|
|
988
|
+
constructor(value, name) {
|
|
942
989
|
super({
|
|
943
990
|
form: DdbForm.vector,
|
|
944
991
|
type: DdbType.string,
|
|
945
992
|
length: 0,
|
|
946
993
|
rows: value.length,
|
|
947
994
|
cols: 1,
|
|
948
|
-
value
|
|
995
|
+
value,
|
|
996
|
+
name,
|
|
949
997
|
});
|
|
950
998
|
}
|
|
951
999
|
}
|
|
952
1000
|
exports.DdbVectorString = DdbVectorString;
|
|
953
1001
|
class DdbVectorDouble extends DdbObj {
|
|
954
|
-
constructor(value) {
|
|
1002
|
+
constructor(value, name) {
|
|
955
1003
|
super({
|
|
956
1004
|
form: DdbForm.vector,
|
|
957
1005
|
type: DdbType.double,
|
|
958
1006
|
length: 0,
|
|
959
1007
|
rows: value.length,
|
|
960
1008
|
cols: 1,
|
|
961
|
-
value: Float64Array.from(value)
|
|
1009
|
+
value: Float64Array.from(value),
|
|
1010
|
+
name,
|
|
962
1011
|
});
|
|
963
1012
|
}
|
|
964
1013
|
}
|
|
965
1014
|
exports.DdbVectorDouble = DdbVectorDouble;
|
|
966
1015
|
class DdbVectorAny extends DdbObj {
|
|
967
|
-
constructor(value) {
|
|
1016
|
+
constructor(value, name) {
|
|
968
1017
|
super({
|
|
969
1018
|
form: DdbForm.vector,
|
|
970
1019
|
type: DdbType.any,
|
|
971
1020
|
length: 0,
|
|
972
1021
|
rows: value.length,
|
|
973
1022
|
cols: 1,
|
|
974
|
-
value
|
|
1023
|
+
value,
|
|
1024
|
+
name,
|
|
975
1025
|
});
|
|
976
1026
|
}
|
|
977
1027
|
}
|
|
@@ -1000,13 +1050,20 @@ class DdbFunction extends DdbObj {
|
|
|
1000
1050
|
}
|
|
1001
1051
|
}
|
|
1002
1052
|
exports.DdbFunction = DdbFunction;
|
|
1003
|
-
function date2str(date) {
|
|
1053
|
+
function date2str(date, format = 'YYYY.MM.DD') {
|
|
1004
1054
|
return date === exports.nulls.int32 ?
|
|
1005
1055
|
''
|
|
1006
1056
|
:
|
|
1007
|
-
(0, dayjs_1.default)(exports.timezone_offset + 1000 * 3600 * 24 * date).format(
|
|
1057
|
+
(0, dayjs_1.default)(exports.timezone_offset + 1000 * 3600 * 24 * date).format(format);
|
|
1008
1058
|
}
|
|
1009
1059
|
exports.date2str = date2str;
|
|
1060
|
+
function datetime2str(datetime, format = 'YYYY.MM.DD HH:mm:ss') {
|
|
1061
|
+
return datetime === exports.nulls.int32 ?
|
|
1062
|
+
''
|
|
1063
|
+
:
|
|
1064
|
+
(0, dayjs_1.default)(exports.timezone_offset + 1000 * datetime).format(format);
|
|
1065
|
+
}
|
|
1066
|
+
exports.datetime2str = datetime2str;
|
|
1010
1067
|
function timestamp2str(timestamp) {
|
|
1011
1068
|
return timestamp === exports.nulls.int64 ?
|
|
1012
1069
|
''
|
|
@@ -1014,6 +1071,29 @@ function timestamp2str(timestamp) {
|
|
|
1014
1071
|
(0, dayjs_1.default)(exports.timezone_offset + Number(timestamp)).format('YYYY.MM.DD HH:mm:ss.SSS');
|
|
1015
1072
|
}
|
|
1016
1073
|
exports.timestamp2str = timestamp2str;
|
|
1074
|
+
function nanotimestamp2str(nanotimestamp, format = 'YYYY.MM.DD HH:mm:ss') {
|
|
1075
|
+
return nanotimestamp === exports.nulls.int64 ?
|
|
1076
|
+
''
|
|
1077
|
+
:
|
|
1078
|
+
(0, dayjs_1.default)(exports.timezone_offset + (Number(nanotimestamp) / 1000000)).format(format) + `.${nanotimestamp % 1000000000n}`;
|
|
1079
|
+
}
|
|
1080
|
+
exports.nanotimestamp2str = nanotimestamp2str;
|
|
1081
|
+
/** parse nano timestamp string to bigint value
|
|
1082
|
+
- str: nano timestamp string, 如果为空字符串会返回对应的空值 (nulls.int64)
|
|
1083
|
+
- format?: Format string up to and including seconds of the passed string, default is `YYYY.MM.DD HH:mm:ss`
|
|
1084
|
+
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
1085
|
+
*/
|
|
1086
|
+
function str2nanotimestamp(str, format = 'YYYY.MM.DD HH:mm:ss') {
|
|
1087
|
+
if (!str)
|
|
1088
|
+
return exports.nulls.int64;
|
|
1089
|
+
if (str.length - format.length !== 9)
|
|
1090
|
+
throw new Error('nanotimestamp 字符串长度减格式串长度应该等于 9');
|
|
1091
|
+
return (BigInt(-exports.timezone_offset +
|
|
1092
|
+
(0, dayjs_1.default)(str.slice(0, format.length), format).valueOf()) * 1000000n
|
|
1093
|
+
+
|
|
1094
|
+
BigInt(str.slice(format.length)));
|
|
1095
|
+
}
|
|
1096
|
+
exports.str2nanotimestamp = str2nanotimestamp;
|
|
1017
1097
|
class DDB {
|
|
1018
1098
|
/**
|
|
1019
1099
|
Initialize an instance of DolphinDB Client using the WebSocket URL
|