namirasoft-core 1.5.2 → 1.5.3

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 (57) hide show
  1. package/SKILL.md +223 -223
  2. package/dist/TimeOperation.d.ts +1 -0
  3. package/dist/TimeOperation.js +4 -0
  4. package/dist/TimeOperation.js.map +1 -1
  5. package/package.json +26 -26
  6. package/src/BaseDatabaseRow.ts +6 -6
  7. package/src/BaseLogger.ts +24 -24
  8. package/src/BaseMetaColumn.ts +17 -17
  9. package/src/BaseMetaDatabase.ts +30 -30
  10. package/src/BaseMetaTable.ts +40 -40
  11. package/src/BaseServer.ts +150 -150
  12. package/src/BaseUUID.ts +76 -76
  13. package/src/ByteOperation.ts +57 -57
  14. package/src/CacheService.ts +76 -76
  15. package/src/ColorOperation.ts +153 -153
  16. package/src/ConsoleOperation.ts +68 -68
  17. package/src/ConvertService.ts +123 -123
  18. package/src/CookieService.ts +33 -33
  19. package/src/Countries.ts +486 -486
  20. package/src/Country.ts +21 -21
  21. package/src/CountryOperation.ts +98 -98
  22. package/src/CronOperation.ts +121 -121
  23. package/src/EncodingOperation.ts +46 -46
  24. package/src/EnvService.ts +28 -28
  25. package/src/ErrorOperation.ts +13 -13
  26. package/src/FileOperation.ts +60 -60
  27. package/src/FilterItem.ts +117 -117
  28. package/src/FilterItemColumnType.ts +9 -9
  29. package/src/FilterItemOperator.ts +52 -52
  30. package/src/GeoOperation.ts +18 -18
  31. package/src/HTTPError.ts +8 -8
  32. package/src/HTTPMethod.ts +7 -7
  33. package/src/HashOperation.ts +24 -24
  34. package/src/ILogger.ts +17 -17
  35. package/src/IStorage.ts +5 -5
  36. package/src/IStorageCookie.ts +52 -52
  37. package/src/IStorageJsonFile.ts +45 -45
  38. package/src/IStorageLocal.ts +16 -16
  39. package/src/IStorageMemoryDedicated.ts +17 -17
  40. package/src/IStorageMemoryShared.ts +21 -21
  41. package/src/IStorageSession.ts +16 -16
  42. package/src/LogLevel.ts +11 -11
  43. package/src/NamingConvention.ts +199 -199
  44. package/src/ObjectService.ts +27 -27
  45. package/src/PackageService.ts +76 -76
  46. package/src/PasswordOperation.ts +12 -12
  47. package/src/PhoneOperation.ts +8 -8
  48. package/src/PriceOperation.ts +20 -20
  49. package/src/SearchOperation.ts +31 -31
  50. package/src/SetTimeouService.ts +32 -32
  51. package/src/SortItem.ts +88 -88
  52. package/src/StringOperation.ts +22 -22
  53. package/src/TimeOperation.ts +303 -299
  54. package/src/TimeUnitOperation.ts +82 -82
  55. package/src/URLOperation.ts +66 -66
  56. package/src/VersionOperation.ts +46 -46
  57. package/src/index.ts +52 -52
