wenay-common2 1.0.1

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 (94) hide show
  1. package/lib/Common/Color.d.ts +31 -0
  2. package/lib/Common/Color.js +115 -0
  3. package/lib/Common/Time.d.ts +206 -0
  4. package/lib/Common/Time.js +393 -0
  5. package/lib/Common/WebHook2.d.ts +0 -0
  6. package/lib/Common/WebHook2.js +1 -0
  7. package/lib/Common/WebHook3.d.ts +39 -0
  8. package/lib/Common/WebHook3.js +211 -0
  9. package/lib/Common/async/PromiseArrayListen.d.ts +14 -0
  10. package/lib/Common/async/PromiseArrayListen.js +41 -0
  11. package/lib/Common/async/createIterableObject.d.ts +6 -0
  12. package/lib/Common/async/createIterableObject.js +66 -0
  13. package/lib/Common/async/waitRun.d.ts +31 -0
  14. package/lib/Common/async/waitRun.js +104 -0
  15. package/lib/Common/core/BaseTypes.d.ts +38 -0
  16. package/lib/Common/core/BaseTypes.js +2 -0
  17. package/lib/Common/core/Decorator.d.ts +24 -0
  18. package/lib/Common/core/Decorator.js +50 -0
  19. package/lib/Common/core/MemoFunc.d.ts +19 -0
  20. package/lib/Common/core/MemoFunc.js +99 -0
  21. package/lib/Common/core/common.d.ts +253 -0
  22. package/lib/Common/core/common.js +773 -0
  23. package/lib/Common/data/ByteStream.d.ts +96 -0
  24. package/lib/Common/data/ByteStream.js +440 -0
  25. package/lib/Common/data/List.d.ts +64 -0
  26. package/lib/Common/data/List.js +193 -0
  27. package/lib/Common/data/ListNodeAnd.d.ts +46 -0
  28. package/lib/Common/data/ListNodeAnd.js +89 -0
  29. package/lib/Common/data/objectPath.d.ts +11 -0
  30. package/lib/Common/data/objectPath.js +59 -0
  31. package/lib/Common/events/Listen.d.ts +55 -0
  32. package/lib/Common/events/Listen.js +124 -0
  33. package/lib/Common/events/SocketBuffer.d.ts +41 -0
  34. package/lib/Common/events/SocketBuffer.js +43 -0
  35. package/lib/Common/events/SocketServerHook.d.ts +47 -0
  36. package/lib/Common/events/SocketServerHook.js +38 -0
  37. package/lib/Common/events/event.d.ts +34 -0
  38. package/lib/Common/events/event.js +77 -0
  39. package/lib/Common/events/joinListens.d.ts +17 -0
  40. package/lib/Common/events/joinListens.js +40 -0
  41. package/lib/Common/fsKeyVolume.d.ts +34 -0
  42. package/lib/Common/fsKeyVolume.js +92 -0
  43. package/lib/Common/funcTimeWait.d.ts +29 -0
  44. package/lib/Common/funcTimeWait.js +116 -0
  45. package/lib/Common/id-pool.d.ts +5 -0
  46. package/lib/Common/id-pool.js +12 -0
  47. package/lib/Common/inputAutoStep.d.ts +14 -0
  48. package/lib/Common/inputAutoStep.js +65 -0
  49. package/lib/Common/isProxy.d.ts +2 -0
  50. package/lib/Common/isProxy.js +40 -0
  51. package/lib/Common/math/Math.d.ts +12 -0
  52. package/lib/Common/math/Math.js +73 -0
  53. package/lib/Common/math/other.d.ts +23 -0
  54. package/lib/Common/math/other.js +70 -0
  55. package/lib/Common/math/scoreLana.d.ts +22 -0
  56. package/lib/Common/math/scoreLana.js +67 -0
  57. package/lib/Common/node_console.d.ts +6 -0
  58. package/lib/Common/node_console.js +170 -0
  59. package/lib/Common/rcp/listen-deep.d.ts +20 -0
  60. package/lib/Common/rcp/listen-deep.js +49 -0
  61. package/lib/Common/rcp/listen-socket.d.ts +25 -0
  62. package/lib/Common/rcp/listen-socket.js +105 -0
  63. package/lib/Common/rcp/rpc-client-auto.d.ts +12 -0
  64. package/lib/Common/rcp/rpc-client-auto.js +20 -0
  65. package/lib/Common/rcp/rpc-client.d.ts +30 -0
  66. package/lib/Common/rcp/rpc-client.js +169 -0
  67. package/lib/Common/rcp/rpc-dynamic.d.ts +2 -0
  68. package/lib/Common/rcp/rpc-dynamic.js +12 -0
  69. package/lib/Common/rcp/rpc-index.d.ts +8 -0
  70. package/lib/Common/rcp/rpc-index.js +24 -0
  71. package/lib/Common/rcp/rpc-limits.d.ts +14 -0
  72. package/lib/Common/rcp/rpc-limits.js +24 -0
  73. package/lib/Common/rcp/rpc-protocol.d.ts +12 -0
  74. package/lib/Common/rcp/rpc-protocol.js +4 -0
  75. package/lib/Common/rcp/rpc-server-auto.d.ts +15 -0
  76. package/lib/Common/rcp/rpc-server-auto.js +28 -0
  77. package/lib/Common/rcp/rpc-server.d.ts +27 -0
  78. package/lib/Common/rcp/rpc-server.js +175 -0
  79. package/lib/Common/rcp/rpc-walk.d.ts +8 -0
  80. package/lib/Common/rcp/rpc-walk.js +82 -0
  81. package/lib/Exchange/Bars.d.ts +181 -0
  82. package/lib/Exchange/Bars.js +475 -0
  83. package/lib/Exchange/CParams.d.ts +225 -0
  84. package/lib/Exchange/CParams.js +244 -0
  85. package/lib/client.d.ts +31 -0
  86. package/lib/client.js +70 -0
  87. package/lib/index.d.ts +31 -0
  88. package/lib/index.js +70 -0
  89. package/lib/server.d.ts +3 -0
  90. package/lib/server.js +19 -0
  91. package/lib/toError/myThrow.d.ts +5 -0
  92. package/lib/toError/myThrow.js +23 -0
  93. package/lib/tsconfig.json +6 -0
  94. package/package.json +32 -0
