namirasoft-core 1.4.12 → 1.4.13
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/dist/EncryptionOperation.js +17 -7
- package/dist/EncryptionOperation.js.map +1 -1
- package/dist/HashOperation.js +17 -7
- package/dist/HashOperation.js.map +1 -1
- package/dist/PhoneOperation.js +17 -7
- package/dist/PhoneOperation.js.map +1 -1
- package/dist/SortItem.d.ts +24 -0
- package/dist/SortItem.js +75 -0
- package/dist/SortItem.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/BaseDatabaseRow.ts +6 -6
- package/src/BaseMetaColumn.ts +13 -13
- package/src/BaseMetaTable.ts +24 -24
- package/src/BaseServer.ts +107 -107
- package/src/CacheService.ts +57 -57
- package/src/ConsoleOperation.ts +68 -68
- package/src/ConvertService.ts +100 -100
- package/src/CookieService.ts +33 -33
- package/src/Countries.ts +486 -486
- package/src/Country.ts +21 -21
- package/src/CountryOperation.ts +98 -98
- package/src/EncodingOperation.ts +12 -12
- package/src/EncryptionOperation.ts +40 -40
- package/src/EnvService.ts +22 -22
- package/src/ErrorOperation.ts +13 -13
- package/src/FileOperation.ts +57 -57
- package/src/FilterItem.ts +128 -128
- package/src/FilterItemColumnType.ts +6 -6
- package/src/FilterItemOperator.ts +51 -51
- package/src/GeoOperation.ts +18 -18
- package/src/HTTPError.ts +8 -8
- package/src/HTTPMethod.ts +6 -6
- package/src/HashOperation.ts +24 -24
- package/src/IStorage.ts +5 -5
- package/src/IStorageCookie.ts +52 -52
- package/src/IStorageJsonFile.ts +45 -45
- package/src/IStorageLocal.ts +16 -16
- package/src/IStorageMemory.ts +17 -17
- package/src/NamingConvention.ts +107 -107
- package/src/ObjectService.ts +27 -27
- package/src/PackageService.ts +76 -76
- package/src/PhoneOperation.ts +8 -8
- package/src/PriceOperation.ts +18 -18
- package/src/RegexTemplate.ts +7 -7
- package/src/SearchOperation.ts +29 -29
- package/src/SortItem.ts +89 -0
- package/src/StringOperation.ts +18 -18
- package/src/TimeOperation.ts +262 -262
- package/src/URLOperation.ts +54 -54
- package/src/VersionOperation.ts +46 -46
- package/src/index.ts +40 -39
package/src/IStorageJsonFile.ts
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import { IStorage } from "./IStorage";
|
|
3
|
-
|
|
4
|
-
export class IStorageJsonFile extends IStorage
|
|
5
|
-
{
|
|
6
|
-
private data: any;
|
|
7
|
-
private base_path: string;
|
|
8
|
-
constructor(base_path: string)
|
|
9
|
-
{
|
|
10
|
-
super();
|
|
11
|
-
this.base_path = base_path;
|
|
12
|
-
}
|
|
13
|
-
static data: { [name: string]: string } = {};
|
|
14
|
-
private load(): void
|
|
15
|
-
{
|
|
16
|
-
try
|
|
17
|
-
{
|
|
18
|
-
let content = fs.readFileSync(this.base_path, { encoding: "utf8" });
|
|
19
|
-
this.data = JSON.parse(content);
|
|
20
|
-
} catch (error)
|
|
21
|
-
{
|
|
22
|
-
this.data = {};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
private save(): void
|
|
26
|
-
{
|
|
27
|
-
fs.writeFileSync(this.base_path, JSON.stringify(this.data));
|
|
28
|
-
}
|
|
29
|
-
override get(name: string, defaultValue: string)
|
|
30
|
-
{
|
|
31
|
-
this.load();
|
|
32
|
-
return this.data[name] ?? defaultValue;
|
|
33
|
-
}
|
|
34
|
-
override set(name: string, value: string)
|
|
35
|
-
{
|
|
36
|
-
this.load();
|
|
37
|
-
this.data[name] = value;
|
|
38
|
-
this.save();
|
|
39
|
-
}
|
|
40
|
-
override del(name: string)
|
|
41
|
-
{
|
|
42
|
-
this.load();
|
|
43
|
-
delete this.data[name];
|
|
44
|
-
this.save();
|
|
45
|
-
}
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { IStorage } from "./IStorage";
|
|
3
|
+
|
|
4
|
+
export class IStorageJsonFile extends IStorage
|
|
5
|
+
{
|
|
6
|
+
private data: any;
|
|
7
|
+
private base_path: string;
|
|
8
|
+
constructor(base_path: string)
|
|
9
|
+
{
|
|
10
|
+
super();
|
|
11
|
+
this.base_path = base_path;
|
|
12
|
+
}
|
|
13
|
+
static data: { [name: string]: string } = {};
|
|
14
|
+
private load(): void
|
|
15
|
+
{
|
|
16
|
+
try
|
|
17
|
+
{
|
|
18
|
+
let content = fs.readFileSync(this.base_path, { encoding: "utf8" });
|
|
19
|
+
this.data = JSON.parse(content);
|
|
20
|
+
} catch (error)
|
|
21
|
+
{
|
|
22
|
+
this.data = {};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
private save(): void
|
|
26
|
+
{
|
|
27
|
+
fs.writeFileSync(this.base_path, JSON.stringify(this.data));
|
|
28
|
+
}
|
|
29
|
+
override get(name: string, defaultValue: string)
|
|
30
|
+
{
|
|
31
|
+
this.load();
|
|
32
|
+
return this.data[name] ?? defaultValue;
|
|
33
|
+
}
|
|
34
|
+
override set(name: string, value: string)
|
|
35
|
+
{
|
|
36
|
+
this.load();
|
|
37
|
+
this.data[name] = value;
|
|
38
|
+
this.save();
|
|
39
|
+
}
|
|
40
|
+
override del(name: string)
|
|
41
|
+
{
|
|
42
|
+
this.load();
|
|
43
|
+
delete this.data[name];
|
|
44
|
+
this.save();
|
|
45
|
+
}
|
|
46
46
|
}
|
package/src/IStorageLocal.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { IStorage } from "./IStorage.js";
|
|
2
|
-
|
|
3
|
-
export class IStorageLocal extends IStorage
|
|
4
|
-
{
|
|
5
|
-
override get(name: string, defaultValue: string)
|
|
6
|
-
{
|
|
7
|
-
return localStorage.getItem(name) ?? defaultValue;
|
|
8
|
-
}
|
|
9
|
-
override set(name: string, value: string)
|
|
10
|
-
{
|
|
11
|
-
localStorage.setItem(name, value);
|
|
12
|
-
}
|
|
13
|
-
override del(name: string)
|
|
14
|
-
{
|
|
15
|
-
localStorage.removeItem(name);
|
|
16
|
-
}
|
|
1
|
+
import { IStorage } from "./IStorage.js";
|
|
2
|
+
|
|
3
|
+
export class IStorageLocal extends IStorage
|
|
4
|
+
{
|
|
5
|
+
override get(name: string, defaultValue: string)
|
|
6
|
+
{
|
|
7
|
+
return localStorage.getItem(name) ?? defaultValue;
|
|
8
|
+
}
|
|
9
|
+
override set(name: string, value: string)
|
|
10
|
+
{
|
|
11
|
+
localStorage.setItem(name, value);
|
|
12
|
+
}
|
|
13
|
+
override del(name: string)
|
|
14
|
+
{
|
|
15
|
+
localStorage.removeItem(name);
|
|
16
|
+
}
|
|
17
17
|
}
|
package/src/IStorageMemory.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { IStorage } from "./IStorage";
|
|
2
|
-
|
|
3
|
-
export class IStorageMemory extends IStorage
|
|
4
|
-
{
|
|
5
|
-
static data: { [name: string]: string } = {};
|
|
6
|
-
override get(name: string, defaultValue: string)
|
|
7
|
-
{
|
|
8
|
-
return IStorageMemory.data[name] ?? defaultValue;
|
|
9
|
-
}
|
|
10
|
-
override set(name: string, value: string)
|
|
11
|
-
{
|
|
12
|
-
IStorageMemory.data[name] = value;
|
|
13
|
-
}
|
|
14
|
-
override del(name: string)
|
|
15
|
-
{
|
|
16
|
-
delete IStorageMemory.data[name];
|
|
17
|
-
}
|
|
1
|
+
import { IStorage } from "./IStorage";
|
|
2
|
+
|
|
3
|
+
export class IStorageMemory extends IStorage
|
|
4
|
+
{
|
|
5
|
+
static data: { [name: string]: string } = {};
|
|
6
|
+
override get(name: string, defaultValue: string)
|
|
7
|
+
{
|
|
8
|
+
return IStorageMemory.data[name] ?? defaultValue;
|
|
9
|
+
}
|
|
10
|
+
override set(name: string, value: string)
|
|
11
|
+
{
|
|
12
|
+
IStorageMemory.data[name] = value;
|
|
13
|
+
}
|
|
14
|
+
override del(name: string)
|
|
15
|
+
{
|
|
16
|
+
delete IStorageMemory.data[name];
|
|
17
|
+
}
|
|
18
18
|
}
|
package/src/NamingConvention.ts
CHANGED
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
export class NamingConvention
|
|
2
|
-
{
|
|
3
|
-
public static formatter_lower = (word: string) =>
|
|
4
|
-
{
|
|
5
|
-
if (word)
|
|
6
|
-
return word.toLowerCase();
|
|
7
|
-
return "";
|
|
8
|
-
};
|
|
9
|
-
public static formatter_upper = (word: string) =>
|
|
10
|
-
{
|
|
11
|
-
if (word)
|
|
12
|
-
return word.toUpperCase();
|
|
13
|
-
return "";
|
|
14
|
-
};
|
|
15
|
-
public static formatter_pascal = (word: string) =>
|
|
16
|
-
{
|
|
17
|
-
if (word)
|
|
18
|
-
return word[0].toUpperCase() + word.substring(1).toLowerCase();
|
|
19
|
-
return "";
|
|
20
|
-
};
|
|
21
|
-
public static formatter_camel = (word: string, index: number) =>
|
|
22
|
-
{
|
|
23
|
-
if (index == 0)
|
|
24
|
-
return NamingConvention.formatter_lower(word);
|
|
25
|
-
return NamingConvention.formatter_pascal(word);
|
|
26
|
-
};
|
|
27
|
-
public static formatter_sentence = (word: string, index: number) =>
|
|
28
|
-
{
|
|
29
|
-
if (index != 0)
|
|
30
|
-
return NamingConvention.formatter_lower(word);
|
|
31
|
-
return NamingConvention.formatter_pascal(word);
|
|
32
|
-
};
|
|
33
|
-
public static splitter_normal = (name: string, delimiter: string) =>
|
|
34
|
-
{
|
|
35
|
-
return name.split(delimiter);
|
|
36
|
-
};
|
|
37
|
-
public static splitter_uppercase = (name: string) =>
|
|
38
|
-
{
|
|
39
|
-
return name.split(/(?=[A-Z])/);
|
|
40
|
-
};
|
|
41
|
-
public static splitter_none = (name: string) =>
|
|
42
|
-
{
|
|
43
|
-
return [name];
|
|
44
|
-
};
|
|
45
|
-
public static lower_case: NamingConvention = new NamingConvention("lowercase", "", NamingConvention.formatter_lower, NamingConvention.splitter_none);
|
|
46
|
-
public static UPPER_CASE: NamingConvention = new NamingConvention("UPPERCASE", "", NamingConvention.formatter_upper, NamingConvention.splitter_none);
|
|
47
|
-
public static Pascal_Case: NamingConvention = new NamingConvention("PascalCase", "", NamingConvention.formatter_pascal, NamingConvention.splitter_uppercase);
|
|
48
|
-
public static camel_Case: NamingConvention = new NamingConvention("camelCase", "", NamingConvention.formatter_camel, NamingConvention.splitter_uppercase);
|
|
49
|
-
public static First_word_case: NamingConvention = new NamingConvention("Firstwordcase", "", NamingConvention.formatter_sentence, NamingConvention.splitter_none);
|
|
50
|
-
|
|
51
|
-
public static lower_case_underscore: NamingConvention = new NamingConvention("snake_case", "_", NamingConvention.formatter_lower, NamingConvention.splitter_normal);
|
|
52
|
-
public static UPPER_CASE_UNDERSCORE: NamingConvention = new NamingConvention("SNAKE_CASE", "_", NamingConvention.formatter_upper, NamingConvention.splitter_normal);
|
|
53
|
-
public static Pascal_Case_Underscore: NamingConvention = new NamingConvention("Pascal_CASE", "_", NamingConvention.formatter_pascal, NamingConvention.splitter_normal);
|
|
54
|
-
public static camel_Case_Underscore: NamingConvention = new NamingConvention("camel_Case", "_", NamingConvention.formatter_camel, NamingConvention.splitter_normal);
|
|
55
|
-
public static First_word_case_underscore: NamingConvention = new NamingConvention("First_word_case", "_", NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
|
|
56
|
-
|
|
57
|
-
public static lower_case_dash: NamingConvention = new NamingConvention("kebab-case", "-", NamingConvention.formatter_lower, NamingConvention.splitter_normal);
|
|
58
|
-
public static UPPER_CASE_DASH: NamingConvention = new NamingConvention("UPPER-CASE", "-", NamingConvention.formatter_upper, NamingConvention.splitter_normal);
|
|
59
|
-
public static Pascal_Case_Dash: NamingConvention = new NamingConvention("Pascal-Case", "-", NamingConvention.formatter_pascal, NamingConvention.splitter_normal);
|
|
60
|
-
public static camel_Case_Dash: NamingConvention = new NamingConvention("camel-Case", "-", NamingConvention.formatter_camel, NamingConvention.splitter_normal);
|
|
61
|
-
public static First_word_case_dash: NamingConvention = new NamingConvention("First-word-case", "-", NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
|
|
62
|
-
|
|
63
|
-
public static lower_case_dot: NamingConvention = new NamingConvention("domain.case", ".", NamingConvention.formatter_lower, NamingConvention.splitter_normal);
|
|
64
|
-
public static UPPER_CASE_DOT: NamingConvention = new NamingConvention("UPPER.CASE", ".", NamingConvention.formatter_upper, NamingConvention.splitter_normal);
|
|
65
|
-
public static Pascal_Case_Dot: NamingConvention = new NamingConvention("Pascal.Case", ".", NamingConvention.formatter_pascal, NamingConvention.splitter_normal);
|
|
66
|
-
public static camel_Case_Dot: NamingConvention = new NamingConvention("camel.Case", ".", NamingConvention.formatter_camel, NamingConvention.splitter_normal);
|
|
67
|
-
public static First_word_case_dot: NamingConvention = new NamingConvention("First.word.case", ".", NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
|
|
68
|
-
|
|
69
|
-
public static lower_case_space: NamingConvention = new NamingConvention("lower case", " ", NamingConvention.formatter_lower, NamingConvention.splitter_normal);
|
|
70
|
-
public static UPPER_CASE_SPACE: NamingConvention = new NamingConvention("UPPRE CASE", " ", NamingConvention.formatter_upper, NamingConvention.splitter_normal);
|
|
71
|
-
public static Pascal_Case_Space: NamingConvention = new NamingConvention("Title Case", " ", NamingConvention.formatter_pascal, NamingConvention.splitter_normal);
|
|
72
|
-
public static camel_Case_Space: NamingConvention = new NamingConvention("camel Case", " ", NamingConvention.formatter_camel, NamingConvention.splitter_normal);
|
|
73
|
-
public static First_word_case_space: NamingConvention = new NamingConvention("Sentence case", " ", NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
|
|
74
|
-
|
|
75
|
-
public static lower_case_slash: NamingConvention = new NamingConvention("path/case", "/", NamingConvention.formatter_lower, NamingConvention.splitter_normal);
|
|
76
|
-
public static UPPER_CASE_SLASH: NamingConvention = new NamingConvention("UPPER/CASE", "/", NamingConvention.formatter_upper, NamingConvention.splitter_normal);
|
|
77
|
-
public static Pascal_Case_Slash: NamingConvention = new NamingConvention("Pascal/Case", "/", NamingConvention.formatter_pascal, NamingConvention.splitter_normal);
|
|
78
|
-
public static camel_Case_Slash: NamingConvention = new NamingConvention("camel/Case", "/", NamingConvention.formatter_camel, NamingConvention.splitter_normal);
|
|
79
|
-
public static First_word_case_slash: NamingConvention = new NamingConvention("First/word/case", "/", NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
|
|
80
|
-
name: string;
|
|
81
|
-
delimiter: string;
|
|
82
|
-
formatter: (word: string, index: number) => string;
|
|
83
|
-
splitter: (name: string, delimiter: string) => string[];
|
|
84
|
-
constructor(name: string, delimiter: string, formatter: (word: string, index: number) => string, splitter: (name: string, delimiter: string) => string[])
|
|
85
|
-
{
|
|
86
|
-
this.name = name;
|
|
87
|
-
this.delimiter = delimiter;
|
|
88
|
-
this.formatter = formatter;
|
|
89
|
-
this.splitter = splitter;
|
|
90
|
-
}
|
|
91
|
-
getWords(name: string)
|
|
92
|
-
{
|
|
93
|
-
let ans = this.splitter(name, this.delimiter);
|
|
94
|
-
ans = ans.filter(w => w);
|
|
95
|
-
return ans;
|
|
96
|
-
}
|
|
97
|
-
convertByWords(words: string[])
|
|
98
|
-
{
|
|
99
|
-
for (let i = 0; i < words.length; i++)
|
|
100
|
-
words[i] = this.formatter(words[i], i);
|
|
101
|
-
return words.join(this.delimiter);
|
|
102
|
-
}
|
|
103
|
-
convert(name: string, to: NamingConvention)
|
|
104
|
-
{
|
|
105
|
-
let words = this.getWords(name);
|
|
106
|
-
return to.convertByWords(words);
|
|
107
|
-
}
|
|
1
|
+
export class NamingConvention
|
|
2
|
+
{
|
|
3
|
+
public static formatter_lower = (word: string) =>
|
|
4
|
+
{
|
|
5
|
+
if (word)
|
|
6
|
+
return word.toLowerCase();
|
|
7
|
+
return "";
|
|
8
|
+
};
|
|
9
|
+
public static formatter_upper = (word: string) =>
|
|
10
|
+
{
|
|
11
|
+
if (word)
|
|
12
|
+
return word.toUpperCase();
|
|
13
|
+
return "";
|
|
14
|
+
};
|
|
15
|
+
public static formatter_pascal = (word: string) =>
|
|
16
|
+
{
|
|
17
|
+
if (word)
|
|
18
|
+
return word[0].toUpperCase() + word.substring(1).toLowerCase();
|
|
19
|
+
return "";
|
|
20
|
+
};
|
|
21
|
+
public static formatter_camel = (word: string, index: number) =>
|
|
22
|
+
{
|
|
23
|
+
if (index == 0)
|
|
24
|
+
return NamingConvention.formatter_lower(word);
|
|
25
|
+
return NamingConvention.formatter_pascal(word);
|
|
26
|
+
};
|
|
27
|
+
public static formatter_sentence = (word: string, index: number) =>
|
|
28
|
+
{
|
|
29
|
+
if (index != 0)
|
|
30
|
+
return NamingConvention.formatter_lower(word);
|
|
31
|
+
return NamingConvention.formatter_pascal(word);
|
|
32
|
+
};
|
|
33
|
+
public static splitter_normal = (name: string, delimiter: string) =>
|
|
34
|
+
{
|
|
35
|
+
return name.split(delimiter);
|
|
36
|
+
};
|
|
37
|
+
public static splitter_uppercase = (name: string) =>
|
|
38
|
+
{
|
|
39
|
+
return name.split(/(?=[A-Z])/);
|
|
40
|
+
};
|
|
41
|
+
public static splitter_none = (name: string) =>
|
|
42
|
+
{
|
|
43
|
+
return [name];
|
|
44
|
+
};
|
|
45
|
+
public static lower_case: NamingConvention = new NamingConvention("lowercase", "", NamingConvention.formatter_lower, NamingConvention.splitter_none);
|
|
46
|
+
public static UPPER_CASE: NamingConvention = new NamingConvention("UPPERCASE", "", NamingConvention.formatter_upper, NamingConvention.splitter_none);
|
|
47
|
+
public static Pascal_Case: NamingConvention = new NamingConvention("PascalCase", "", NamingConvention.formatter_pascal, NamingConvention.splitter_uppercase);
|
|
48
|
+
public static camel_Case: NamingConvention = new NamingConvention("camelCase", "", NamingConvention.formatter_camel, NamingConvention.splitter_uppercase);
|
|
49
|
+
public static First_word_case: NamingConvention = new NamingConvention("Firstwordcase", "", NamingConvention.formatter_sentence, NamingConvention.splitter_none);
|
|
50
|
+
|
|
51
|
+
public static lower_case_underscore: NamingConvention = new NamingConvention("snake_case", "_", NamingConvention.formatter_lower, NamingConvention.splitter_normal);
|
|
52
|
+
public static UPPER_CASE_UNDERSCORE: NamingConvention = new NamingConvention("SNAKE_CASE", "_", NamingConvention.formatter_upper, NamingConvention.splitter_normal);
|
|
53
|
+
public static Pascal_Case_Underscore: NamingConvention = new NamingConvention("Pascal_CASE", "_", NamingConvention.formatter_pascal, NamingConvention.splitter_normal);
|
|
54
|
+
public static camel_Case_Underscore: NamingConvention = new NamingConvention("camel_Case", "_", NamingConvention.formatter_camel, NamingConvention.splitter_normal);
|
|
55
|
+
public static First_word_case_underscore: NamingConvention = new NamingConvention("First_word_case", "_", NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
|
|
56
|
+
|
|
57
|
+
public static lower_case_dash: NamingConvention = new NamingConvention("kebab-case", "-", NamingConvention.formatter_lower, NamingConvention.splitter_normal);
|
|
58
|
+
public static UPPER_CASE_DASH: NamingConvention = new NamingConvention("UPPER-CASE", "-", NamingConvention.formatter_upper, NamingConvention.splitter_normal);
|
|
59
|
+
public static Pascal_Case_Dash: NamingConvention = new NamingConvention("Pascal-Case", "-", NamingConvention.formatter_pascal, NamingConvention.splitter_normal);
|
|
60
|
+
public static camel_Case_Dash: NamingConvention = new NamingConvention("camel-Case", "-", NamingConvention.formatter_camel, NamingConvention.splitter_normal);
|
|
61
|
+
public static First_word_case_dash: NamingConvention = new NamingConvention("First-word-case", "-", NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
|
|
62
|
+
|
|
63
|
+
public static lower_case_dot: NamingConvention = new NamingConvention("domain.case", ".", NamingConvention.formatter_lower, NamingConvention.splitter_normal);
|
|
64
|
+
public static UPPER_CASE_DOT: NamingConvention = new NamingConvention("UPPER.CASE", ".", NamingConvention.formatter_upper, NamingConvention.splitter_normal);
|
|
65
|
+
public static Pascal_Case_Dot: NamingConvention = new NamingConvention("Pascal.Case", ".", NamingConvention.formatter_pascal, NamingConvention.splitter_normal);
|
|
66
|
+
public static camel_Case_Dot: NamingConvention = new NamingConvention("camel.Case", ".", NamingConvention.formatter_camel, NamingConvention.splitter_normal);
|
|
67
|
+
public static First_word_case_dot: NamingConvention = new NamingConvention("First.word.case", ".", NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
|
|
68
|
+
|
|
69
|
+
public static lower_case_space: NamingConvention = new NamingConvention("lower case", " ", NamingConvention.formatter_lower, NamingConvention.splitter_normal);
|
|
70
|
+
public static UPPER_CASE_SPACE: NamingConvention = new NamingConvention("UPPRE CASE", " ", NamingConvention.formatter_upper, NamingConvention.splitter_normal);
|
|
71
|
+
public static Pascal_Case_Space: NamingConvention = new NamingConvention("Title Case", " ", NamingConvention.formatter_pascal, NamingConvention.splitter_normal);
|
|
72
|
+
public static camel_Case_Space: NamingConvention = new NamingConvention("camel Case", " ", NamingConvention.formatter_camel, NamingConvention.splitter_normal);
|
|
73
|
+
public static First_word_case_space: NamingConvention = new NamingConvention("Sentence case", " ", NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
|
|
74
|
+
|
|
75
|
+
public static lower_case_slash: NamingConvention = new NamingConvention("path/case", "/", NamingConvention.formatter_lower, NamingConvention.splitter_normal);
|
|
76
|
+
public static UPPER_CASE_SLASH: NamingConvention = new NamingConvention("UPPER/CASE", "/", NamingConvention.formatter_upper, NamingConvention.splitter_normal);
|
|
77
|
+
public static Pascal_Case_Slash: NamingConvention = new NamingConvention("Pascal/Case", "/", NamingConvention.formatter_pascal, NamingConvention.splitter_normal);
|
|
78
|
+
public static camel_Case_Slash: NamingConvention = new NamingConvention("camel/Case", "/", NamingConvention.formatter_camel, NamingConvention.splitter_normal);
|
|
79
|
+
public static First_word_case_slash: NamingConvention = new NamingConvention("First/word/case", "/", NamingConvention.formatter_sentence, NamingConvention.splitter_normal);
|
|
80
|
+
name: string;
|
|
81
|
+
delimiter: string;
|
|
82
|
+
formatter: (word: string, index: number) => string;
|
|
83
|
+
splitter: (name: string, delimiter: string) => string[];
|
|
84
|
+
constructor(name: string, delimiter: string, formatter: (word: string, index: number) => string, splitter: (name: string, delimiter: string) => string[])
|
|
85
|
+
{
|
|
86
|
+
this.name = name;
|
|
87
|
+
this.delimiter = delimiter;
|
|
88
|
+
this.formatter = formatter;
|
|
89
|
+
this.splitter = splitter;
|
|
90
|
+
}
|
|
91
|
+
getWords(name: string)
|
|
92
|
+
{
|
|
93
|
+
let ans = this.splitter(name, this.delimiter);
|
|
94
|
+
ans = ans.filter(w => w);
|
|
95
|
+
return ans;
|
|
96
|
+
}
|
|
97
|
+
convertByWords(words: string[])
|
|
98
|
+
{
|
|
99
|
+
for (let i = 0; i < words.length; i++)
|
|
100
|
+
words[i] = this.formatter(words[i], i);
|
|
101
|
+
return words.join(this.delimiter);
|
|
102
|
+
}
|
|
103
|
+
convert(name: string, to: NamingConvention)
|
|
104
|
+
{
|
|
105
|
+
let words = this.getWords(name);
|
|
106
|
+
return to.convertByWords(words);
|
|
107
|
+
}
|
|
108
108
|
}
|
package/src/ObjectService.ts
CHANGED
|
@@ -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
|
}
|
package/src/PackageService.ts
CHANGED
|
@@ -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
|
}
|
package/src/PhoneOperation.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as Phone from 'phone';
|
|
2
|
-
|
|
3
|
-
export class PhoneOperation
|
|
4
|
-
{
|
|
5
|
-
static isValid(number: string): boolean
|
|
6
|
-
{
|
|
7
|
-
return Phone.phone(number).isValid;
|
|
8
|
-
}
|
|
1
|
+
import * as Phone from 'phone';
|
|
2
|
+
|
|
3
|
+
export class PhoneOperation
|
|
4
|
+
{
|
|
5
|
+
static isValid(number: string): boolean
|
|
6
|
+
{
|
|
7
|
+
return Phone.phone(number).isValid;
|
|
8
|
+
}
|
|
9
9
|
}
|
package/src/PriceOperation.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export class PriceOperation
|
|
2
|
-
{
|
|
3
|
-
static toCent(value: number): number
|
|
4
|
-
{
|
|
5
|
-
return Math.round(value / 1000);
|
|
6
|
-
}
|
|
7
|
-
static toNormal(value: number): number
|
|
8
|
-
{
|
|
9
|
-
return Math.round(value / 1000) / 100;
|
|
10
|
-
}
|
|
11
|
-
static fromCent(value: number): number
|
|
12
|
-
{
|
|
13
|
-
return Math.floor(value * 1000);
|
|
14
|
-
}
|
|
15
|
-
static fromNormal(value: number): number
|
|
16
|
-
{
|
|
17
|
-
return Math.floor(value * 100 * 1000);
|
|
18
|
-
}
|
|
1
|
+
export class PriceOperation
|
|
2
|
+
{
|
|
3
|
+
static toCent(value: number): number
|
|
4
|
+
{
|
|
5
|
+
return Math.round(value / 1000);
|
|
6
|
+
}
|
|
7
|
+
static toNormal(value: number): number
|
|
8
|
+
{
|
|
9
|
+
return Math.round(value / 1000) / 100;
|
|
10
|
+
}
|
|
11
|
+
static fromCent(value: number): number
|
|
12
|
+
{
|
|
13
|
+
return Math.floor(value * 1000);
|
|
14
|
+
}
|
|
15
|
+
static fromNormal(value: number): number
|
|
16
|
+
{
|
|
17
|
+
return Math.floor(value * 100 * 1000);
|
|
18
|
+
}
|
|
19
19
|
}
|