wenay-common 1.0.200 → 1.0.201

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.
Files changed (41) hide show
  1. package/lib/Common/BaseTypes.js +2 -1
  2. package/lib/Common/ByteStream.js +11 -4
  3. package/lib/Common/Color.js +18 -8
  4. package/lib/Common/Decorator.js +10 -4
  5. package/lib/Common/List.js +5 -1
  6. package/lib/Common/ListNodeAnd.js +5 -1
  7. package/lib/Common/Listen.js +43 -23
  8. package/lib/Common/Math.js +6 -2
  9. package/lib/Common/Time.js +73 -44
  10. package/lib/Common/common.js +150 -60
  11. package/lib/Common/commonsServer.js +21 -10
  12. package/lib/Common/commonsServer2.js +4 -1
  13. package/lib/Common/event.js +9 -4
  14. package/lib/Common/funcTimeWait.js +6 -2
  15. package/lib/Common/inputAutoStep.js +9 -6
  16. package/lib/Common/isProxy.js +4 -1
  17. package/lib/Common/node_console.js +10 -4
  18. package/lib/Common/objectPath.js +10 -4
  19. package/lib/Common/waitRun.js +12 -6
  20. package/lib/Exchange/Bars.js +91 -38
  21. package/lib/Exchange/CParams.js +26 -13
  22. package/lib/Exchange/ConnectData/Binance/BinanceLib/base.js +7 -2
  23. package/lib/Exchange/ConnectData/Binance/BinanceLib/type.js +2 -1
  24. package/lib/Exchange/ConnectData/Binance/commonOrder.js +4 -1
  25. package/lib/Exchange/ConnectData/Binance/interfaces.js +2 -1
  26. package/lib/Exchange/ConnectData/Binance/marketD.js +5 -1
  27. package/lib/Exchange/ConnectData/Binance/marketData.js +14 -6
  28. package/lib/Exchange/ConnectData/Binance/order.js +7 -4
  29. package/lib/Exchange/ConnectData/Binance/signatureCoder.js +4 -1
  30. package/lib/Exchange/ConnectData/Binance/use.js +9 -6
  31. package/lib/Exchange/ConnectData/Binance.js +79 -50
  32. package/lib/Exchange/ConnectData/type.js +2 -1
  33. package/lib/Exchange/IHistoryBase.js +2 -1
  34. package/lib/Exchange/LoadBase.js +14 -11
  35. package/lib/Exchange/MarketData.js +80 -37
  36. package/lib/Exchange/mini.js +2 -1
  37. package/lib/client.js +58 -18
  38. package/lib/index.js +72 -32
  39. package/lib/server.js +18 -2
  40. package/lib/toError/myThrow.js +4 -1
  41. package/package.json +1 -1
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,13 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ByteStreamR = exports.ByteStreamW = exports.Nullable = void 0;
4
+ exports.nullable = nullable;
1
5
  function createCopyOfBuffer(src, length = src.byteLength) {
2
6
  let dst = new ArrayBuffer(length);
3
7
  new Uint8Array(dst).set(new Uint8Array(src));
4
8
  return dst;
5
9
  }
