wenay-common 1.0.81 → 1.0.83

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.
@@ -57,16 +57,12 @@ type tBinanceLoadBase<Bar extends {
57
57
  name: IntervalNameT;
58
58
  }[];
59
59
  nameKey?: string;
60
+ controlTimeToNumber?: (bar: Bar) => number;
60
61
  };
61
- export declare function LoadQuoteBase<Bar extends {
62
- time?: number;
63
- } | {
64
- time?: Date;
65
- } | object, T extends (number | Date), T2 extends (number | string)>(setting: tBinanceLoadBase<Bar, T, T2> & {
62
+ export declare function LoadQuoteBase<Bar extends object, T extends (number | Date), T2 extends (number | string)>(setting: tBinanceLoadBase<Bar, T, T2> & {
66
63
  maxLoadBars: T;
67
64
  }, data?: {
68
65
  fetch?: tFetch3;
69
66
  error?: boolean;
70
- reverseControlOff?: boolean;
71
67
  }): (info: tInfoForLoadHistory) => Promise<Bar[]>;
72
68
  export {};
@@ -11,18 +11,7 @@ function LoadQuoteBase(setting, data) {
11
11
  const keyName = setting.nameKey ?? "loadKey";
12
12
  const time = setting.time ?? 60000;
13
13
  const other = data;
14
- const getDataEl = (a) => {
15
- if (typeof a == "object") {
16
- if (a.time) {
17
- if (typeof a.time == "number")
18
- return a;
19
- if (a.time instanceof Date) {
20
- return a.time.valueOf();
21
- }
22
- }
23
- }
24
- return undefined;
25
- };
14
+ const getDataEl = (a) => setting.controlTimeToNumber?.(a);
26
15
  async function waitLimit(weight = 1) {
27
16
  const t1 = funcTimeWait_1.FuncTimeWait.byWeight(keyName, setting.countConnect) - (Date.now() - time) + 1;
28
17
  if (t1 > 0) {
@@ -109,12 +98,12 @@ function LoadQuoteBase(setting, data) {
109
98
  };
110
99
  await waitLimit();
111
100
  let res = await setting.funcLoad(data);
112
- if (res.length && res[0].time && (other?.reverseControlOff != true)) {
113
- let t1, t2;
114
- t1 = getDataEl(res[0]);
115
- t2 = getDataEl(res.at(-1));
101
+ if (setting.controlTimeToNumber && res.length) {
102
+ let [t1, t2] = [
103
+ getDataEl(res[0]),
104
+ getDataEl(res.at(-1))
105
+ ];
116
106
  if (t1 && t2 && t1 > t2) {
117
- console.log("correct reverse history time, auto revers ruing, pls use revers in funcLoad");
118
107
  res = res.reverse();
119
108
  }
120
109
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wenay-common",
3
- "version": "1.0.81",
3
+ "version": "1.0.83",
4
4
  "description": "math math math",
5
5
  "strict": true,
6
6
  "main": "lib/index.js",