@@ -0,0 +1,31 @@
1
+ declare type Nominal<T, Name extends string> = T & {
2
+ [Symbol.species]: Name;
3
+ };
4
+ export type ColorNumber = Nominal<number, 'Color'>;
5
+ export type ColorString = `rgb(${number},${number},${number})` | `rgba(${number},${number},${number},${number})` | `#${string}`;
6
+ export type ColorRGB = Readonly<{
7
+ red: number;
8
+ green: number;
9
+ blue: number;
10
+ }>;
11
+ export type ColorRGBA = Readonly<{
12
+ red: number;
13
+ green: number;
14
+ blue: number;
15
+ alpha: number;
16
+ }>;
17
+ export type ColorAny = ColorNumber | ColorString | Readonly<ColorRGBA>;
18
+ export type Color = ColorString;
19
+ export declare function rgb(red: number, green: number, blue: number): ColorString;
20
+ export declare function colorGenerator(min?: number, max?: number): Generator<[number, number, number]>;
21
+ export declare function colorGenerator2(data?: {
22
+ min?: number;
23
+ max?: number;
24
+ }): Generator<[number, number, number]>;
25
+ export declare function colorGeneratorByCount2(value?: number, count?: number, index?: number): [number, number, number];
26
+ export declare function colorGeneratorByCount(value?: number, count?: number, index?: number): ColorString;
27
+ export declare function colorStringToRGBA(str: ColorString): [number, number, number, number];
28
+ export declare function colorStringToRGBA(str: string): [number, number, number, number] | undefined;
29
+ export declare function toColorString(str: string): ColorString;
30
+ export declare function isSimilarColors(color1: ColorString | readonly [number, number, number], color2: ColorString | readonly [number, number, number], maxDelta?: number): boolean;
31
+ export {};
@@ -0,0 +1,115 @@
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) {
13
+ for (let step = Math.floor((max - min) / 2); step >= 1; step /= 2) {
14
+ let v = (max - min) / step;
15
+ for (let rStep = 0, r = 0; rStep <= v; rStep++, r += step)
16
+ for (let gStep = 0, g = 0; gStep <= v; gStep++, g += step)
17
+ for (let bStep = 0, b = 0; bStep <= v; bStep++, b += step) {
18
+ if (r % (step * 2) == 0 && g % (step * 2) == 0 && b % (step * 2) == 0)
19
+ continue;
20
+ yield [Math.round(r) + min, Math.round(g) + min, Math.round(b) + min];
21
+ }
22
+ }
23
+ yield [-1, -1, -1];
24
+ }
25
+ function* colorGenerator2(data) {
26
+ const max = data?.max ?? 255;
27
+ const min = data?.min ?? 0;
28
+ function* _range(start = 0, end = 255) {
29
+ const range = (end - start) * 5;
30
+ for (let p = range; p > 1; p >>= 2) {
31
+ for (let i = 1, step = p >> 2; step * i < range; i++)
32
+ yield step * i;
33
+ }
34
+ }
35
+ const d = max - min;
36
+ let buf = [min, min, min];
37
+ const rangeGen = _range(min, max);
38
+ for (let num of rangeGen) {
39
+ buf = [min, min, min];
40
+ const p = Math.round(num / d);
41
+ const r = num % d;
42
+ if (p == 0) {
43
+ buf[0] = max;
44
+ buf[1] = min + r;
45
+ }
46
+ if (p == 1) {
47
+ buf[0] = max - r;
48
+ buf[1] = max;
49
+ }
50
+ if (p == 2) {
51
+ buf[1] = max;
52
+ buf[2] = min + r;
53
+ }
54
+ if (p == 3) {
55
+ buf[1] = max - r;
56
+ buf[2] = max;
57
+ }
58
+ if (p == 4) {
59
+ buf[2] = max;
60
+ buf[0] = min + r;
61
+ }
62
+ if (p == 5) {
63
+ buf[2] = max - r;
64
+ buf[0] = max;
65
+ }
66
+ yield buf;
67
+ }
68
+ yield [-1, -1, -1];
69
+ }
70
+ function colorGeneratorByCount2(value = 180, count = 100, index = 1) {
71
+ const step = Math.floor(value * 6 * index / count);
72
+ const p = Math.floor(step / value);
73
+ const z = Math.floor(step % value);
74
+ const r = (p == 0 || p == 5) ? value : (p == 1) ? value - z : (p == 4) ? z : 0;
75
+ const g = (p == 1 || p == 2) ? value : (p == 3) ? value - z : (p == 0) ? z : 0;
76
+ const b = (p == 3 || p == 4) ? value : (p == 5) ? value - z : (p == 2) ? z : 0;
77
+ return [r, g, b];
78
+ }
79
+ function colorGeneratorByCount(value = 180, count = 100, index = 1) {
80
+ const [r, g, b] = colorGeneratorByCount2(value, count, index);
81
+ return `rgb(${r},${g},${b})`;
82
+ }
83
+ function colorStringToRGBA(str) {
84
+ const rgbRegex = /^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i;
85
+ const rgbaRegex = /^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d*\.?\d+)\s*\)$/i;
86
+ let match = str.match(rgbRegex);
87
+ if (match) {
88
+ const [r, g, b] = match.slice(1).map(Number);
89
+ if (isValidRGBValue(r) && isValidRGBValue(g) && isValidRGBValue(b)) {
90
+ return [r, g, b, 1];
91
+ }
92
+ }
93
+ match = str.match(rgbaRegex);
94
+ if (match) {
95
+ const [r, g, b, a] = match.slice(1).map(Number);
96
+ if (isValidRGBValue(r) && isValidRGBValue(g) && isValidRGBValue(b) && isValidAlphaValue(a)) {
97
+ return [r, g, b, a];
98
+ }
99
+ }
100
+ return undefined;
101
+ }
102
+ function isValidRGBValue(value) {
103
+ return value >= 0 && value <= 255;
104
+ }
105
+ function isValidAlphaValue(value) {
106
+ return value >= 0 && value <= 1;
107
+ }
108
+ function toColorString(str) { if (colorStringToRGBA(str))
109
+ return str; throw `the string '${str}' is not valid 'rgb' or 'rgba' string`; }
110
+ function isSimilarColors(color1, color2, maxDelta = 32) {
111
+ let [r1, g1, b1] = typeof color1 == "string" ? colorStringToRGBA(color1) : color1;
112
+ let [r2, g2, b2] = typeof color2 == "string" ? colorStringToRGBA(color2) : color2;
113
+ let delta = Math.abs(r1 - r2) + Math.abs(g1 - g2) + Math.abs(b1 - b2);
114
+ return delta <= maxDelta;
115
+ }
@@ -0,0 +1,206 @@
1
+ import { const_Date } from "./core/BaseTypes";
2
+ export type DateString = `${number}-${number}-${number}`;
3
+ export type TimeStringHHMM = `${number}:${number}`;
4
+ export type TimeStringHHMMSS = `${number}:${number}:${number}`;
5
+ export type TimeStringHHMMSS_ms = `${number}:${number}:${number}.${number}`;
6
+ type TimeString_ = ` ${TimeStringHHMM | TimeStringHHMMSS | TimeStringHHMMSS_ms}`;
7
+ export type DateTimeString = `${DateString}${TimeString_ | ""}${"Z" | ""}`;
8
+ export { const_Date };
9
+ export declare const H1_S = 3600;
10
+ export declare const D1_S: number;
11
+ export declare const W1_S: number;
12
+ export declare const W1_MS: number;
13
+ export declare const D1_MS: number;
14
+ export declare const H1_MS: number;
15
+ export declare const M1_MS: number;
16
+ declare enum __E_TF {
17
+ S1 = 1,
18
+ S2 = 2,
19
+ S3 = 3,
20
+ S4 = 4,
21
+ S5 = 5,
22
+ S6 = 6,
23
+ S10 = 7,
24
+ S12 = 8,
25
+ S15 = 9,
26
+ S20 = 10,
27
+ S30 = 11,
28
+ M1 = 12,
29
+ M2 = 13,
30
+ M3 = 14,
31
+ M4 = 15,
32
+ M5 = 16,
33
+ M6 = 17,
34
+ M10 = 18,
35
+ M12 = 19,
36
+ M15 = 20,
37
+ M20 = 21,
38
+ M30 = 22,
39
+ H1 = 23,
40
+ H2 = 24,
41
+ H3 = 25,
42
+ H4 = 26,
43
+ H6 = 27,
44
+ H8 = 28,
45
+ H12 = 29,
46
+ D1 = 30,
47
+ W1 = 31,
48
+ MN1 = 32,
49
+ MN2 = 33,
50
+ MN3 = 34,
51
+ MN4 = 35,
52
+ MN6 = 36,
53
+ Y1 = 37
54
+ }
55
+ export interface IPeriod {
56
+ readonly msec: number;
57
+ readonly name: string;
58
+ }
59
+ type __E_TF_KEY = keyof typeof __E_TF;
60
+ export declare class TIME_UNIT {
61
+ readonly index: number;
62
+ readonly msec: number;
63
+ readonly sec: number;
64
+ readonly name: string;
65
+ readonly sign: string;
66
+ private static _lastIndex;
67
+ private constructor();
68
+ static readonly MSecond: TIME_UNIT;
69
+ static readonly Second: TIME_UNIT;
70
+ static readonly Minute: TIME_UNIT;
71
+ static readonly Hour: TIME_UNIT;
72
+ static readonly Day: TIME_UNIT;
73
+ static readonly Week: TIME_UNIT;
74
+ static readonly Month: TIME_UNIT;
75
+ static readonly Year: TIME_UNIT;
76
+ readonly [key: number]: void;
77
+ }
78
+ declare type Nominal<T, Name extends string> = T & {
79
+ readonly [Symbol.species]: Name;
80
+ };
81
+ export type TFIndex = Nominal<number, 'TFIndex'>;
82
+ export declare class TF implements IPeriod {
83
+ readonly sec: number;
84
+ readonly msec: number;
85
+ readonly name: string;
86
+ readonly unit: TIME_UNIT;
87
+ readonly unitCount: number;
88
+ readonly index: TFIndex;
89
+ readonly [key: number]: void;
90
+ valueOf(): number;
91
+ toString(): string;
92
+ private constructor();
93
+ private static constructFromSec;
94
+ static get<T extends string>(name: T): TF | (T extends __E_TF_KEY ? never : null);
95
+ static getAsserted(name: string): TF;
96
+ static fromName<T extends string>(name: T): TF | (T extends "D1" | "S1" | "S2" | "S3" | "S4" | "S5" | "S6" | "S10" | "S12" | "S15" | "S20" | "S30" | "M1" | "M2" | "M3" | "M4" | "M5" | "M6" | "M10" | "M12" | "M15" | "M20" | "M30" | "H1" | "H2" | "H3" | "H4" | "H6" | "H8" | "H12" | "W1" | "MN1" | "MN2" | "MN3" | "MN4" | "MN6" | "Y1" ? never : null);
97
+ static fromSec(value: number): TF | null;
98
+ static createCustomFromSec(sec: number): TF;
99
+ static createCustom(unit: TIME_UNIT, unitCount: number): TF;
100
+ static readonly all: readonly TF[];
101
+ private static readonly _mapBySec;
102
+ static readonly S1: TF;
103
+ static readonly S2: TF;
104
+ static readonly S3: TF;
105
+ static readonly S4: TF;
106
+ static readonly S5: TF;
107
+ static readonly S6: TF;
108
+ static readonly S10: TF;
109
+ static readonly S12: TF;
110
+ static readonly S15: TF;
111
+ static readonly S20: TF;
112
+ static readonly S30: TF;
113
+ static readonly M1: TF;
114
+ static readonly M2: TF;
115
+ static readonly M3: TF;
116
+ static readonly M4: TF;
117
+ static readonly M5: TF;
118
+ static readonly M6: TF;
119
+ static readonly M10: TF;
120
+ static readonly M12: TF;
121
+ static readonly M15: TF;
122
+ static readonly M20: TF;
123
+ static readonly M30: TF;
124
+ static readonly H1: TF;
125
+ static readonly H2: TF;
126
+ static readonly H3: TF;
127
+ static readonly H4: TF;
128
+ static readonly H6: TF;
129
+ static readonly H8: TF;
130
+ static readonly H12: TF;
131
+ static readonly D1: TF;
132
+ static readonly W1: TF;
133
+ static readonly MN1: TF;
134
+ static readonly MN2: TF;
135
+ static readonly MN3: TF;
136
+ static readonly MN4: TF;
137
+ static readonly MN6: TF;
138
+ static readonly Y1: TF;
139
+ static min(): never;
140
+ static min(...args: [TF, ...TF[]] | [[TF, ...TF[]]]): TF;
141
+ static min(...args: TF[] | [Iterable<TF>]): TF | null;
142
+ static max(): never;
143
+ static max(...args: [TF, ...TF[]] | [[TF, ...TF[]]]): TF;
144
+ static max(...args: TF[] | [Iterable<TF>]): TF | null;
145
+ }
146
+ declare class MyDate extends Date {
147
+ ToShiftedMsTime(shiftMs: number): Date;
148
+ }
149
+ export type MyDate_const = Omit<MyDate, keyof Date> & const_Date;
150
+ export declare class PeriodSpan {
151
+ readonly period: Period;
152
+ readonly index: number;
153
+ readonly [key: number]: void;
154
+ constructor(period: Period | TF, indexOrTime: number | const_Date);
155
+ next(): PeriodSpan;
156
+ prev(): PeriodSpan;
157
+ get startTime(): MyDate;
158
+ get endTime(): Date;
159
+ }
160
+ export declare class Period implements IPeriod {
161
+ readonly tf: TF;
162
+ get sec(): number;
163
+ get msec(): number;
164
+ get name(): string;
165
+ valueOf(): number;
166
+ readonly [key: number]: PeriodSpan;
167
+ span(time: const_Date): PeriodSpan;
168
+ constructor(tf: TF);
169
+ static Seconds(tf: TF): number;
170
+ static Name(tf: TF): string;
171
+ IndexFromTime(time: const_Date): number;
172
+ getStartTime(currentTime: const_Date): MyDate;
173
+ private static getW1Shift_ms;
174
+ static W1Shift_ms: number;
175
+ static year0: number;
176
+ static IndexFromTime(tf: TF, time: const_Date): number;
177
+ static StartTimeForIndex(tf: TF, index: number): MyDate;
178
+ static StartTime(tf: TF, currentTime: const_Date, shiftPeriods?: number): MyDate;
179
+ static EndTime(tf: TF, currentTime: const_Date): Date;
180
+ }
181
+ export declare function timeToStr_hhmmss_ms(date: const_Date): string;
182
+ export declare function timeToStr_hhmmss(date: const_Date): string;
183
+ export declare function timeToStr_yyyymmdd_hhmm(date: const_Date, dateDelim?: string): string;
184
+ export declare function timeToStr_yyyymmdd_hhmmss(date: const_Date, dateDelim?: string): string;
185
+ export declare function timeToStr_yyyymmdd_hhmmss_ms(date: const_Date, dateDelim?: string): string;
186
+ export declare function timeLocalToStr_hhmmss(date: const_Date): string;
187
+ export declare function timeLocalToStr_hhmmss_ms(date: const_Date): string;
188
+ export declare function timeLocalToStr_yyyymmdd(date: const_Date, dateDelim?: string): string;
189
+ export declare function timeLocalToStr_yyyymmdd_hhmm(date: const_Date, dateDelim?: string): string;
190
+ export declare function timeLocalToStr_yyyymmdd_hhmmss(date: const_Date, dateDelim?: string): string;
191
+ export declare function timeLocalToStr_yyyymmdd_hhmmss_ms(date: const_Date, dateDelim?: string): string;
192
+ export declare function timeToString_yyyymmdd_hhmm_offset(date: const_Date): string;
193
+ export declare function timeToString_yyyymmdd_hhmmss_offset(date: const_Date): string;
194
+ export declare function convertDatesToStrings(arg: any): any;
195
+ export declare function toPrintObject(arg: any): any;
196
+ export declare function durationToStr(duration_ms: number): string;
197
+ export declare function durationToStrNullable(duration_ms: number | null | undefined): string | null;
198
+ export declare function durationToStr_h_mm_ss(duration_ms: number): string;
199
+ export declare function durationToStr_h_mm_ss_ms(duration_ms: number): string;
200
+ export declare class CDelayer {
201
+ protected remainPause: number;
202
+ sleepAsync(pause_ms_getter: () => number | null): Promise<void>;
203
+ }
204
+ type NullableTime = const_Date | undefined | null;
205
+ export declare function MinTime<T1 extends NullableTime, T2 extends NullableTime>(time1: T1, time2: T2): T1 | NonNullable<T2>;
206
+ export declare function MaxTime<T1 extends NullableTime, T2 extends NullableTime>(time1: T1, time2: T2): T1 | NonNullable<T2>;