wenay-common 1.0.152 → 1.0.155
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/lib/Common/ByteStream.d.ts +3 -3
- package/lib/Common/ByteStream.js +2 -2
- package/lib/Common/Color.js +7 -8
- package/lib/Common/Listen.d.ts +62 -5
- package/lib/Common/Listen.js +56 -7
- package/lib/Common/Math.js +2 -3
- package/lib/Common/Time.js +22 -22
- package/lib/Common/common.js +36 -37
- package/lib/Common/commonsServer.js +7 -7
- package/lib/Common/funcTimeWait.js +2 -2
- package/lib/Common/inputAutoStep.js +1 -2
- package/lib/Common/node_console.js +4 -5
- package/lib/Common/objectPath.js +4 -5
- package/lib/Common/waitRun.js +2 -3
- package/lib/Exchange/Bars.d.ts +1 -1
- package/lib/Exchange/Bars.js +3 -3
- package/lib/Exchange/CParams.js +9 -9
- package/lib/Exchange/ConnectData/Binance/commonOrder.js +1 -2
- package/lib/Exchange/ConnectData/Binance/marketD.d.ts +23 -34
- package/lib/Exchange/ConnectData/Binance/marketData.d.ts +0 -1
- package/lib/Exchange/ConnectData/Binance/marketData.js +6 -6
- package/lib/Exchange/ConnectData/Binance/order.d.ts +5 -5
- package/lib/Exchange/ConnectData/Binance/signatureCoder.js +1 -2
- package/lib/Exchange/ConnectData/Binance/use.d.ts +8 -8
- package/lib/Exchange/ConnectData/Binance/use.js +1 -2
- package/lib/Exchange/ConnectData/Binance.d.ts +3 -4
- package/lib/Exchange/ConnectData/Binance.js +20 -20
- package/lib/Exchange/ConnectData/test.js +1 -2
- package/lib/Exchange/LoadBase.d.ts +0 -1
- package/lib/Exchange/LoadBase.js +1 -2
- package/lib/client.js +2 -2
- package/lib/index.js +2 -2
- package/lib/test.d.ts +1 -0
- package/lib/test.js +65 -0
- package/package.json +1 -1
|
@@ -58,7 +58,7 @@ declare class ByteStreamR_<throwable extends boolean> {
|
|
|
58
58
|
constructor(data: Readonly<ArrayBuffer | DataView>);
|
|
59
59
|
UpdateFrom(stream: Readonly<ByteStreamW>): void;
|
|
60
60
|
private __readNumber;
|
|
61
|
-
_readNumber(bytes: number, isInteger: boolean, isSigned?: boolean): throwable extends true ? number : number | null;
|
|
61
|
+
_readNumber(bytes: number, isInteger: boolean, isSigned?: boolean): (throwable extends true ? number : number | null);
|
|
62
62
|
noThrow(): ByteStreamR_<false>;
|
|
63
63
|
readInt8(): throwable extends true ? number : number | null;
|
|
64
64
|
readInt16(): throwable extends true ? number : number | null;
|
|
@@ -74,10 +74,10 @@ declare class ByteStreamR_<throwable extends boolean> {
|
|
|
74
74
|
readUint64(): throwable extends true ? number : number | null;
|
|
75
75
|
readFloat(): throwable extends true ? number : number | null;
|
|
76
76
|
readDouble(): throwable extends true ? number : number | null;
|
|
77
|
-
readBool(): throwable extends true ? boolean : boolean | null;
|
|
77
|
+
readBool(): (throwable extends true ? boolean : boolean | null);
|
|
78
78
|
readNumber(type: NumericTypes | Nullable<NumericTypes>): throwable extends true ? number : number | null;
|
|
79
79
|
readDate(): Date;
|
|
80
|
-
toType<T>(value: T): throwable extends true ? T : T | null;
|
|
80
|
+
toType<T>(value: T): (throwable extends true ? T : T | null);
|
|
81
81
|
protected _getReadFuncForNumeric<T extends NumericTypes | Nullable<NumericTypes>>(type: T): (stream: ByteStreamR_<throwable>) => throwable extends true ? number : T extends NumericTypes ? number : number | null;
|
|
82
82
|
readNullable<T>(reader: ReaderFromBytes<NonNullable<T>>): NonNullable<T> | null;
|
|
83
83
|
readArray<T>(func: (stream: ByteStreamR) => NonNullable<T>): T[];
|
package/lib/Common/ByteStream.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ByteStreamR = exports.ByteStreamW = exports.
|
|
3
|
+
exports.ByteStreamR = exports.ByteStreamW = exports.Nullable = void 0;
|
|
4
|
+
exports.nullable = nullable;
|
|
4
5
|
function createCopyOfBuffer(src, length = src.byteLength) {
|
|
5
6
|
let dst = new ArrayBuffer(length);
|
|
6
7
|
new Uint8Array(dst).set(new Uint8Array(src));
|
|
@@ -12,7 +13,6 @@ class Nullable {
|
|
|
12
13
|
}
|
|
13
14
|
exports.Nullable = Nullable;
|
|
14
15
|
function nullable(type) { return new Nullable(type); }
|
|
15
|
-
exports.nullable = nullable;
|
|
16
16
|
function __getNumericTypeInfo(type) {
|
|
17
17
|
switch (type) {
|
|
18
18
|
case "int8": return [1];
|
package/lib/Common/Color.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSimilarColors = exports.toColorString = exports.colorStringToRGBA = exports.colorGeneratorByCount = exports.colorGenerator2 = exports.colorGenerator = exports.rgb = void 0;
|
|
4
|
-
function rgb(red, green, blue) { return `rgb(${red},${green},${blue})`; }
|
|
5
3
|
exports.rgb = rgb;
|
|
4
|
+
exports.colorGenerator = colorGenerator;
|
|
5
|
+
exports.colorGenerator2 = colorGenerator2;
|
|
6
|
+
exports.colorGeneratorByCount = colorGeneratorByCount;
|
|
7
|
+
exports.colorStringToRGBA = colorStringToRGBA;
|
|
8
|
+
exports.toColorString = toColorString;
|
|
9
|
+
exports.isSimilarColors = isSimilarColors;
|
|
10
|
+
function rgb(red, green, blue) { return `rgb(${red},${green},${blue})`; }
|
|
6
11
|
function* colorGenerator(min = 0, max = 254) {
|
|
7
12
|
for (let step = Math.floor((max - min) / 2); step >= 1; step /= 2) {
|
|
8
13
|
let v = (max - min) / step;
|
|
@@ -16,7 +21,6 @@ function* colorGenerator(min = 0, max = 254) {
|
|
|
16
21
|
}
|
|
17
22
|
yield [-1, -1, -1];
|
|
18
23
|
}
|
|
19
|
-
exports.colorGenerator = colorGenerator;
|
|
20
24
|
function* colorGenerator2(data) {
|
|
21
25
|
const max = data?.max ?? 255;
|
|
22
26
|
const min = data?.min ?? 0;
|
|
@@ -62,7 +66,6 @@ function* colorGenerator2(data) {
|
|
|
62
66
|
}
|
|
63
67
|
yield [-1, -1, -1];
|
|
64
68
|
}
|
|
65
|
-
exports.colorGenerator2 = colorGenerator2;
|
|
66
69
|
function colorGeneratorByCount(value = 180, count = 100, index = 1) {
|
|
67
70
|
const step = Math.floor(value * 6 * index / count);
|
|
68
71
|
const p = Math.floor(step / value);
|
|
@@ -72,7 +75,6 @@ function colorGeneratorByCount(value = 180, count = 100, index = 1) {
|
|
|
72
75
|
const b = (p == 3 || p == 4) ? value : (p == 5) ? value - z : (p == 2) ? z : 0;
|
|
73
76
|
return `rgb(${r},${g},${b})`;
|
|
74
77
|
}
|
|
75
|
-
exports.colorGeneratorByCount = colorGeneratorByCount;
|
|
76
78
|
function colorStringToRGBA(str) {
|
|
77
79
|
let arr = str.match(/^rgb?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
|
|
78
80
|
if (!arr || arr[1] == null)
|
|
@@ -84,14 +86,11 @@ function colorStringToRGBA(str) {
|
|
|
84
86
|
a ??= 1;
|
|
85
87
|
return [r, g, b, a];
|
|
86
88
|
}
|
|
87
|
-
exports.colorStringToRGBA = colorStringToRGBA;
|
|
88
89
|
function toColorString(str) { if (colorStringToRGBA(str))
|
|
89
90
|
return str; throw `the string '${str}' is not valid 'rgb' or 'rgba' string`; }
|
|
90
|
-
exports.toColorString = toColorString;
|
|
91
91
|
function isSimilarColors(color1, color2, maxDelta = 32) {
|
|
92
92
|
let [r1, g1, b1] = typeof color1 == "string" ? colorStringToRGBA(color1) : color1;
|
|
93
93
|
let [r2, g2, b2] = typeof color2 == "string" ? colorStringToRGBA(color2) : color2;
|
|
94
94
|
let delta = Math.max(r1 - r2) + Math.max(g1 - g2) + Math.max(b1 - b2);
|
|
95
95
|
return delta <= maxDelta;
|
|
96
96
|
}
|
|
97
|
-
exports.isSimilarColors = isSimilarColors;
|
package/lib/Common/Listen.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare function funcListenCallback<T extends any[]>(a: (e: tr222<T>) =>
|
|
|
5
5
|
isRun: () => boolean;
|
|
6
6
|
run: () => (() => void) | null;
|
|
7
7
|
close: () => void;
|
|
8
|
-
addListen: (a: tr222<T>) => void;
|
|
8
|
+
addListen: (a: tr222<T>) => () => void;
|
|
9
9
|
removeListen: (a: (tr222<T>) | null) => void;
|
|
10
10
|
count: () => number;
|
|
11
11
|
};
|
|
@@ -25,7 +25,7 @@ export declare function funcListenBySocket2<Z extends any[] = any[]>(e: t1<Z>, {
|
|
|
25
25
|
readonly stop?: (x: tt) => any;
|
|
26
26
|
readonly paramsModify?: (...e: Parameters<tt>) => any[];
|
|
27
27
|
}): {
|
|
28
|
-
callback: (z: (a: Z[0]) => void) => void;
|
|
28
|
+
callback: (z: (...params: Parameters<(a: Z[0]) => void>) => void) => void;
|
|
29
29
|
removeCallback: () => boolean;
|
|
30
30
|
};
|
|
31
31
|
export declare function funcListenBySocket<Z extends any[] = any[]>(e: ReturnType<typeof funcListenCallback<Z>>, status: () => boolean): {
|
|
@@ -41,13 +41,32 @@ export declare function UseListen<T extends any[]>(data?: {
|
|
|
41
41
|
isRun: () => boolean;
|
|
42
42
|
run: () => (() => void) | null;
|
|
43
43
|
close: () => void;
|
|
44
|
-
addListen: (a: tr222<T>) => void;
|
|
44
|
+
addListen: (a: tr222<T>) => () => void;
|
|
45
45
|
removeListen: (a: tr222<T> | null) => void;
|
|
46
46
|
count: () => number;
|
|
47
47
|
}];
|
|
48
|
+
type tDeepKeys<T, T2 extends object, T3 extends any> = {
|
|
49
|
+
[K in keyof T]: T[K] extends T2 ? T3 : T[K] extends object ? tDeepKeys<T[K], T2, T3> : T[K];
|
|
50
|
+
};
|
|
51
|
+
type obj = {
|
|
52
|
+
[k: string]: any;
|
|
53
|
+
};
|
|
54
|
+
export declare function CompareKeys<T extends obj, T2 extends obj>(obj1: T, obj2: T2): boolean;
|
|
55
|
+
export declare function DeepCompareKeys<T, T2 extends obj, T4, T3 extends (a: T2) => any>(obj1: T, obj2: T2, func: (a: T2) => T4): any;
|
|
56
|
+
export declare function deepModifyByListen<T>(obj: T, status: () => boolean): tDeepKeys<T, {
|
|
57
|
+
lastUpdate: () => Date | null;
|
|
58
|
+
lastUpdateMs: () => number | null;
|
|
59
|
+
isRun: () => boolean;
|
|
60
|
+
run: () => (() => void) | null;
|
|
61
|
+
close: () => void;
|
|
62
|
+
addListen: (a: tr222<any[]>) => () => void;
|
|
63
|
+
removeListen: (a: tr222<any[]> | null) => void;
|
|
64
|
+
count: () => number;
|
|
65
|
+
}, ReturnType<typeof funcListenBySocket1>>;
|
|
66
|
+
export declare const funcListenBySocketObj: typeof deepModifyByListen;
|
|
48
67
|
export declare function PromiseArrayListen<T extends any = unknown>(array: ((() => Promise<T>) | (() => any) | Promise<T>)[]): {
|
|
49
|
-
listenOk: (a: (data: T, i: number, countOk: number, countError: number, count: number) => any) => () => void;
|
|
50
|
-
listenError: (a: (error: any, i: number, countOk: number, countError: number, count: number) => any) => () => void;
|
|
68
|
+
listenOk: (a: (...d: [data: T, i: number, countOk: number, countError: number, count: number]) => any) => () => void;
|
|
69
|
+
listenError: (a: (...d: [error: any, i: number, countOk: number, countError: number, count: number]) => any) => () => void;
|
|
51
70
|
promise: {
|
|
52
71
|
all: () => Promise<((() => Promise<T>) | Awaited<T>)[]>;
|
|
53
72
|
allSettled: () => Promise<PromiseSettledResult<(() => Promise<T>) | Awaited<T>>[]>;
|
|
@@ -59,4 +78,42 @@ export declare function PromiseArrayListen<T extends any = unknown>(array: ((()
|
|
|
59
78
|
count: number;
|
|
60
79
|
};
|
|
61
80
|
};
|
|
81
|
+
export type realSocket2<T extends any> = (data: {
|
|
82
|
+
callback: (data: T) => void;
|
|
83
|
+
[key: string]: any;
|
|
84
|
+
}, ...b: any[]) => (any | (() => any));
|
|
85
|
+
export type getTypeCallback<T extends realSocket2<any>> = T extends realSocket2<infer R> ? R : never;
|
|
86
|
+
type ParametersOther<T extends (forget: any, ...args: any) => any> = T extends (forget: any, ...args: infer P) => any ? P : never;
|
|
87
|
+
type tr22<T> = T extends undefined ? never : T;
|
|
88
|
+
export declare function socketBuffer3<T extends realSocket2<any | any[]>, T2 extends (readonly unknown[]) | undefined, T3 extends {
|
|
89
|
+
[key: string]: unknown;
|
|
90
|
+
}>(func: T, callbackMain: (data: getTypeCallback<T>, memo: T3) => T2, memo?: T3): (a: Omit<Parameters<T>[0], "callback"> & {
|
|
91
|
+
callback: (...data: tr22<T2>) => any;
|
|
92
|
+
}, ...b: ParametersOther<T>) => ReturnType<T>;
|
|
93
|
+
export declare function socketBufferBySnapshot<T extends realSocket2<any | any[]>, T2 extends (readonly unknown[]) | undefined, T3 extends {
|
|
94
|
+
[key: string]: unknown;
|
|
95
|
+
}>({ func, memo, callbackSave, snapshot }: {
|
|
96
|
+
func: () => T;
|
|
97
|
+
callbackSave: (data: getTypeCallback<T>, memo: T3) => T2;
|
|
98
|
+
memo: T3;
|
|
99
|
+
snapshot?: (memo: T3) => T3;
|
|
100
|
+
}): {
|
|
101
|
+
run: (a: tr222<[data: getTypeCallback<T>, memo: T3]>) => () => void;
|
|
102
|
+
snapshot: () => T3 | undefined;
|
|
103
|
+
memo: T3;
|
|
104
|
+
listenA: {
|
|
105
|
+
lastUpdate: () => Date | null;
|
|
106
|
+
lastUpdateMs: () => number | null;
|
|
107
|
+
isRun: () => boolean;
|
|
108
|
+
run: () => (() => void) | null;
|
|
109
|
+
close: () => void;
|
|
110
|
+
addListen: (a: tr222<[data: getTypeCallback<T>, memo: T3]>) => () => void;
|
|
111
|
+
removeListen: (a: tr222<[data: getTypeCallback<T>, memo: T3]> | null) => void;
|
|
112
|
+
count: () => number;
|
|
113
|
+
};
|
|
114
|
+
connect: () => void;
|
|
115
|
+
readonly disconnect: ((a: Omit<Parameters<T>[0], "callback"> & {
|
|
116
|
+
callback: (...data: tr22<T2>) => any;
|
|
117
|
+
}, ...b: ParametersOther<T>) => ReturnType<T>) | null;
|
|
118
|
+
};
|
|
62
119
|
export {};
|
package/lib/Common/Listen.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.funcListenBySocketObj = exports.funcListenBySocket1 = void 0;
|
|
4
|
+
exports.funcListenCallback = funcListenCallback;
|
|
5
|
+
exports.funcListenBySocket3 = funcListenBySocket3;
|
|
6
|
+
exports.funcListenBySocket2 = funcListenBySocket2;
|
|
7
|
+
exports.funcListenBySocket = funcListenBySocket;
|
|
8
|
+
exports.UseListen = UseListen;
|
|
9
|
+
exports.CompareKeys = CompareKeys;
|
|
10
|
+
exports.DeepCompareKeys = DeepCompareKeys;
|
|
11
|
+
exports.deepModifyByListen = deepModifyByListen;
|
|
12
|
+
exports.PromiseArrayListen = PromiseArrayListen;
|
|
13
|
+
exports.socketBuffer3 = socketBuffer3;
|
|
14
|
+
exports.socketBufferBySnapshot = socketBufferBySnapshot;
|
|
4
15
|
function funcListenCallback(a, event) {
|
|
5
16
|
const obj = new Map;
|
|
6
17
|
let close = null;
|
|
@@ -18,6 +29,7 @@ function funcListenCallback(a, event) {
|
|
|
18
29
|
addListen: (a) => {
|
|
19
30
|
obj.set(a, a);
|
|
20
31
|
event?.("add", obj.size, api);
|
|
32
|
+
return () => api.removeListen(a);
|
|
21
33
|
},
|
|
22
34
|
removeListen: (a) => {
|
|
23
35
|
obj.delete(a);
|
|
@@ -27,11 +39,9 @@ function funcListenCallback(a, event) {
|
|
|
27
39
|
};
|
|
28
40
|
return api;
|
|
29
41
|
}
|
|
30
|
-
exports.funcListenCallback = funcListenCallback;
|
|
31
42
|
function funcListenBySocket3(e, z) {
|
|
32
43
|
return funcListenBySocket2(e, { ...z, stop: x => x("___STOP"), paramsModify: (...e) => [e[0]] });
|
|
33
44
|
}
|
|
34
|
-
exports.funcListenBySocket3 = funcListenBySocket3;
|
|
35
45
|
function funcListenBySocket2(e, { stop, setEventClose, status, paramsModify }) {
|
|
36
46
|
const { addListen, removeListen, count } = e;
|
|
37
47
|
const x = { x: null };
|
|
@@ -75,7 +85,6 @@ function funcListenBySocket2(e, { stop, setEventClose, status, paramsModify }) {
|
|
|
75
85
|
removeCallback
|
|
76
86
|
};
|
|
77
87
|
}
|
|
78
|
-
exports.funcListenBySocket2 = funcListenBySocket2;
|
|
79
88
|
function funcListenBySocket(e, status) {
|
|
80
89
|
const { addListen, removeListen, count } = e;
|
|
81
90
|
let x = null;
|
|
@@ -106,7 +115,6 @@ function funcListenBySocket(e, status) {
|
|
|
106
115
|
}
|
|
107
116
|
};
|
|
108
117
|
}
|
|
109
|
-
exports.funcListenBySocket = funcListenBySocket;
|
|
110
118
|
exports.funcListenBySocket1 = funcListenBySocket;
|
|
111
119
|
function UseListen(data) {
|
|
112
120
|
let t = null;
|
|
@@ -114,7 +122,19 @@ function UseListen(data) {
|
|
|
114
122
|
a.run();
|
|
115
123
|
return [(...e) => t?.(...e), a];
|
|
116
124
|
}
|
|
117
|
-
|
|
125
|
+
function CompareKeys(obj1, obj2) {
|
|
126
|
+
return (new Set([...Object.keys(obj1), ...Object.keys(obj2)])).size == Object.keys(obj2).length;
|
|
127
|
+
}
|
|
128
|
+
function DeepCompareKeys(obj1, obj2, func) {
|
|
129
|
+
return (Object.fromEntries(Object.entries(obj1).map(([k, v]) => {
|
|
130
|
+
return v instanceof Object ? CompareKeys(v, obj2) ? [k, func(v)] : [k, DeepCompareKeys(v, obj2, func)] : [k, v];
|
|
131
|
+
})));
|
|
132
|
+
}
|
|
133
|
+
function deepModifyByListen(obj, status) {
|
|
134
|
+
const l = UseListen()[1];
|
|
135
|
+
return DeepCompareKeys(obj, l, e => (0, exports.funcListenBySocket1)(e, status));
|
|
136
|
+
}
|
|
137
|
+
exports.funcListenBySocketObj = deepModifyByListen;
|
|
118
138
|
function PromiseArrayListen(array) {
|
|
119
139
|
let ok = 0, error = 0;
|
|
120
140
|
const count = array.length;
|
|
@@ -150,4 +170,33 @@ function PromiseArrayListen(array) {
|
|
|
150
170
|
}
|
|
151
171
|
};
|
|
152
172
|
}
|
|
153
|
-
|
|
173
|
+
function socketBuffer3(func, callbackMain, memo = {}) {
|
|
174
|
+
return (a, ...b) => func({ ...a, callback: (v) => { const z = callbackMain(v, memo); if (z)
|
|
175
|
+
a.callback(...z); }
|
|
176
|
+
}, ...b);
|
|
177
|
+
}
|
|
178
|
+
function socketBufferBySnapshot({ func, memo = {}, callbackSave, snapshot }) {
|
|
179
|
+
let d = null;
|
|
180
|
+
const [callback, listenA] = UseListen({
|
|
181
|
+
event: (type, count, api) => {
|
|
182
|
+
if (type == "remove" && count == 0) {
|
|
183
|
+
api.close();
|
|
184
|
+
d?.();
|
|
185
|
+
}
|
|
186
|
+
if (type == "add" && count == 1)
|
|
187
|
+
api.run();
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
const connect = () => {
|
|
191
|
+
if (d == null)
|
|
192
|
+
d = socketBuffer3(func(), callbackSave, memo)({ callback });
|
|
193
|
+
};
|
|
194
|
+
const run = (...params) => {
|
|
195
|
+
if (!listenA.isRun()) {
|
|
196
|
+
snapshot?.(memo);
|
|
197
|
+
connect();
|
|
198
|
+
}
|
|
199
|
+
return listenA.addListen(...params);
|
|
200
|
+
};
|
|
201
|
+
return { run, snapshot: () => snapshot?.(memo), memo, listenA, connect, get disconnect() { return d; } };
|
|
202
|
+
}
|
package/lib/Common/Math.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CorrelationRollingByBuffer = CorrelationRollingByBuffer;
|
|
4
|
+
exports.CorrelationFunc = CorrelationFunc;
|
|
4
5
|
function CorrelationRollingByBuffer(data) {
|
|
5
6
|
let setting = { ...data };
|
|
6
7
|
const map = new Map();
|
|
@@ -19,7 +20,6 @@ function CorrelationRollingByBuffer(data) {
|
|
|
19
20
|
}
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
|
-
exports.CorrelationRollingByBuffer = CorrelationRollingByBuffer;
|
|
23
23
|
function CorrelationFunc(d1, d2, setting) {
|
|
24
24
|
const { min, pow, sqrt } = Math;
|
|
25
25
|
const { isNaN } = Number;
|
|
@@ -67,4 +67,3 @@ function CorrelationFunc(d1, d2, setting) {
|
|
|
67
67
|
const result = (mulSum - (sum1 * sum2 / c)) / dense;
|
|
68
68
|
return { corr: result, buffer: buf };
|
|
69
69
|
}
|
|
70
|
-
exports.CorrelationFunc = CorrelationFunc;
|
package/lib/Common/Time.js
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CDelayer = exports.Period = exports.PeriodSpan = exports.TF = exports.TIME_UNIT = exports.M1_MS = exports.H1_MS = exports.D1_MS = exports.W1_MS = exports.W1_S = exports.D1_S = exports.H1_S = void 0;
|
|
4
|
+
exports.timeToStr_hhmmss_ms = timeToStr_hhmmss_ms;
|
|
5
|
+
exports.timeToStr_hhmmss = timeToStr_hhmmss;
|
|
6
|
+
exports.timeToStr_yyyymmdd_hhmm = timeToStr_yyyymmdd_hhmm;
|
|
7
|
+
exports.timeToStr_yyyymmdd_hhmmss = timeToStr_yyyymmdd_hhmmss;
|
|
8
|
+
exports.timeToStr_yyyymmdd_hhmmss_ms = timeToStr_yyyymmdd_hhmmss_ms;
|
|
9
|
+
exports.timeLocalToStr_hhmmss = timeLocalToStr_hhmmss;
|
|
10
|
+
exports.timeLocalToStr_hhmmss_ms = timeLocalToStr_hhmmss_ms;
|
|
11
|
+
exports.timeLocalToStr_yyyymmdd = timeLocalToStr_yyyymmdd;
|
|
12
|
+
exports.timeLocalToStr_yyyymmdd_hhmm = timeLocalToStr_yyyymmdd_hhmm;
|
|
13
|
+
exports.timeLocalToStr_yyyymmdd_hhmmss = timeLocalToStr_yyyymmdd_hhmmss;
|
|
14
|
+
exports.timeLocalToStr_yyyymmdd_hhmmss_ms = timeLocalToStr_yyyymmdd_hhmmss_ms;
|
|
15
|
+
exports.timeToString_yyyymmdd_hhmm_offset = timeToString_yyyymmdd_hhmm_offset;
|
|
16
|
+
exports.timeToString_yyyymmdd_hhmmss_offset = timeToString_yyyymmdd_hhmmss_offset;
|
|
17
|
+
exports.convertDatesToStrings = convertDatesToStrings;
|
|
18
|
+
exports.toPrintObject = toPrintObject;
|
|
19
|
+
exports.durationToStr = durationToStr;
|
|
20
|
+
exports.durationToStrNullable = durationToStrNullable;
|
|
21
|
+
exports.durationToStr_h_mm_ss = durationToStr_h_mm_ss;
|
|
22
|
+
exports.durationToStr_h_mm_ss_ms = durationToStr_h_mm_ss_ms;
|
|
23
|
+
exports.MinTime = MinTime;
|
|
24
|
+
exports.MaxTime = MaxTime;
|
|
4
25
|
const common_1 = require("./common");
|
|
5
26
|
function GetEnumKeys(T) { return Object.keys(T).filter(k => isNaN(k)); }
|
|
6
27
|
{
|
|
@@ -260,31 +281,18 @@ exports.Period = Period;
|
|
|
260
281
|
function str2(n) { return n <= 9 ? '0' + n : '' + n; }
|
|
261
282
|
function str3(n) { return (n <= 9 ? '00' : n <= 99 ? '0' : '') + n; }
|
|
262
283
|
function timeToStr_hhmmss_ms(date) { return str2(date.getUTCHours()) + ":" + str2(date.getUTCMinutes()) + ":" + str2(date.getUTCSeconds()) + "." + str3(date.getUTCMilliseconds()); }
|
|
263
|
-
exports.timeToStr_hhmmss_ms = timeToStr_hhmmss_ms;
|
|
264
284
|
function timeToStr_hhmmss(date) { return str2(date.getUTCHours()) + ":" + str2(date.getUTCMinutes()) + ":" + str2(date.getUTCSeconds()); }
|
|
265
|
-
exports.timeToStr_hhmmss = timeToStr_hhmmss;
|
|
266
285
|
function timeToStr_yyyymmdd_hhmm(date, dateDelim = "-") { return date.getUTCFullYear() + dateDelim + str2(date.getUTCMonth() + 1) + dateDelim + str2(date.getUTCDate()) + " " + str2(date.getUTCHours()) + ":" + str2(date.getUTCMinutes()); }
|
|
267
|
-
exports.timeToStr_yyyymmdd_hhmm = timeToStr_yyyymmdd_hhmm;
|
|
268
286
|
function timeToStr_yyyymmdd_hhmmss(date, dateDelim = "-") { return timeToStr_yyyymmdd_hhmm(date, dateDelim) + ":" + str2(date.getUTCSeconds()); }
|
|
269
|
-
exports.timeToStr_yyyymmdd_hhmmss = timeToStr_yyyymmdd_hhmmss;
|
|
270
287
|
function timeToStr_yyyymmdd_hhmmss_ms(date, dateDelim = "-") { return timeToStr_yyyymmdd_hhmmss(date, dateDelim) + "." + str3(date.getUTCMilliseconds()); }
|
|
271
|
-
exports.timeToStr_yyyymmdd_hhmmss_ms = timeToStr_yyyymmdd_hhmmss_ms;
|
|
272
288
|
function timeLocalToStr_hhmmss(date) { return str2(date.getHours()) + ":" + str2(date.getMinutes()) + ":" + str2(date.getSeconds()); }
|
|
273
|
-
exports.timeLocalToStr_hhmmss = timeLocalToStr_hhmmss;
|
|
274
289
|
function timeLocalToStr_hhmmss_ms(date) { return timeLocalToStr_hhmmss(date) + str3(date.getMilliseconds()); }
|
|
275
|
-
exports.timeLocalToStr_hhmmss_ms = timeLocalToStr_hhmmss_ms;
|
|
276
290
|
function timeLocalToStr_yyyymmdd(date, dateDelim = "-") { return date.getFullYear() + dateDelim + str2(date.getMonth() + 1) + dateDelim + str2(date.getDate()); }
|
|
277
|
-
exports.timeLocalToStr_yyyymmdd = timeLocalToStr_yyyymmdd;
|
|
278
291
|
function timeLocalToStr_yyyymmdd_hhmm(date, dateDelim = "-") { return timeLocalToStr_yyyymmdd(date, dateDelim) + " " + str2(date.getHours()) + ":" + str2(date.getMinutes()); }
|
|
279
|
-
exports.timeLocalToStr_yyyymmdd_hhmm = timeLocalToStr_yyyymmdd_hhmm;
|
|
280
292
|
function timeLocalToStr_yyyymmdd_hhmmss(date, dateDelim = "-") { return timeLocalToStr_yyyymmdd_hhmm(date, dateDelim) + ":" + str2(date.getSeconds()); }
|
|
281
|
-
exports.timeLocalToStr_yyyymmdd_hhmmss = timeLocalToStr_yyyymmdd_hhmmss;
|
|
282
293
|
function timeLocalToStr_yyyymmdd_hhmmss_ms(date, dateDelim = "-") { return timeLocalToStr_yyyymmdd_hhmmss(date, dateDelim) + "." + str3(date.getMilliseconds()); }
|
|
283
|
-
exports.timeLocalToStr_yyyymmdd_hhmmss_ms = timeLocalToStr_yyyymmdd_hhmmss_ms;
|
|
284
294
|
function timeToString_yyyymmdd_hhmm_offset(date) { let offset = date.getTimezoneOffset(); return timeLocalToStr_yyyymmdd_hhmm(date) + " GMT" + (offset < 0 ? '+' : '') + (-offset / 60); }
|
|
285
|
-
exports.timeToString_yyyymmdd_hhmm_offset = timeToString_yyyymmdd_hhmm_offset;
|
|
286
295
|
function timeToString_yyyymmdd_hhmmss_offset(date) { let offset = date.getTimezoneOffset(); return timeLocalToStr_yyyymmdd_hhmmss(date) + " GMT" + (offset < 0 ? '+' : '') + (-offset / 60); }
|
|
287
|
-
exports.timeToString_yyyymmdd_hhmmss_offset = timeToString_yyyymmdd_hhmmss_offset;
|
|
288
296
|
Date.prototype.toString = function () { return timeToString_yyyymmdd_hhmmss_offset(this); };
|
|
289
297
|
Date.prototype.toDateString = function () { return timeLocalToStr_yyyymmdd(this); };
|
|
290
298
|
Date.prototype.toTimeString = function () { let offset = this.getTimezoneOffset(); return timeLocalToStr_hhmmss(this) + " GMT" + (offset < 0 ? '+' : '') + (-offset / 60); };
|
|
@@ -311,9 +319,7 @@ function _getStructCopyWithTimeStrings(arg, objectsMap) {
|
|
|
311
319
|
return clone;
|
|
312
320
|
}
|
|
313
321
|
function convertDatesToStrings(arg) { return _getStructCopyWithTimeStrings(arg); }
|
|
314
|
-
exports.convertDatesToStrings = convertDatesToStrings;
|
|
315
322
|
function toPrintObject(arg) { return convertDatesToStrings(arg); }
|
|
316
|
-
exports.toPrintObject = toPrintObject;
|
|
317
323
|
function replaceConsoleCommands() {
|
|
318
324
|
const consoleLog = console.log;
|
|
319
325
|
const consoleWarn = console.warn;
|
|
@@ -346,16 +352,12 @@ function durationToStr(duration_ms) {
|
|
|
346
352
|
}
|
|
347
353
|
return str;
|
|
348
354
|
}
|
|
349
|
-
exports.durationToStr = durationToStr;
|
|
350
355
|
function durationToStrNullable(duration_ms) { return duration_ms == null ? null : durationToStr(duration_ms); }
|
|
351
|
-
exports.durationToStrNullable = durationToStrNullable;
|
|
352
356
|
function durationToStr_h_mm_ss(duration_ms) {
|
|
353
357
|
let time = new Date(duration_ms);
|
|
354
358
|
return Math.trunc(duration_ms / exports.H1_MS) + ":" + str2(time.getUTCMinutes()) + ":" + str2(time.getUTCSeconds());
|
|
355
359
|
}
|
|
356
|
-
exports.durationToStr_h_mm_ss = durationToStr_h_mm_ss;
|
|
357
360
|
function durationToStr_h_mm_ss_ms(duration_ms) { return durationToStr_h_mm_ss(duration_ms) + "." + str3(Math.trunc(duration_ms % 1000)); }
|
|
358
|
-
exports.durationToStr_h_mm_ss_ms = durationToStr_h_mm_ss_ms;
|
|
359
361
|
async function sleepAsync(msec) {
|
|
360
362
|
return new Promise((resolve, reject) => { setTimeout(resolve, msec); });
|
|
361
363
|
}
|
|
@@ -386,8 +388,6 @@ exports.CDelayer = CDelayer;
|
|
|
386
388
|
function MinTime(time1, time2) {
|
|
387
389
|
return time1 && time2 && time1.valueOf() <= time2.valueOf() ? time1 : time2 ?? time1;
|
|
388
390
|
}
|
|
389
|
-
exports.MinTime = MinTime;
|
|
390
391
|
function MaxTime(time1, time2) {
|
|
391
392
|
return time1 && time2 && time1.valueOf() >= time2.valueOf() ? time1 : time2 ?? time1;
|
|
392
393
|
}
|
|
393
|
-
exports.MaxTime = MaxTime;
|