wenay-common 1.0.163 → 1.0.166
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/Listen.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
type tr222<T extends any[]> = (...r: T) => void;
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function funcListenCallbackBase<T extends any[]>(a: (e: (tr222<T> | null)) => (void | (() => void)), option?: {
|
|
3
|
+
event?: (type: "add" | "remove", count: number, api: ReturnType<typeof funcListenCallbackBase<T>>) => void;
|
|
4
|
+
fast: boolean;
|
|
5
|
+
}): {
|
|
3
6
|
isRun: () => boolean;
|
|
4
7
|
run: () => (() => void) | null;
|
|
5
8
|
close: () => void;
|
|
@@ -7,6 +10,22 @@ export declare function funcListenCallback<T extends any[]>(a: (e: (tr222<T> | n
|
|
|
7
10
|
removeListen: (a: (tr222<T>) | null) => void;
|
|
8
11
|
count: () => number;
|
|
9
12
|
};
|
|
13
|
+
export declare function funcListenCallbackFast<T extends any[]>(a: (e: (tr222<T> | null)) => (void | (() => void))): {
|
|
14
|
+
isRun: () => boolean;
|
|
15
|
+
run: () => (() => void) | null;
|
|
16
|
+
close: () => void;
|
|
17
|
+
addListen: (a: tr222<T>) => () => void;
|
|
18
|
+
removeListen: (a: tr222<T> | null) => void;
|
|
19
|
+
count: () => number;
|
|
20
|
+
};
|
|
21
|
+
export declare function funcListenCallback<T extends any[]>(a: (e: (tr222<T> | null)) => (void | (() => void)), event?: (type: "add" | "remove", count: number, api: ReturnType<typeof funcListenCallbackBase<T>>) => void, fast?: boolean): {
|
|
22
|
+
isRun: () => boolean;
|
|
23
|
+
run: () => (() => void) | null;
|
|
24
|
+
close: () => void;
|
|
25
|
+
addListen: (a: tr222<T>) => () => void;
|
|
26
|
+
removeListen: (a: tr222<T> | null) => void;
|
|
27
|
+
count: () => number;
|
|
28
|
+
};
|
|
10
29
|
type tr2<T extends (...a: any[]) => any> = (a: Parameters<T>[0]) => void;
|
|
11
30
|
type t1<T extends any[] = any[]> = ReturnType<typeof funcListenCallback<T>>;
|
|
12
31
|
type tt = tr2<Parameters<t1["addListen"]>[0]>;
|
|
@@ -33,6 +52,7 @@ export declare function funcListenBySocket<Z extends any[] = any[]>(e: ReturnTyp
|
|
|
33
52
|
export declare const funcListenBySocket1: typeof funcListenBySocket;
|
|
34
53
|
export declare function UseListen<T extends any[]>(data?: {
|
|
35
54
|
event?: Parameters<typeof funcListenCallback<T>>[1];
|
|
55
|
+
fast?: boolean;
|
|
36
56
|
}): readonly [(...e: T) => void | undefined, {
|
|
37
57
|
isRun: () => boolean;
|
|
38
58
|
run: () => (() => void) | null;
|
package/lib/Common/Listen.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.funcListenBySocketObj = exports.funcListenBySocket1 = void 0;
|
|
4
|
+
exports.funcListenCallbackBase = funcListenCallbackBase;
|
|
5
|
+
exports.funcListenCallbackFast = funcListenCallbackFast;
|
|
4
6
|
exports.funcListenCallback = funcListenCallback;
|
|
5
7
|
exports.funcListenBySocket3 = funcListenBySocket3;
|
|
6
8
|
exports.funcListenBySocket2 = funcListenBySocket2;
|
|
@@ -13,13 +15,12 @@ exports.deepModifyByListenSocket2 = deepModifyByListenSocket2;
|
|
|
13
15
|
exports.PromiseArrayListen = PromiseArrayListen;
|
|
14
16
|
exports.socketBuffer3 = socketBuffer3;
|
|
15
17
|
exports.funcListenCallbackSnapshot = funcListenCallbackSnapshot;
|
|
16
|
-
function
|
|
18
|
+
function funcListenCallbackBase(a, option) {
|
|
19
|
+
const { fast = false, event } = option ?? {};
|
|
17
20
|
const obj = new Map;
|
|
18
21
|
let close = null;
|
|
19
22
|
let lastSize = 0;
|
|
20
23
|
const checkFast = () => {
|
|
21
|
-
if (!fast)
|
|
22
|
-
return;
|
|
23
24
|
const size = obj.size;
|
|
24
25
|
if (lastSize > 2 && size > 2)
|
|
25
26
|
return;
|
|
@@ -48,19 +49,27 @@ function funcListenCallback(a, event, fast = true) {
|
|
|
48
49
|
},
|
|
49
50
|
addListen: (a) => {
|
|
50
51
|
obj.set(a, a);
|
|
51
|
-
|
|
52
|
+
if (fast)
|
|
53
|
+
checkFast();
|
|
52
54
|
event?.("add", obj.size, api);
|
|
53
55
|
return () => api.removeListen(a);
|
|
54
56
|
},
|
|
55
57
|
removeListen: (a) => {
|
|
56
58
|
obj.delete(a);
|
|
57
|
-
|
|
59
|
+
if (fast)
|
|
60
|
+
checkFast();
|
|
58
61
|
event?.("remove", obj.size, api);
|
|
59
62
|
},
|
|
60
63
|
count: () => obj.size
|
|
61
64
|
};
|
|
62
65
|
return api;
|
|
63
66
|
}
|
|
67
|
+
function funcListenCallbackFast(a) {
|
|
68
|
+
return funcListenCallbackBase(a, { fast: true });
|
|
69
|
+
}
|
|
70
|
+
function funcListenCallback(a, event, fast = true) {
|
|
71
|
+
return funcListenCallbackBase(a, { event, fast });
|
|
72
|
+
}
|
|
64
73
|
function funcListenBySocket3(e, z) {
|
|
65
74
|
return funcListenBySocket2(e, { ...z, stop: x => x("___STOP"), paramsModify: (...e) => [e[0]] });
|
|
66
75
|
}
|
|
@@ -140,7 +149,7 @@ function funcListenBySocket(e, status) {
|
|
|
140
149
|
exports.funcListenBySocket1 = funcListenBySocket;
|
|
141
150
|
function UseListen(data) {
|
|
142
151
|
let t = null;
|
|
143
|
-
const a =
|
|
152
|
+
const a = funcListenCallbackBase((e) => { t = e; }, { fast: true, ...data });
|
|
144
153
|
a.run();
|
|
145
154
|
return [(...e) => t?.(...e), a];
|
|
146
155
|
}
|
|
@@ -7,7 +7,10 @@ export type tRequestScreenerT<T> = {
|
|
|
7
7
|
callbacksId?: string[];
|
|
8
8
|
request: any[];
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type tt = {
|
|
11
|
+
[k: string]: any;
|
|
12
|
+
};
|
|
13
|
+
export declare function funcPromiseServer<T extends tt>(data: screenerSoc<tSocketData<tRequestScreenerT<T>>>, obj: T): void;
|
|
11
14
|
export declare function funcPromiseServer2<T extends object>(sendMessage: screenerSoc222<tSocketData<tRequestScreenerT<T>>>, obj: T): (datum: any) => Promise<void>;
|
|
12
15
|
type tSocketData<T> = ({
|
|
13
16
|
data: T;
|
|
@@ -28,12 +28,7 @@ function funcPromiseServer(data, obj) {
|
|
|
28
28
|
console.error({ error: e, key: key, arguments: request });
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
if (nameF == "call") {
|
|
32
|
-
console.log(key, nameF);
|
|
33
|
-
}
|
|
34
31
|
const buf = buf2;
|
|
35
|
-
if (!buf[nameF])
|
|
36
|
-
return;
|
|
37
32
|
if (typeof buf[nameF] == "function") {
|
|
38
33
|
const { callbacksId } = datum;
|
|
39
34
|
if (callbacksId) {
|
|
@@ -49,13 +44,12 @@ function funcPromiseServer(data, obj) {
|
|
|
49
44
|
});
|
|
50
45
|
let r = 0;
|
|
51
46
|
request.forEach((e, i) => {
|
|
52
|
-
if (e == "___FUNC")
|
|
47
|
+
if (e == "___FUNC")
|
|
53
48
|
request[i] = arr[r++];
|
|
54
|
-
}
|
|
55
49
|
});
|
|
56
50
|
}
|
|
57
51
|
const trt = async () => buf[nameF](...request);
|
|
58
|
-
|
|
52
|
+
await trt()
|
|
59
53
|
.then(a => {
|
|
60
54
|
if (datum.wait !== false)
|
|
61
55
|
data.sendMessage({ mapId: datum.mapId, data: a ?? undefined });
|
|
@@ -2,20 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FuncTimeWait = void 0;
|
|
4
4
|
exports.funcTimeW = funcTimeW;
|
|
5
|
-
const map = {
|
|
6
|
-
binanceSpot: binanceSpotHistory2(),
|
|
7
|
-
binanceFutures: binanceSpotHistory3()
|
|
8
|
-
};
|
|
9
|
-
function binanceSpotHistory2() {
|
|
10
|
-
return {
|
|
11
|
-
symbols: () => ({})
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function binanceSpotHistory3() {
|
|
15
|
-
return {
|
|
16
|
-
symbols: () => ({})
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
5
|
function funcTimeW() {
|
|
20
6
|
const dStatic = {};
|
|
21
7
|
const data = [];
|
package/package.json
CHANGED