@@ -1,200 +1,200 @@
1
- export class NamingConvention
2
- {
3
- public static abbreviations: string[] = [
4
- "ID", "AWS", "NWS", "FTP", "SFTP", "SMTP", "API", "AI", "CPU", "DB", "DNS", "HTML", "CSS", "JSON", "HTTP", "HTTPS", "IP", "YAML", "YML", "NFS", "OS", "SQL", "TCP", "UDP", "SSL", "TLS", "UI", "UID",
5
- "URL", "URI", "UTC", "XML", "CLI", "FIFO", "LIFO", "GPU", "GCP", "SMS",
6
- "EBS", "EFS", "S3",
7
- "KB", "MB", "GB", "TB", "PB",
8
- "SSO", "OIDC",
9
- "LLM", "SID", "ERP",
10
- "GitHub", "GitLab",
11
- ];
12
- static combineSingleCharacters(words: string[])
13
- {
14
- let combined = [];
15
- let single_found: boolean = false;
16
- for (let i = 0; i < words.length; i++)
17
- {
18
- let word = words[i];
19
- if (word)
20
- {
21
- if (word.length > 1)
22
- {
23
- combined.push(word);
24
- single_found = false;
25
- }
26
- else
27
- {
28
- if (i == 0 || !single_found)
29
- {
30
- combined.push(word);
31
- single_found = true;
32
- }
33
- else
34
- {
35
- combined[combined.length - 1] += word;
36
- if (this.abbreviations.includes(combined[combined.length - 1]))
37
- single_found = false;
38
- }
39
- }
40
- }
41
- }
42
- return combined;
43
- }
44
- public static formatter_lower = (word: string) =>
45
- {
46
- if (word)
47
- return word.toString().toLowerCase();
48
- return "";
49
- };
50
- public static formatter_upper = (word: string) =>
51
- {
52
- if (word)
53
- return word.toString().toUpperCase();
54
- return "";
55
- };
56
- public static formatter_pascal = (word: string) =>
57
- {
58
- if (word)
59
- if (this.abbreviations.includes(word.toString().toUpperCase()))
60
- return word.toString().toUpperCase();
61
- if (word)
62
- return word[0].toUpperCase() + word.substring(1).toLowerCase();
63
- return "";
64
- };
65
- public static formatter_camel = (word: string, index: number) =>
66
- {
67
- if (word)
68
- if (this.abbreviations.includes(word.toString().toUpperCase()))
69
- return word.toString().toUpperCase();
70
- if (index == 0)
71
- return NamingConvention.formatter_lower(word);
72
- return NamingConvention.formatter_pascal(word);
73
- };
74
- public static formatter_sentence = (word: string, index: number) =>
75
- {
76
- if (word)
77
- if (this.abbreviations.includes(word.toString().toUpperCase()))
78
- return word.toString().toUpperCase();
79
- if (index != 0)
80
- return NamingConvention.formatter_lower(word);
81
- return NamingConvention.formatter_pascal(word);
82
- };
83
- public static splitter_multi = (name: string, ...splitters: ((name: string) => string[])[]) =>
84
- {
85
- let ans = [name];
86
- for (let i = 0; i < splitters.length; i++)
87
- {
88
- const splitter = splitters[i];
89
- let words = [];
90
- for (let word of ans)
91
- if (word)
92
- if (this.abbreviations.includes(word.toString().toUpperCase()))
93
- words.push(word);
94
- else
95
- words.push(...splitter(word));
96
- ans = words;
97
- }
98
- return ans;
99
- };
100
- public static splitter_normal = (name: string, delimiter: string) =>
101
- {
102
- return name.split(delimiter);
103
- };
104
- public static splitter_pascal = (name: string, delimiter: string) =>
105
- {
106
- return NamingConvention.splitter_multi(name, NamingConvention.splitter_uppercase, (w) => NamingConvention.splitter_normal(w, delimiter));
107
- };
108
- public static splitter_uppercase = (name: string) =>
109
- {
110
- let ans = name.split(/(?=[A-Z])/);
111
- ans = NamingConvention.combineSingleCharacters(ans);
112
- return ans;
113
- };
114
- public static splitter_none = (name: string) =>
115
- {
116
- return [name];
117
- };
118
- public static splitter_all = (name: string) =>
119
- {
120
- return NamingConvention.splitter_multi(name,
121
- (w) => NamingConvention.splitter_normal(w, ' '),
122
- (w) => NamingConvention.splitter_normal(w, '/'),
123
- (w) => NamingConvention.splitter_normal(w, '-'),
124
- (w) => NamingConvention.splitter_normal(w, '_'),
125
- (w) => NamingConvention.splitter_normal(w, '\\'),
126
- (w) => NamingConvention.splitter_normal(w, '.'),
127
- (w) => NamingConvention.splitter_normal(w, '.'),
128
- NamingConvention.splitter_uppercase
129
- );
130
- };
131
- public static auto: NamingConvention = new NamingConvention("auto", "", false, () => { throw new Error("NamingConvention.auto can not be used to format") }, NamingConvention.splitter_all);
132
-
133
- public static lower_case: NamingConvention = new NamingConvention("lowercase", "", false, NamingConvention.formatter_lower, NamingConvention.splitter_none);
134
- public static UPPER_CASE: NamingConvention = new NamingConvention("UPPERCASE", "", false, NamingConvention.formatter_upper, NamingConvention.splitter_none);
135
- public static Pascal_Case: NamingConvention = new NamingConvention("PascalCase", "", true, NamingConvention.formatter_pascal, NamingConvention.splitter_uppercase);
136
- public static camel_Case: NamingConvention = new NamingConvention("camelCase", "", true, NamingConvention.formatter_camel, NamingConvention.splitter_uppercase);
137
- public static First_word_case: NamingConvention = new NamingConvention("Firstwordcase", "", false, NamingConvention.formatter_sentence, NamingConvention.splitter_none);
138
-
139
- public static lower_case_underscore: NamingConvention = new NamingConvention("snake_case", "_", false, NamingConvention.formatter_lower, NamingConvention.splitter_normal);
140
- public static UPPER_CASE_UNDERSCORE: NamingConvention = new NamingConvention("SNAKE_CASE", "_", false, NamingConvention.formatter_upper, NamingConvention.splitter_normal);
141
- public static Pascal_Case_Underscore: NamingConvention = new NamingConvention("Pascal_CASE", "_", true, NamingConvention.formatter_pascal, NamingConvention.splitter_pascal);
142
- public static camel_Case_Underscore: NamingConvention = new NamingConvention("camel_Case", "_", true, NamingConvention.formatter_camel, NamingConvention.splitter_normal);
143
- public static First_word_case_underscore: NamingConvention = new NamingConvention("First_word_case", "_", false, NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
144
-
145
- public static lower_case_dash: NamingConvention = new NamingConvention("kebab-case", "-", false, NamingConvention.formatter_lower, NamingConvention.splitter_normal);
146
- public static UPPER_CASE_DASH: NamingConvention = new NamingConvention("UPPER-CASE", "-", false, NamingConvention.formatter_upper, NamingConvention.splitter_normal);
147
- public static Pascal_Case_Dash: NamingConvention = new NamingConvention("Pascal-Case", "-", true, NamingConvention.formatter_pascal, NamingConvention.splitter_pascal);
148
- public static camel_Case_Dash: NamingConvention = new NamingConvention("camel-Case", "-", true, NamingConvention.formatter_camel, NamingConvention.splitter_normal);
149
- public static First_word_case_dash: NamingConvention = new NamingConvention("First-word-case", "-", false, NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
150
-
151
- public static lower_case_dot: NamingConvention = new NamingConvention("domain.case", ".", false, NamingConvention.formatter_lower, NamingConvention.splitter_normal);
152
- public static UPPER_CASE_DOT: NamingConvention = new NamingConvention("UPPER.CASE", ".", false, NamingConvention.formatter_upper, NamingConvention.splitter_normal);
153
- public static Pascal_Case_Dot: NamingConvention = new NamingConvention("Pascal.Case", ".", true, NamingConvention.formatter_pascal, NamingConvention.splitter_pascal);
154
- public static camel_Case_Dot: NamingConvention = new NamingConvention("camel.Case", ".", true, NamingConvention.formatter_camel, NamingConvention.splitter_normal);
155
- public static First_word_case_dot: NamingConvention = new NamingConvention("First.word.case", ".", false, NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
156
-
157
- public static lower_case_space: NamingConvention = new NamingConvention("lower case", " ", false, NamingConvention.formatter_lower, NamingConvention.splitter_normal);
158
- public static UPPER_CASE_SPACE: NamingConvention = new NamingConvention("UPPRE CASE", " ", false, NamingConvention.formatter_upper, NamingConvention.splitter_normal);
159
- public static Pascal_Case_Space: NamingConvention = new NamingConvention("Title Case", " ", true, NamingConvention.formatter_pascal, NamingConvention.splitter_pascal);
160
- public static camel_Case_Space: NamingConvention = new NamingConvention("camel Case", " ", true, NamingConvention.formatter_camel, NamingConvention.splitter_normal);
161
- public static First_word_case_space: NamingConvention = new NamingConvention("Sentence case", " ", false, NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
162
-
163
- public static lower_case_slash: NamingConvention = new NamingConvention("path/case", "/", false, NamingConvention.formatter_lower, NamingConvention.splitter_normal);
164
- public static UPPER_CASE_SLASH: NamingConvention = new NamingConvention("UPPER/CASE", "/", false, NamingConvention.formatter_upper, NamingConvention.splitter_normal);
165
- public static Pascal_Case_Slash: NamingConvention = new NamingConvention("Pascal/Case", "/", true, NamingConvention.formatter_pascal, NamingConvention.splitter_pascal);
166
- public static camel_Case_Slash: NamingConvention = new NamingConvention("camel/Case", "/", true, NamingConvention.formatter_camel, NamingConvention.splitter_normal);
167
- public static First_word_case_slash: NamingConvention = new NamingConvention("First/word/case", "/", false, NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
168
- public name: string;
169
- public delimiter: string;
170
- public revertable: boolean;
171
- formatter: (word: string, index: number) => string;
172
- splitter: (name: string, delimiter: string) => string[];
173
- constructor(name: string, delimiter: string, revertable: boolean, formatter: (word: string, index: number) => string, splitter: (name: string, delimiter: string) => string[])
174
- {
175
- this.name = name;
176
- this.delimiter = delimiter;
177
- this.revertable = revertable;
178
- this.formatter = formatter;
179
- this.splitter = splitter;
180
- }
181
- getWords(name: string)
182
- {
183
- let ans = this.splitter(name, this.delimiter);
184
- ans = ans.filter(w => w);
185
- return ans;
186
- }
187
- convertByWords(words: string[], revertable: boolean = true)
188
- {
189
- for (let i = 0; i < words.length; i++)
190
- words[i] = this.formatter(words[i], i);
191
- if (this.revertable || !revertable)
192
- words = NamingConvention.combineSingleCharacters(words);
193
- return words.join(this.delimiter);
194
- }
195
- convert(name: string, to: NamingConvention, revertable: boolean = true)
196
- {
197
- let words = this.getWords(name);
198
- return to.convertByWords(words, revertable);
199
- }
1
+ export class NamingConvention
2
+ {
3
+ public static abbreviations: string[] = [
4
+ "ID", "AWS", "NWS", "FTP", "SFTP", "SMTP", "API", "AI", "CPU", "DB", "DNS", "HTML", "CSS", "JSON", "HTTP", "HTTPS", "IP", "YAML", "YML", "NFS", "OS", "SQL", "TCP", "UDP", "SSL", "TLS", "UI", "UID",
5
+ "URL", "URI", "UTC", "XML", "CLI", "FIFO", "LIFO", "GPU", "GCP", "SMS",
6
+ "EBS", "EFS", "S3",
7
+ "KB", "MB", "GB", "TB", "PB",
8
+ "SSO", "OIDC",
9
+ "LLM", "SID", "ERP",
10
+ "GitHub", "GitLab",
11
+ ];
12
+ static combineSingleCharacters(words: string[])
13
+ {
14
+ let combined = [];
15
+ let single_found: boolean = false;
16
+ for (let i = 0; i < words.length; i++)
17
+ {
18
+ let word = words[i];
19
+ if (word)
20
+ {
21
+ if (word.length > 1)
22
+ {
23
+ combined.push(word);
24
+ single_found = false;
25
+ }
26
+ else
27
+ {
28
+ if (i == 0 || !single_found)
29
+ {
30
+ combined.push(word);
31
+ single_found = true;
32
+ }
33
+ else
34
+ {
35
+ combined[combined.length - 1] += word;
36
+ if (this.abbreviations.includes(combined[combined.length - 1]))
37
+ single_found = false;
38
+ }
39
+ }
40
+ }
41
+ }
42
+ return combined;
43
+ }
44
+ public static formatter_lower = (word: string) =>
45
+ {
46
+ if (word)
47
+ return word.toString().toLowerCase();
48
+ return "";
49
+ };
50
+ public static formatter_upper = (word: string) =>
51
+ {
52
+ if (word)
53
+ return word.toString().toUpperCase();
54
+ return "";
55
+ };
56
+ public static formatter_pascal = (word: string) =>
57
+ {
58
+ if (word)
59
+ if (this.abbreviations.includes(word.toString().toUpperCase()))
60
+ return word.toString().toUpperCase();
61
+ if (word)
62
+ return word[0].toUpperCase() + word.substring(1).toLowerCase();
63
+ return "";
64
+ };
65
+ public static formatter_camel = (word: string, index: number) =>
66
+ {
67
+ if (word)
68
+ if (this.abbreviations.includes(word.toString().toUpperCase()))
69
+ return word.toString().toUpperCase();
70
+ if (index == 0)
71
+ return NamingConvention.formatter_lower(word);
72
+ return NamingConvention.formatter_pascal(word);
73
+ };
74
+ public static formatter_sentence = (word: string, index: number) =>
75
+ {
76
+ if (word)
77
+ if (this.abbreviations.includes(word.toString().toUpperCase()))
78
+ return word.toString().toUpperCase();
79
+ if (index != 0)
80
+ return NamingConvention.formatter_lower(word);
81
+ return NamingConvention.formatter_pascal(word);
82
+ };
83
+ public static splitter_multi = (name: string, ...splitters: ((name: string) => string[])[]) =>
84
+ {
85
+ let ans = [name];
86
+ for (let i = 0; i < splitters.length; i++)
87
+ {
88
+ const splitter = splitters[i];
89
+ let words = [];
90
+ for (let word of ans)
91
+ if (word)
92
+ if (this.abbreviations.includes(word.toString().toUpperCase()))
93
+ words.push(word);
94
+ else
95
+ words.push(...splitter(word));
96
+ ans = words;
97
+ }
98
+ return ans;
99
+ };
100
+ public static splitter_normal = (name: string, delimiter: string) =>
101
+ {
102
+ return name.split(delimiter);
103
+ };
104
+ public static splitter_pascal = (name: string, delimiter: string) =>
105
+ {
106
+ return NamingConvention.splitter_multi(name, NamingConvention.splitter_uppercase, (w) => NamingConvention.splitter_normal(w, delimiter));
107
+ };
108
+ public static splitter_uppercase = (name: string) =>
109
+ {
110
+ let ans = name.split(/(?=[A-Z])/);
111
+ ans = NamingConvention.combineSingleCharacters(ans);
112
+ return ans;
113
+ };
114
+ public static splitter_none = (name: string) =>
115
+ {
116
+ return [name];
117
+ };
118
+ public static splitter_all = (name: string) =>
119
+ {
120
+ return NamingConvention.splitter_multi(name,
121
+ (w) => NamingConvention.splitter_normal(w, ' '),
122
+ (w) => NamingConvention.splitter_normal(w, '/'),
123
+ (w) => NamingConvention.splitter_normal(w, '-'),
124
+ (w) => NamingConvention.splitter_normal(w, '_'),
125
+ (w) => NamingConvention.splitter_normal(w, '\\'),
126
+ (w) => NamingConvention.splitter_normal(w, '.'),
127
+ (w) => NamingConvention.splitter_normal(w, '.'),
128
+ NamingConvention.splitter_uppercase
129
+ );
130
+ };
131
+ public static auto: NamingConvention = new NamingConvention("auto", "", false, () => { throw new Error("NamingConvention.auto can not be used to format") }, NamingConvention.splitter_all);
132
+
133
+ public static lower_case: NamingConvention = new NamingConvention("lowercase", "", false, NamingConvention.formatter_lower, NamingConvention.splitter_none);
134
+ public static UPPER_CASE: NamingConvention = new NamingConvention("UPPERCASE", "", false, NamingConvention.formatter_upper, NamingConvention.splitter_none);
135
+ public static Pascal_Case: NamingConvention = new NamingConvention("PascalCase", "", true, NamingConvention.formatter_pascal, NamingConvention.splitter_uppercase);
136
+ public static camel_Case: NamingConvention = new NamingConvention("camelCase", "", true, NamingConvention.formatter_camel, NamingConvention.splitter_uppercase);
137
+ public static First_word_case: NamingConvention = new NamingConvention("Firstwordcase", "", false, NamingConvention.formatter_sentence, NamingConvention.splitter_none);
138
+
139
+ public static lower_case_underscore: NamingConvention = new NamingConvention("snake_case", "_", false, NamingConvention.formatter_lower, NamingConvention.splitter_normal);
140
+ public static UPPER_CASE_UNDERSCORE: NamingConvention = new NamingConvention("SNAKE_CASE", "_", false, NamingConvention.formatter_upper, NamingConvention.splitter_normal);
141
+ public static Pascal_Case_Underscore: NamingConvention = new NamingConvention("Pascal_CASE", "_", true, NamingConvention.formatter_pascal, NamingConvention.splitter_pascal);
142
+ public static camel_Case_Underscore: NamingConvention = new NamingConvention("camel_Case", "_", true, NamingConvention.formatter_camel, NamingConvention.splitter_normal);
143
+ public static First_word_case_underscore: NamingConvention = new NamingConvention("First_word_case", "_", false, NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
144
+
145
+ public static lower_case_dash: NamingConvention = new NamingConvention("kebab-case", "-", false, NamingConvention.formatter_lower, NamingConvention.splitter_normal);
146
+ public static UPPER_CASE_DASH: NamingConvention = new NamingConvention("UPPER-CASE", "-", false, NamingConvention.formatter_upper, NamingConvention.splitter_normal);
147
+ public static Pascal_Case_Dash: NamingConvention = new NamingConvention("Pascal-Case", "-", true, NamingConvention.formatter_pascal, NamingConvention.splitter_pascal);
148
+ public static camel_Case_Dash: NamingConvention = new NamingConvention("camel-Case", "-", true, NamingConvention.formatter_camel, NamingConvention.splitter_normal);
149
+ public static First_word_case_dash: NamingConvention = new NamingConvention("First-word-case", "-", false, NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
150
+
151
+ public static lower_case_dot: NamingConvention = new NamingConvention("domain.case", ".", false, NamingConvention.formatter_lower, NamingConvention.splitter_normal);
152
+ public static UPPER_CASE_DOT: NamingConvention = new NamingConvention("UPPER.CASE", ".", false, NamingConvention.formatter_upper, NamingConvention.splitter_normal);
153
+ public static Pascal_Case_Dot: NamingConvention = new NamingConvention("Pascal.Case", ".", true, NamingConvention.formatter_pascal, NamingConvention.splitter_pascal);
154
+ public static camel_Case_Dot: NamingConvention = new NamingConvention("camel.Case", ".", true, NamingConvention.formatter_camel, NamingConvention.splitter_normal);
155
+ public static First_word_case_dot: NamingConvention = new NamingConvention("First.word.case", ".", false, NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
156
+
157
+ public static lower_case_space: NamingConvention = new NamingConvention("lower case", " ", false, NamingConvention.formatter_lower, NamingConvention.splitter_normal);
158
+ public static UPPER_CASE_SPACE: NamingConvention = new NamingConvention("UPPRE CASE", " ", false, NamingConvention.formatter_upper, NamingConvention.splitter_normal);
159
+ public static Pascal_Case_Space: NamingConvention = new NamingConvention("Title Case", " ", true, NamingConvention.formatter_pascal, NamingConvention.splitter_pascal);
160
+ public static camel_Case_Space: NamingConvention = new NamingConvention("camel Case", " ", true, NamingConvention.formatter_camel, NamingConvention.splitter_normal);
161
+ public static First_word_case_space: NamingConvention = new NamingConvention("Sentence case", " ", false, NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
162
+
163
+ public static lower_case_slash: NamingConvention = new NamingConvention("path/case", "/", false, NamingConvention.formatter_lower, NamingConvention.splitter_normal);
164
+ public static UPPER_CASE_SLASH: NamingConvention = new NamingConvention("UPPER/CASE", "/", false, NamingConvention.formatter_upper, NamingConvention.splitter_normal);
165
+ public static Pascal_Case_Slash: NamingConvention = new NamingConvention("Pascal/Case", "/", true, NamingConvention.formatter_pascal, NamingConvention.splitter_pascal);
166
+ public static camel_Case_Slash: NamingConvention = new NamingConvention("camel/Case", "/", true, NamingConvention.formatter_camel, NamingConvention.splitter_normal);
167
+ public static First_word_case_slash: NamingConvention = new NamingConvention("First/word/case", "/", false, NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
168
+ public name: string;
169
+ public delimiter: string;
170
+ public revertable: boolean;
171
+ formatter: (word: string, index: number) => string;
172
+ splitter: (name: string, delimiter: string) => string[];
173
+ constructor(name: string, delimiter: string, revertable: boolean, formatter: (word: string, index: number) => string, splitter: (name: string, delimiter: string) => string[])
174
+ {
175
+ this.name = name;
176
+ this.delimiter = delimiter;
177
+ this.revertable = revertable;
178
+ this.formatter = formatter;
179
+ this.splitter = splitter;
180
+ }
181
+ getWords(name: string)
182
+ {
183
+ let ans = this.splitter(name, this.delimiter);
184
+ ans = ans.filter(w => w);
185
+ return ans;
186
+ }
187
+ convertByWords(words: string[], revertable: boolean = true)
188
+ {
189
+ for (let i = 0; i < words.length; i++)
190
+ words[i] = this.formatter(words[i], i);
191
+ if (this.revertable || !revertable)
192
+ words = NamingConvention.combineSingleCharacters(words);
193
+ return words.join(this.delimiter);
194
+ }
195
+ convert(name: string, to: NamingConvention, revertable: boolean = true)
196
+ {
197
+ let words = this.getWords(name);
198
+ return to.convertByWords(words, revertable);
199
+ }
200
200
  }
@@ -1,28 +1,28 @@
1
- import { ConvertService } from "./ConvertService";
2
- import { ParsedNameValue } from "./ParsedNameValue";
3
-
4
- export class ObjectService extends ConvertService
5
- {
6
- static isClass(obj: any)
7
- {
8
- return typeof obj === 'function' && /^\s*class\s+/.test(obj.toString());
9
- }
10
- private object: ParsedNameValue;
11
- constructor(object: ParsedNameValue, mandatory: boolean = false)
12
- {
13
- super(mandatory);
14
- this.object = object;
15
- }
16
- override getNullString()
17
- {
18
- let ans: string | null = null;
19
- if (Array.isArray(this.object))
20
- {
21
- if (this.object.length > 0)
22
- ans = this.object.join(",");
23
- }
24
- else if (this.object != null && this.object != undefined)
25
- ans = this.object + "";
26
- return ans;
27
- }
1
+ import { ConvertService } from "./ConvertService";
2
+ import { ParsedNameValue } from "./ParsedNameValue";
3
+
4
+ export class ObjectService extends ConvertService
5
+ {
6
+ static isClass(obj: any)
7
+ {
8
+ return typeof obj === 'function' && /^\s*class\s+/.test(obj.toString());
9
+ }
10
+ private object: ParsedNameValue;
11
+ constructor(object: ParsedNameValue, mandatory: boolean = false)
12
+ {
13
+ super(mandatory);
14
+ this.object = object;
15
+ }
16
+ override getNullString()
17
+ {
18
+ let ans: string | null = null;
19
+ if (Array.isArray(this.object))
20
+ {
21
+ if (this.object.length > 0)
22
+ ans = this.object.join(",");
23
+ }
24
+ else if (this.object != null && this.object != undefined)
25
+ ans = this.object + "";
26
+ return ans;
27
+ }
28
28
  }
@@ -1,77 +1,77 @@
1
- let fs: any;
2
- if (typeof window === 'undefined')
3
- fs = require('fs');
4
- import { FileOperation } from "./FileOperation";
5
-
6
- export class PackageService
7
- {
8
- static MainJson: any = null;
9
- static ThisJson: any = null;
10
- static get(path: string): PackageService
11
- {
12
- if (path)
13
- {
14
- const json = JSON.parse(fs.readFileSync(path, 'utf8'));
15
- if (json)
16
- return new PackageService(path, json);
17
- }
18
- throw new Error("Coundn't find package");
19
- }
20
- static getMain(): PackageService
21
- {
22
- if (PackageService.MainJson)
23
- return new PackageService("", PackageService.MainJson);
24
- const paths = FileOperation.findUp('package.json');
25
- if (paths)
26
- return this.get(paths[paths.length - 1]);
27
- throw new Error("Coundn't find package");
28
- }
29
- static getThis(): PackageService
30
- {
31
- if (PackageService.ThisJson)
32
- return new PackageService("", PackageService.ThisJson);
33
- const paths = FileOperation.findUp('package.json');
34
- if (paths)
35
- return this.get(paths[0]);
36
- throw new Error("Coundn't find package");
37
- }
38
- private path: string;
39
- private json: any;
40
- constructor(path: string, json: any)
41
- {
42
- this.json = json;
43
- this.path = path;
44
- }
45
- getPath(): string
46
- {
47
- return this.path;
48
- }
49
- getJson(): string
50
- {
51
- return this.json;
52
- }
53
- getName(): string
54
- {
55
- return this.json.name;
56
- }
57
- getTitle(): string
58
- {
59
- return this.json.title;
60
- }
61
- getDescription(): string
62
- {
63
- return this.json.description;
64
- }
65
- getIcon(): string
66
- {
67
- return this.json.icon;
68
- }
69
- getLogo(): string
70
- {
71
- return this.json.logo;
72
- }
73
- getVersion(): string
74
- {
75
- return this.json.version;
76
- }
1
+ let fs: any;
2
+ if (typeof window === 'undefined')
3
+ fs = require('fs');
4
+ import { FileOperation } from "./FileOperation";
5
+
6
+ export class PackageService
7
+ {
8
+ static MainJson: any = null;
9
+ static ThisJson: any = null;
10
+ static get(path: string): PackageService
11
+ {
12
+ if (path)
13
+ {
14
+ const json = JSON.parse(fs.readFileSync(path, 'utf8'));
15
+ if (json)
16
+ return new PackageService(path, json);
17
+ }
18
+ throw new Error("Coundn't find package");
19
+ }
20
+ static getMain(): PackageService
21
+ {
22
+ if (PackageService.MainJson)
23
+ return new PackageService("", PackageService.MainJson);
24
+ const paths = FileOperation.findUp('package.json');
25
+ if (paths)
26
+ return this.get(paths[paths.length - 1]);
27
+ throw new Error("Coundn't find package");
28
+ }
29
+ static getThis(): PackageService
30
+ {
31
+ if (PackageService.ThisJson)
32
+ return new PackageService("", PackageService.ThisJson);
33
+ const paths = FileOperation.findUp('package.json');
34
+ if (paths)
35
+ return this.get(paths[0]);
36
+ throw new Error("Coundn't find package");
37
+ }
38
+ private path: string;
39
+ private json: any;
40
+ constructor(path: string, json: any)
41
+ {
42
+ this.json = json;
43
+ this.path = path;
44
+ }
45
+ getPath(): string
46
+ {
47
+ return this.path;
48
+ }
49
+ getJson(): string
50
+ {
51
+ return this.json;
52
+ }
53
+ getName(): string
54
+ {
55
+ return this.json.name;
56
+ }
57
+ getTitle(): string
58
+ {
59
+ return this.json.title;
60
+ }
61
+ getDescription(): string
62
+ {
63
+ return this.json.description;
64
+ }
65
+ getIcon(): string
66
+ {
67
+ return this.json.icon;
68
+ }
69
+ getLogo(): string
70
+ {
71
+ return this.json.logo;
72
+ }
73
+ getVersion(): string
74
+ {
75
+ return this.json.version;
76
+ }
77
77
  }
@@ -1,13 +1,13 @@
1
- import crypto from "crypto";
2
-
3
- export class PasswordOperation
4
- {
5
- static new(length: number): string
6
- {
7
- return crypto.randomBytes(length)
8
- .toString('base64')
9
- .slice(0, length)
10
- .replace(/\+/g, '0')
11
- .replace(/\//g, '0');
12
- }
1
+ import crypto from "crypto";
2
+
3
+ export class PasswordOperation
4
+ {
5
+ static new(length: number): string
6
+ {
7
+ return crypto.randomBytes(length)
8
+ .toString('base64')
9
+ .slice(0, length)
10
+ .replace(/\+/g, '0')
11
+ .replace(/\//g, '0');
12
+ }
13
13
  }