6
- export class Nullable {
10
+ class Nullable {
7
11
  value;
8
12
  constructor(type) { this.value = type; }
9
13
  }
10
- export function nullable(type) { return new Nullable(type); }
14
+ exports.Nullable = Nullable;
15
+ function nullable(type) { return new Nullable(type); }
11
16
  function __getNumericTypeInfo(type) {
12
17
  switch (type) {
13
18
  case "int8": return [1];
@@ -34,7 +39,7 @@ function getNumericTypeInfo(type) {
34
39
  return null;
35
40
  return { size, signed, integer };
36
41
  }
37
- export class ByteStreamW {
42
+ class ByteStreamW {
38
43
  _view = new DataView(new ArrayBuffer(0));
39
44
  _pos = 0;
40
45
  _isThrowable = true;
@@ -214,6 +219,7 @@ export class ByteStreamW {
214
219
  pushAnsi(text) { return this._pushNullableString(text, 1); }
215
220
  pushUnicode(text) { return this._pushNullableString(text, 2); }
216
221
  }
222
+ exports.ByteStreamW = ByteStreamW;
217
223
  class ByteStreamR_ {
218
224
  _wstream;
219
225
  _view;
@@ -378,9 +384,10 @@ class ByteStreamR_ {
378
384
  readUnicode() { return this._readNullableString(2); }
379
385
  }
380
386
  ;
381
- export class ByteStreamR extends ByteStreamR_ {
387
+ class ByteStreamR extends ByteStreamR_ {
382
388
  constructor(data) { super(data); }
383
389
  }
390
+ exports.ByteStreamR = ByteStreamR;
384
391
  ;
385
392
  function Test() {
386
393
  class A {
@@ -1,5 +1,15 @@
1
- export function rgb(red, green, blue) { return `rgb(${red},${green},${blue})`; }
2
- export function* colorGenerator(min = 0, max = 254) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rgb = rgb;
4
+ exports.colorGenerator = colorGenerator;
5
+ exports.colorGenerator2 = colorGenerator2;
6
+ exports.colorGeneratorByCount2 = colorGeneratorByCount2;
7
+ exports.colorGeneratorByCount = colorGeneratorByCount;
8
+ exports.colorStringToRGBA = colorStringToRGBA;
9
+ exports.toColorString = toColorString;
10
+ exports.isSimilarColors = isSimilarColors;
11
+ function rgb(red, green, blue) { return `rgb(${red},${green},${blue})`; }
12
+ function* colorGenerator(min = 0, max = 254) {
3
13
  for (let step = Math.floor((max - min) / 2); step >= 1; step /= 2) {
4
14
  let v = (max - min) / step;
5
15
  for (let rStep = 0, r = 0; rStep <= v; rStep++, r += step)
@@ -12,7 +22,7 @@ export function* colorGenerator(min = 0, max = 254) {
12
22
  }
13
23
  yield [-1, -1, -1];
14
24
  }
15
- export function* colorGenerator2(data) {
25
+ function* colorGenerator2(data) {
16
26
  const max = data?.max ?? 255;
17
27
  const min = data?.min ?? 0;
18
28
  function* _range(start = 0, end = 255) {
@@ -57,7 +67,7 @@ export function* colorGenerator2(data) {
57
67
  }
58
68
  yield [-1, -1, -1];
59
69
  }
60
- export function colorGeneratorByCount2(value = 180, count = 100, index = 1) {
70
+ function colorGeneratorByCount2(value = 180, count = 100, index = 1) {
61
71
  const step = Math.floor(value * 6 * index / count);
62
72
  const p = Math.floor(step / value);
63
73
  const z = Math.floor(step % value);
@@ -66,11 +76,11 @@ export function colorGeneratorByCount2(value = 180, count = 100, index = 1) {
66
76
  const b = (p == 3 || p == 4) ? value : (p == 5) ? value - z : (p == 2) ? z : 0;
67
77
  return [r, g, b];
68
78
  }
69
- export function colorGeneratorByCount(value = 180, count = 100, index = 1) {
79
+ function colorGeneratorByCount(value = 180, count = 100, index = 1) {
70
80
  const [r, g, b] = colorGeneratorByCount2(value, count, index);
71
81
  return `rgb(${r},${g},${b})`;
72
82
  }
73
- export function colorStringToRGBA(str) {
83
+ function colorStringToRGBA(str) {
74
84
  const rgbRegex = /^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i;
75
85
  const rgbaRegex = /^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d*\.?\d+)\s*\)$/i;
76
86
  let match = str.match(rgbRegex);
@@ -95,9 +105,9 @@ function isValidRGBValue(value) {
95
105
  function isValidAlphaValue(value) {
96
106
  return value >= 0 && value <= 1;
97
107
  }
98
- export function toColorString(str) { if (colorStringToRGBA(str))
108
+ function toColorString(str) { if (colorStringToRGBA(str))
99
109
  return str; throw `the string '${str}' is not valid 'rgb' or 'rgba' string`; }
100
- export function isSimilarColors(color1, color2, maxDelta = 32) {
110
+ function isSimilarColors(color1, color2, maxDelta = 32) {
101
111
  let [r1, g1, b1] = typeof color1 == "string" ? colorStringToRGBA(color1) : color1;
102
112
  let [r2, g2, b2] = typeof color2 == "string" ? colorStringToRGBA(color2) : color2;
103
113
  let delta = Math.abs(r1 - r2) + Math.abs(g1 - g2) + Math.abs(b1 - b2);
@@ -1,4 +1,10 @@
1
- export function enhancedDecorator(fn, opt) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enhancedDecorator = enhancedDecorator;
4
+ exports.enhancedTransformer = enhancedTransformer;
5
+ exports.Decorator = Decorator;
6
+ exports.Transformer = Transformer;
7
+ function enhancedDecorator(fn, opt) {
2
8
  return (...args) => {
3
9
  opt?.beforeParams?.(...args);
4
10
  const modifiedArgs = opt?.modifyParams?.(...args) || args;
@@ -20,13 +26,13 @@ export function enhancedDecorator(fn, opt) {
20
26
  }
21
27
  };
22
28
  }
23
- export function enhancedTransformer(fn, transform) {
29
+ function enhancedTransformer(fn, transform) {
24
30
  return (...args) => {
25
31
  const result = fn(...args);
26
32
  return transform([args, result]);
27
33
  };
28
34
  }
29
- export function Decorator(fn, opt) {
35
+ function Decorator(fn, opt) {
30
36
  return enhancedDecorator(fn, {
31
37
  beforeParams: opt?.parameters,
32
38
  modifyParams: opt?.parametersModifier,
@@ -35,6 +41,6 @@ export function Decorator(fn, opt) {
35
41
  modifyResult: opt?.resultModifier,
36
42
  });
37
43
  }
38
- export function Transformer(fn, transform) {
44
+ function Transformer(fn, transform) {
39
45
  return enhancedTransformer(fn, transform);
40
46
  }
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CList = void 0;
1
4
  class CListNode {
2
5
  value;
3
6
  list;
@@ -6,7 +9,7 @@ class CListNode {
6
9
  [Symbol.species] = this;
7
10
  constructor(list, value) { this.list = list; this.value = value; }
8
11
  }
9
- export class CList {
12
+ class CList {
10
13
  _first;
11
14
  _last;
12
15
  _count = 0;
@@ -141,6 +144,7 @@ export class CList {
141
144
  }
142
145
  newNode(value) { return new CListNode(this, value); }
143
146
  }
147
+ exports.CList = CList;
144
148
  function test() {
145
149
  function print(...args) { console.log(...args); }
146
150
  let list = new CList();
@@ -1,7 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CListNodeAnd = void 0;
1
4
  class CBaseList {
2
5
  data;
3
6
  }
4
- export class CListNodeAnd extends CBaseList {
7
+ class CListNodeAnd extends CBaseList {
5
8
  get count() {
6
9
  return this._home?._count ?? -1;
7
10
  }
@@ -83,3 +86,4 @@ export class CListNodeAnd extends CBaseList {
83
86
  } return undefined; }
84
87
  DeleteLink() { this._prev._next = this._next; this._next._prev = this._prev; this._prev = this._next = this; this._stop = true; this._home?.countRef(); CListNodeAnd._valueG2--; this._home = undefined; }
85
88
  }
89
+ exports.CListNodeAnd = CListNodeAnd;
@@ -1,5 +1,25 @@
1
- import { isProxy } from "./isProxy";
2
- export function funcListenCallbackBase(b, data) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.funcListenBySocketObj = exports.funcListenBySocket1 = void 0;
4
+ exports.funcListenCallbackBase = funcListenCallbackBase;
5
+ exports.funcListenCallbackFast = funcListenCallbackFast;
6
+ exports.funcListenCallback = funcListenCallback;
7
+ exports.funcListenBySocket2 = funcListenBySocket2;
8
+ exports.funcListenBySocket3 = funcListenBySocket3;
9
+ exports.funcListenBySocket = funcListenBySocket;
10
+ exports.UseListen = UseListen;
11
+ exports.CompareKeys = CompareKeys;
12
+ exports.CompareKeys2 = CompareKeys2;
13
+ exports.DeepCompareKeys2 = DeepCompareKeys2;
14
+ exports.DeepCompareKeys = DeepCompareKeys;
15
+ exports.deepModifyByListenSocket = deepModifyByListenSocket;
16
+ exports.deepModifyByListenSocket2 = deepModifyByListenSocket2;
17
+ exports.deepModifyByListenSocket3 = deepModifyByListenSocket3;
18
+ exports.PromiseArrayListen = PromiseArrayListen;
19
+ exports.socketBuffer3 = socketBuffer3;
20
+ exports.funcListenCallbackSnapshot = funcListenCallbackSnapshot;
21
+ const isProxy_1 = require("./isProxy");
22
+ function funcListenCallbackBase(b, data) {
3
23
  const def = { fast: false };
4
24
  const { fast, event } = { ...def, ...(data ?? {}) };
5
25
  let a;
@@ -51,13 +71,13 @@ export function funcListenCallbackBase(b, data) {
51
71
  };
52
72
  return api;
53
73
  }
54
- export function funcListenCallbackFast(a) {
74
+ function funcListenCallbackFast(a) {
55
75
  return funcListenCallbackBase(a, { fast: true });
56
76
  }
57
- export function funcListenCallback(a, event, fast = true) {
77
+ function funcListenCallback(a, event, fast = true) {
58
78
  return funcListenCallbackBase(a, { event, fast });
59
79
  }
60
- export function funcListenBySocket2(e, d) {
80
+ function funcListenBySocket2(e, d) {
61
81
  const { stop, addListenClose, status, paramsModify } = d ?? {};
62
82
  const { addListen, removeListen, count } = e;
63
83
  let last = null;
@@ -99,7 +119,7 @@ export function funcListenBySocket2(e, d) {
99
119
  removeCallback
100
120
  };
101
121
  }
102
- export function funcListenBySocket3(e, options) {
122
+ function funcListenBySocket3(e, options) {
103
123
  const r = funcListenBySocket2(e, { ...options, paramsModify: e => [e] });
104
124
  const callback = r.callback;
105
125
  return {
@@ -107,7 +127,7 @@ export function funcListenBySocket3(e, options) {
107
127
  removeCallback: r.removeCallback
108
128
  };
109
129
  }
110
- export function funcListenBySocket(e, status, onStop) {
130
+ function funcListenBySocket(e, status, onStop) {
111
131
  const { addListen, removeListen, count } = e;
112
132
  let x = null;
113
133
  let r2 = null;
@@ -137,24 +157,24 @@ export function funcListenBySocket(e, status, onStop) {
137
157
  }
138
158
  };
139
159
  }
140
- export const funcListenBySocket1 = funcListenBySocket;
141
- export function UseListen(data = { fast: true }) {
160
+ exports.funcListenBySocket1 = funcListenBySocket;
161
+ function UseListen(data = { fast: true }) {
142
162
  let t;
143
163
  const a = funcListenCallbackBase((e) => { t = e; }, { fast: true, ...data });
144
164
  a.run();
145
165
  t = a.func;
146
166
  return [t, a];
147
167
  }
148
- export function CompareKeys(obj1, obj2) {
168
+ function CompareKeys(obj1, obj2) {
149
169
  const k1 = Object.keys(obj1);
150
170
  const k2 = Object.keys(obj2);
151
171
  return k1.length == k2.length && ((new Set([...k1, ...k2])).size == k2.length);
152
172
  }
153
- export function CompareKeys2(obj1, keys) {
173
+ function CompareKeys2(obj1, keys) {
154
174
  const k1 = Object.keys(obj1);
155
175
  return k1.length == keys.length && ((new Set([...k1, ...keys])).size == keys.length);
156
176
  }
157
- export function DeepCompareKeys2(obj1, keys, func) {
177
+ function DeepCompareKeys2(obj1, keys, func) {
158
178
  if (obj1 == null)
159
179
  return null;
160
180
  if (typeof obj1 == "function")
@@ -163,14 +183,14 @@ export function DeepCompareKeys2(obj1, keys, func) {
163
183
  return obj1;
164
184
  if (typeof obj1 != "object")
165
185
  return obj1;
166
- if (isProxy(obj1))
186
+ if ((0, isProxy_1.isProxy)(obj1))
167
187
  return obj1;
168
188
  if (CompareKeys2(obj1, keys)) {
169
189
  return func(obj1);
170
190
  }
171
191
  return Object.fromEntries(Object.entries(obj1).map(([k, v]) => [k, DeepCompareKeys2(v, keys, func)]));
172
192
  }
173
- export function DeepCompareKeys(obj1, obj2, func) {
193
+ function DeepCompareKeys(obj1, obj2, func) {
174
194
  if (obj1 == null)
175
195
  return null;
176
196
  if (typeof obj1 == "function")
@@ -179,7 +199,7 @@ export function DeepCompareKeys(obj1, obj2, func) {
179
199
  return obj1;
180
200
  if (typeof obj1 != "object")
181
201
  return obj1;
182
- if (isProxy(obj1))
202
+ if ((0, isProxy_1.isProxy)(obj1))
183
203
  return obj1;
184
204
  const keys = Object.keys(obj2);
185
205
  if (CompareKeys2(obj1, keys)) {
@@ -187,17 +207,17 @@ export function DeepCompareKeys(obj1, obj2, func) {
187
207
  }
188
208
  return Object.fromEntries(Object.entries(obj1).map(([k, v]) => [k, DeepCompareKeys2(v, keys, func)]));
189
209
  }
190
- export function deepModifyByListenSocket(obj, status) {
191
- return DeepCompareKeys(obj, funcListenCallbackBase(e => { }), e => funcListenBySocket1(e, status));
210
+ function deepModifyByListenSocket(obj, status) {
211
+ return DeepCompareKeys(obj, funcListenCallbackBase(e => { }), e => (0, exports.funcListenBySocket1)(e, status));
192
212
  }
193
- export function deepModifyByListenSocket2(obj, data) {
213
+ function deepModifyByListenSocket2(obj, data) {
194
214
  return DeepCompareKeys(obj, funcListenCallbackBase(e => { }), e => funcListenBySocket2(e, data));
195
215
  }
196
- export function deepModifyByListenSocket3(obj, data) {
216
+ function deepModifyByListenSocket3(obj, data) {
197
217
  return DeepCompareKeys(obj, funcListenCallbackBase(e => { }), e => funcListenBySocket3(e, data));
198
218
  }
199
- export const funcListenBySocketObj = deepModifyByListenSocket;
200
- export function PromiseArrayListen(array) {
219
+ exports.funcListenBySocketObj = deepModifyByListenSocket;
220
+ function PromiseArrayListen(array) {
201
221
  let ok = 0, error = 0;
202
222
  const count = array.length;
203
223
  const t = UseListen();
@@ -232,12 +252,12 @@ export function PromiseArrayListen(array) {
232
252
  }
233
253
  };
234
254
  }
235
- export function socketBuffer3(func, callbackMain, memo = {}) {
255
+ function socketBuffer3(func, callbackMain, memo = {}) {
236
256
  return (a, ...b) => func({ ...a, callback: (v) => { const z = callbackMain(v, memo); if (z)
237
257
  a.callback(...z); }
238
258
  }, ...b);
239
259
  }
240
- export function funcListenCallbackSnapshot({ func, memo = {}, callbackSave, snapshot }) {
260
+ function funcListenCallbackSnapshot({ func, memo = {}, callbackSave, snapshot }) {
241
261
  let d = null;
242
262
  const [callback, listenA] = UseListen({
243
263
  event: (type, count, api) => {
@@ -1,4 +1,8 @@
1
- export function CorrelationRollingByBuffer(data) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CorrelationRollingByBuffer = CorrelationRollingByBuffer;
4
+ exports.CorrelationFunc = CorrelationFunc;
5
+ function CorrelationRollingByBuffer(data) {
2
6
  let setting = { ...data };
3
7
  let total = 0;
4
8
  const map = new Map();
@@ -53,7 +57,7 @@ export function CorrelationRollingByBuffer(data) {
53
57
  }
54
58
  });
55
59
  }
56
- export function CorrelationFunc(d1, d2, setting) {
60
+ function CorrelationFunc(d1, d2, setting) {
57
61
  const { min, pow, sqrt } = Math;
58
62
  const { isNaN } = Number;
59
63
  const { rolling } = setting;
@@ -1,17 +1,41 @@
1
- import { CreateArrayProxy } from "./common";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
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;
25
+ const common_1 = require("./common");
2
26
  function GetEnumKeys(T) { return Object.keys(T).filter(k => isNaN(k)); }
3
27
  {
4
28
  let t1 = "2022-05-01";
5
29
  let t2 = "2022-05-01 01:01";
6
30
  let t3 = "2022-05-01 01:01:10";
7
31
  }
8
- export const H1_S = 3600;
9
- export const D1_S = 3600 * 24;
10
- export const W1_S = D1_S * 7;
11
- export const W1_MS = W1_S * 1000;
12
- export const D1_MS = D1_S * 1000;
13
- export const H1_MS = H1_S * 1000;
14
- export const M1_MS = 60 * 1000;
32
+ exports.H1_S = 3600;
33
+ exports.D1_S = 3600 * 24;
34
+ exports.W1_S = exports.D1_S * 7;
35
+ exports.W1_MS = exports.W1_S * 1000;
36
+ exports.D1_MS = exports.D1_S * 1000;
37
+ exports.H1_MS = exports.H1_S * 1000;
38
+ exports.M1_MS = 60 * 1000;
15
39
  var __E_TF;
16
40
  (function (__E_TF) {
17
41
  __E_TF[__E_TF["S1"] = 1] = "S1";
@@ -53,8 +77,8 @@ var __E_TF;
53
77
  __E_TF[__E_TF["Y1"] = 37] = "Y1";
54
78
  })(__E_TF || (__E_TF = {}));
55
79
  ;
56
- const __Tf_S = [0, 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60, 120, 180, 240, 300, 360, 600, 720, 900, 1200, 1800, H1_S, 2 * H1_S, 3 * H1_S, 4 * H1_S, 6 * H1_S, 8 * H1_S, 12 * H1_S, D1_S, W1_S, 30 * D1_S, 60 * D1_S, 90 * D1_S, 120 * D1_S, 180 * D1_S, 365 * D1_S];
57
- export class TIME_UNIT {
80
+ const __Tf_S = [0, 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60, 120, 180, 240, 300, 360, 600, 720, 900, 1200, 1800, exports.H1_S, 2 * exports.H1_S, 3 * exports.H1_S, 4 * exports.H1_S, 6 * exports.H1_S, 8 * exports.H1_S, 12 * exports.H1_S, exports.D1_S, exports.W1_S, 30 * exports.D1_S, 60 * exports.D1_S, 90 * exports.D1_S, 120 * exports.D1_S, 180 * exports.D1_S, 365 * exports.D1_S];
81
+ class TIME_UNIT {
58
82
  index;
59
83
  msec;
60
84
  sec;
@@ -71,13 +95,14 @@ export class TIME_UNIT {
71
95
  static MSecond = new TIME_UNIT(1, "millisecond", "MS");
72
96
  static Second = new TIME_UNIT(1000, "second", "S");
73
97
  static Minute = new TIME_UNIT(60 * 1000, "minute", "M");
74
- static Hour = new TIME_UNIT(H1_S * 1000, "hour", "H");
75
- static Day = new TIME_UNIT(D1_S * 1000, "day", "D");
76
- static Week = new TIME_UNIT(7 * D1_S * 1000, "week", "W");
77
- static Month = new TIME_UNIT(30 * D1_S * 1000, "month", "MN");
78
- static Year = new TIME_UNIT(365 * D1_S * 1000, "year", "Y");
98
+ static Hour = new TIME_UNIT(exports.H1_S * 1000, "hour", "H");
99
+ static Day = new TIME_UNIT(exports.D1_S * 1000, "day", "D");
100
+ static Week = new TIME_UNIT(7 * exports.D1_S * 1000, "week", "W");
101
+ static Month = new TIME_UNIT(30 * exports.D1_S * 1000, "month", "MN");
102
+ static Year = new TIME_UNIT(365 * exports.D1_S * 1000, "year", "Y");
79
103
  }
80
- export class TF {
104
+ exports.TIME_UNIT = TIME_UNIT;
105
+ class TF {
81
106
  sec;
82
107
  msec;
83
108
  name;
@@ -182,11 +207,12 @@ export class TF {
182
207
  return index != -1 ? this.all[index] : null;
183
208
  }
184
209
  }
210
+ exports.TF = TF;
185
211
  function TimeAddMilliseconds(time, shift) { return new Date(time.valueOf() + shift); }
186
212
  class MyDate extends Date {
187
213
  ToShiftedMsTime(shiftMs) { return TimeAddMilliseconds(this, shiftMs); }
188
214
  }
189
- export class PeriodSpan {
215
+ class PeriodSpan {
190
216
  period;
191
217
  index;
192
218
  constructor(period, indexOrTime) {
@@ -198,14 +224,15 @@ export class PeriodSpan {
198
224
  get startTime() { return Period.StartTimeForIndex(this.period.tf, this.index); }
199
225
  get endTime() { return Period.StartTimeForIndex(this.period.tf, this.index + 1).ToShiftedMsTime(-1); }
200
226
  }
201
- export class Period {
227
+ exports.PeriodSpan = PeriodSpan;
228
+ class Period {
202
229
  tf;
203
230
  get sec() { return this.tf.sec; }
204
231
  get msec() { return this.tf.msec; }
205
232
  get name() { return this.tf.name; }
206
233
  valueOf() { return this.msec; }
207
234
  span(time) { return new PeriodSpan(this.tf, time); }
208
- constructor(tf) { this.tf = tf; return CreateArrayProxy(this, (i) => new PeriodSpan(tf, i)); }
235
+ constructor(tf) { this.tf = tf; return (0, common_1.CreateArrayProxy)(this, (i) => new PeriodSpan(tf, i)); }
209
236
  static Seconds(tf) { return tf.sec; }
210
237
  static Name(tf) { return tf.name; }
211
238
  IndexFromTime(time) {
@@ -214,7 +241,7 @@ export class Period {
214
241
  getStartTime(currentTime) { return Period.StartTime(this.tf, currentTime); }
215
242
  static getW1Shift_ms() {
216
243
  const day0 = new Date(0).getUTCDay();
217
- const tshift = D1_MS * Math.trunc((day0 + 6) % 7);
244
+ const tshift = exports.D1_MS * Math.trunc((day0 + 6) % 7);
218
245
  return tshift;
219
246
  }
220
247
  static W1Shift_ms = this.getW1Shift_ms();
@@ -250,21 +277,22 @@ export class Period {
250
277
  }
251
278
  static EndTime(tf, currentTime) { return this.StartTime(tf, currentTime, +1).ToShiftedMsTime(-1); }
252
279
  }
280
+ exports.Period = Period;
253
281
  function str2(n) { return n <= 9 ? '0' + n : '' + n; }
254
282
  function str3(n) { return (n <= 9 ? '00' : n <= 99 ? '0' : '') + n; }
255
- export function timeToStr_hhmmss_ms(date) { return str2(date.getUTCHours()) + ":" + str2(date.getUTCMinutes()) + ":" + str2(date.getUTCSeconds()) + "." + str3(date.getUTCMilliseconds()); }
256
- export function timeToStr_hhmmss(date) { return str2(date.getUTCHours()) + ":" + str2(date.getUTCMinutes()) + ":" + str2(date.getUTCSeconds()); }
257
- export function timeToStr_yyyymmdd_hhmm(date, dateDelim = "-") { return date.getUTCFullYear() + dateDelim + str2(date.getUTCMonth() + 1) + dateDelim + str2(date.getUTCDate()) + " " + str2(date.getUTCHours()) + ":" + str2(date.getUTCMinutes()); }
258
- export function timeToStr_yyyymmdd_hhmmss(date, dateDelim = "-") { return timeToStr_yyyymmdd_hhmm(date, dateDelim) + ":" + str2(date.getUTCSeconds()); }
259
- export function timeToStr_yyyymmdd_hhmmss_ms(date, dateDelim = "-") { return timeToStr_yyyymmdd_hhmmss(date, dateDelim) + "." + str3(date.getUTCMilliseconds()); }
260
- export function timeLocalToStr_hhmmss(date) { return str2(date.getHours()) + ":" + str2(date.getMinutes()) + ":" + str2(date.getSeconds()); }
261
- export function timeLocalToStr_hhmmss_ms(date) { return timeLocalToStr_hhmmss(date) + str3(date.getMilliseconds()); }
262
- export function timeLocalToStr_yyyymmdd(date, dateDelim = "-") { return date.getFullYear() + dateDelim + str2(date.getMonth() + 1) + dateDelim + str2(date.getDate()); }
263
- export function timeLocalToStr_yyyymmdd_hhmm(date, dateDelim = "-") { return timeLocalToStr_yyyymmdd(date, dateDelim) + " " + str2(date.getHours()) + ":" + str2(date.getMinutes()); }
264
- export function timeLocalToStr_yyyymmdd_hhmmss(date, dateDelim = "-") { return timeLocalToStr_yyyymmdd_hhmm(date, dateDelim) + ":" + str2(date.getSeconds()); }
265
- export function timeLocalToStr_yyyymmdd_hhmmss_ms(date, dateDelim = "-") { return timeLocalToStr_yyyymmdd_hhmmss(date, dateDelim) + "." + str3(date.getMilliseconds()); }
266
- export function timeToString_yyyymmdd_hhmm_offset(date) { let offset = date.getTimezoneOffset(); return timeLocalToStr_yyyymmdd_hhmm(date) + " GMT" + (offset < 0 ? '+' : '') + (-offset / 60); }
267
- export function timeToString_yyyymmdd_hhmmss_offset(date) { let offset = date.getTimezoneOffset(); return timeLocalToStr_yyyymmdd_hhmmss(date) + " GMT" + (offset < 0 ? '+' : '') + (-offset / 60); }
283
+ function timeToStr_hhmmss_ms(date) { return str2(date.getUTCHours()) + ":" + str2(date.getUTCMinutes()) + ":" + str2(date.getUTCSeconds()) + "." + str3(date.getUTCMilliseconds()); }
284
+ function timeToStr_hhmmss(date) { return str2(date.getUTCHours()) + ":" + str2(date.getUTCMinutes()) + ":" + str2(date.getUTCSeconds()); }
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()); }
286
+ function timeToStr_yyyymmdd_hhmmss(date, dateDelim = "-") { return timeToStr_yyyymmdd_hhmm(date, dateDelim) + ":" + str2(date.getUTCSeconds()); }
287
+ function timeToStr_yyyymmdd_hhmmss_ms(date, dateDelim = "-") { return timeToStr_yyyymmdd_hhmmss(date, dateDelim) + "." + str3(date.getUTCMilliseconds()); }
288
+ function timeLocalToStr_hhmmss(date) { return str2(date.getHours()) + ":" + str2(date.getMinutes()) + ":" + str2(date.getSeconds()); }
289
+ function timeLocalToStr_hhmmss_ms(date) { return timeLocalToStr_hhmmss(date) + str3(date.getMilliseconds()); }
290
+ function timeLocalToStr_yyyymmdd(date, dateDelim = "-") { return date.getFullYear() + dateDelim + str2(date.getMonth() + 1) + dateDelim + str2(date.getDate()); }
291
+ function timeLocalToStr_yyyymmdd_hhmm(date, dateDelim = "-") { return timeLocalToStr_yyyymmdd(date, dateDelim) + " " + str2(date.getHours()) + ":" + str2(date.getMinutes()); }
292
+ function timeLocalToStr_yyyymmdd_hhmmss(date, dateDelim = "-") { return timeLocalToStr_yyyymmdd_hhmm(date, dateDelim) + ":" + str2(date.getSeconds()); }
293
+ function timeLocalToStr_yyyymmdd_hhmmss_ms(date, dateDelim = "-") { return timeLocalToStr_yyyymmdd_hhmmss(date, dateDelim) + "." + str3(date.getMilliseconds()); }
294
+ function timeToString_yyyymmdd_hhmm_offset(date) { let offset = date.getTimezoneOffset(); return timeLocalToStr_yyyymmdd_hhmm(date) + " GMT" + (offset < 0 ? '+' : '') + (-offset / 60); }
295
+ function timeToString_yyyymmdd_hhmmss_offset(date) { let offset = date.getTimezoneOffset(); return timeLocalToStr_yyyymmdd_hhmmss(date) + " GMT" + (offset < 0 ? '+' : '') + (-offset / 60); }
268
296
  Date.prototype.toString = function () { return timeToString_yyyymmdd_hhmmss_offset(this); };
269
297
  Date.prototype.toDateString = function () { return timeLocalToStr_yyyymmdd(this); };
270
298
  Date.prototype.toTimeString = function () { let offset = this.getTimezoneOffset(); return timeLocalToStr_hhmmss(this) + " GMT" + (offset < 0 ? '+' : '') + (-offset / 60); };
@@ -290,8 +318,8 @@ function _getStructCopyWithTimeStrings(arg, objectsMap) {
290
318
  clone[key] = _getStructCopyWithTimeStrings(arg[key], objectsMap);
291
319
  return clone;
292
320
  }
293
- export function convertDatesToStrings(arg) { return _getStructCopyWithTimeStrings(arg); }
294
- export function toPrintObject(arg) { return convertDatesToStrings(arg); }
321
+ function convertDatesToStrings(arg) { return _getStructCopyWithTimeStrings(arg); }
322
+ function toPrintObject(arg) { return convertDatesToStrings(arg); }
295
323
  function replaceConsoleCommands() {
296
324
  const consoleLog = console.log;
297
325
  const consoleWarn = console.warn;
@@ -301,8 +329,8 @@ function replaceConsoleCommands() {
301
329
  console.warn = (...args) => { consoleWarn(...replaceArgs(args)); };
302
330
  console.error = (...args) => { consoleError(...replaceArgs(args)); };
303
331
  }
304
- export function durationToStr(duration_ms) {
305
- let units = [[D1_MS, "д"], [H1_MS, "ч"], [M1_MS, "м"], [1000, "c"], [1, "мс"]];
332
+ function durationToStr(duration_ms) {
333
+ let units = [[exports.D1_MS, "д"], [exports.H1_MS, "ч"], [exports.M1_MS, "м"], [1000, "c"], [1, "мс"]];
306
334
  let lastUnit = null;
307
335
  let str = "";
308
336
  for (let unit of units) {
@@ -324,16 +352,16 @@ export function durationToStr(duration_ms) {
324
352
  }
325
353
  return str;
326
354
  }
327
- export function durationToStrNullable(duration_ms) { return duration_ms == null ? null : durationToStr(duration_ms); }
328
- export function durationToStr_h_mm_ss(duration_ms) {
355
+ function durationToStrNullable(duration_ms) { return duration_ms == null ? null : durationToStr(duration_ms); }
356
+ function durationToStr_h_mm_ss(duration_ms) {
329
357
  let time = new Date(duration_ms);
330
- return Math.trunc(duration_ms / H1_MS) + ":" + str2(time.getUTCMinutes()) + ":" + str2(time.getUTCSeconds());
358
+ return Math.trunc(duration_ms / exports.H1_MS) + ":" + str2(time.getUTCMinutes()) + ":" + str2(time.getUTCSeconds());
331
359
  }
332
- export function durationToStr_h_mm_ss_ms(duration_ms) { return durationToStr_h_mm_ss(duration_ms) + "." + str3(Math.trunc(duration_ms % 1000)); }
360
+ function durationToStr_h_mm_ss_ms(duration_ms) { return durationToStr_h_mm_ss(duration_ms) + "." + str3(Math.trunc(duration_ms % 1000)); }
333
361
  async function sleepAsync(msec) {
334
362
  return new Promise((resolve, reject) => { setTimeout(resolve, msec); });
335
363
  }
336
- export class CDelayer {
364
+ class CDelayer {
337
365
  remainPause = 0;
338
366
  async sleepAsync(pause_ms_getter) {
339
367
  let passed_ms = 0;
@@ -356,9 +384,10 @@ export class CDelayer {
356
384
  }
357
385
  }
358
386
  }
359
- export function MinTime(time1, time2) {
387
+ exports.CDelayer = CDelayer;
388
+ function MinTime(time1, time2) {
360
389
  return time1 && time2 && time1.valueOf() <= time2.valueOf() ? time1 : time2 ?? time1;
361
390
  }
362
- export function MaxTime(time1, time2) {
391
+ function MaxTime(time1, time2) {
363
392
  return time1 && time2 && time1.valueOf() >= time2.valueOf() ? time1 : time2 ?? time1;
364
393
  }