@aitianyu.cn/types 0.0.12 → 0.1.0

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 (87) hide show
  1. package/dist/lib/{utilities/coding → coding}/Error.js +44 -44
  2. package/dist/lib/{utilities/coding → coding}/Path.js +210 -198
  3. package/dist/lib/{utilities/core → core}/Errors.js +86 -86
  4. package/dist/lib/{utilities/core → core}/Language.js +561 -559
  5. package/dist/lib/{utilities/core → core}/Log.js +112 -108
  6. package/dist/lib/{utilities/core → core}/TypeConvertion.js +25 -25
  7. package/dist/lib/{utilities/core → core}/interface/ITJSON.js +3 -3
  8. package/dist/lib/{utilities/core → core}/interface/ITianyuType.js +3 -3
  9. package/dist/lib/{utilities/core → core}/object/ArrayHelper.js +35 -35
  10. package/dist/lib/core/object/Bytes.js +21 -0
  11. package/dist/lib/{utilities/core → core}/object/Calculater.js +240 -230
  12. package/dist/lib/core/object/DataView.js +23 -0
  13. package/dist/lib/core/object/Integer.js +117 -0
  14. package/dist/lib/core/object/Json.js +35 -0
  15. package/dist/lib/{utilities/core/object/Helper.js → core/object/ObjectHelper.js} +202 -201
  16. package/dist/lib/core/object/StringHelper.js +61 -0
  17. package/dist/lib/{utilities/core → core}/type/TArray.js +8 -7
  18. package/dist/lib/{utilities/core → core}/type/TBoolean.js +7 -7
  19. package/dist/lib/{utilities/core → core}/type/TJSON.js +7 -7
  20. package/dist/lib/{utilities/core → core}/type/TNumber.js +7 -7
  21. package/dist/lib/{utilities/core → core}/type/TObject.js +7 -7
  22. package/dist/lib/{utilities/core → core}/type/TString.js +7 -7
  23. package/dist/lib/index.js +70 -54
  24. package/dist/lib/security/Base32.js +104 -0
  25. package/dist/lib/security/Guid.js +26 -0
  26. package/dist/lib/{utilities/security → security}/Hash.js +16 -15
  27. package/dist/lib/security/QRCode.js +46 -0
  28. package/dist/lib/security/RSA.js +62 -0
  29. package/dist/lib/security/SHA.js +67 -0
  30. package/dist/lib/types/AreaCode.js +269 -269
  31. package/dist/lib/types/Exception.js +19 -19
  32. package/dist/lib/types/Logs.js +20 -20
  33. package/dist/lib/types/Object.js +3 -3
  34. package/dist/lib/types/PathBase.js +109 -109
  35. package/dist/lib/types/Security.js +10 -10
  36. package/dist/lib/types/TMap.js +139 -138
  37. package/dist/lib/types/Types.js +3 -3
  38. package/dist/lib/types/index.js +17 -17
  39. package/dist/types/{utilities/coding → coding}/Error.d.ts +27 -27
  40. package/dist/types/{utilities/coding → coding}/Path.d.ts +61 -61
  41. package/dist/types/{utilities/core → core}/Errors.d.ts +47 -47
  42. package/dist/types/{utilities/core → core}/Language.d.ts +17 -17
  43. package/dist/types/{utilities/core → core}/Log.d.ts +12 -12
  44. package/dist/types/{utilities/core → core}/TypeConvertion.d.ts +2 -2
  45. package/dist/types/{utilities/core → core}/interface/ITJSON.d.ts +5 -5
  46. package/dist/types/{utilities/core → core}/interface/ITianyuType.d.ts +5 -5
  47. package/dist/types/{utilities/core → core}/object/ArrayHelper.d.ts +11 -11
  48. package/dist/types/core/object/Bytes.d.ts +13 -0
  49. package/dist/types/{utilities/core → core}/object/Calculater.d.ts +22 -22
  50. package/dist/types/core/object/DataView.d.ts +11 -0
  51. package/dist/types/core/object/Integer.d.ts +71 -0
  52. package/dist/types/core/object/Json.d.ts +22 -0
  53. package/dist/types/{utilities/core/object/Helper.d.ts → core/object/ObjectHelper.d.ts} +39 -39
  54. package/dist/types/core/object/StringHelper.d.ts +21 -0
  55. package/dist/types/{utilities/core → core}/type/TArray.d.ts +3 -3
  56. package/dist/types/{utilities/core → core}/type/TBoolean.d.ts +3 -3
  57. package/dist/types/{utilities/core → core}/type/TJSON.d.ts +3 -3
  58. package/dist/types/{utilities/core → core}/type/TNumber.d.ts +3 -3
  59. package/dist/types/{utilities/core → core}/type/TObject.d.ts +3 -3
  60. package/dist/types/{utilities/core → core}/type/TString.d.ts +3 -3
  61. package/dist/types/index.d.ts +29 -21
  62. package/dist/types/security/Base32.d.ts +42 -0
  63. package/dist/types/security/Guid.d.ts +4 -0
  64. package/dist/types/{utilities/security → security}/Hash.d.ts +3 -3
  65. package/dist/types/security/QRCode.d.ts +11 -0
  66. package/dist/types/security/RSA.d.ts +68 -0
  67. package/dist/types/security/SHA.d.ts +40 -0
  68. package/dist/types/types/AreaCode.d.ts +135 -135
  69. package/dist/types/types/Exception.d.ts +11 -11
  70. package/dist/types/types/Logs.d.ts +64 -64
  71. package/dist/types/types/Object.d.ts +18 -18
  72. package/dist/types/types/PathBase.d.ts +76 -76
  73. package/dist/types/types/Security.d.ts +23 -23
  74. package/dist/types/types/TMap.d.ts +80 -80
  75. package/dist/types/types/Types.d.ts +25 -25
  76. package/dist/types/types/index.d.ts +9 -9
  77. package/package.json +57 -51
  78. package/dist/lib/utilities/coding/index.js +0 -10
  79. package/dist/lib/utilities/core/index.js +0 -21
  80. package/dist/lib/utilities/core/object/StringHelper.js +0 -22
  81. package/dist/lib/utilities/security/Guid.js +0 -20
  82. package/dist/lib/utilities/security/index.js +0 -8
  83. package/dist/types/utilities/coding/index.d.ts +0 -3
  84. package/dist/types/utilities/core/index.d.ts +0 -6
  85. package/dist/types/utilities/core/object/StringHelper.d.ts +0 -4
  86. package/dist/types/utilities/security/Guid.d.ts +0 -3
  87. package/dist/types/utilities/security/index.d.ts +0 -3
@@ -1,44 +1,44 @@
1
- "use strict";
2
- /**@format */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.PathDirAndFileConvertInvaild = exports.PathDirectoryValidationFailException = exports.PathProcessorSourceLostException = void 0;
5
- const Exception_1 = require("../../types/Exception");
6
- /**
7
- * Source lost exception of Path Processor.
8
- * Exception will be thrown if the path is file but the file field is not specified
9
- */
10
- class PathProcessorSourceLostException extends Exception_1.Exception {
11
- constructor(msg) {
12
- super(msg);
13
- }
14
- toString() {
15
- return `路径处理器 - 指定的参数 ( path.file ) 为空`;
16
- }
17
- }
18
- exports.PathProcessorSourceLostException = PathProcessorSourceLostException;
19
- /**
20
- * Path directory name is not valid.
21
- * Exception will be thrown if the path name has the invalid char
22
- */
23
- class PathDirectoryValidationFailException extends Exception_1.Exception {
24
- constructor(msg) {
25
- super(msg);
26
- }
27
- toString() {
28
- return `路径处理器 - 指定的路径目录 ( ${this.message} ) 无效`;
29
- }
30
- }
31
- exports.PathDirectoryValidationFailException = PathDirectoryValidationFailException;
32
- /**
33
- * Path is file or directory but target type is not.
34
- * Exception will be thrown if the path is file(directory) but try to convert to directory(file)
35
- */
36
- class PathDirAndFileConvertInvaild extends Exception_1.Exception {
37
- constructor(path, type) {
38
- super(`${path} 为 ${type === "directory" ? "目录" : "文件"}`);
39
- }
40
- toString() {
41
- return `路径处理器 - 不能将文件与目录相互转换 ( ${this.message} ) `;
42
- }
43
- }
44
- exports.PathDirAndFileConvertInvaild = PathDirAndFileConvertInvaild;
1
+ "use strict";
2
+ /**@format */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.PathDirAndFileConvertInvaild = exports.PathDirectoryValidationFailException = exports.PathProcessorSourceLostException = void 0;
5
+ const Exception_1 = require("../types/Exception");
6
+ /**
7
+ * Source lost exception of Path Processor.
8
+ * Exception will be thrown if the path is file but the file field is not specified
9
+ */
10
+ class PathProcessorSourceLostException extends Exception_1.Exception {
11
+ constructor(msg) {
12
+ super(msg);
13
+ }
14
+ toString() {
15
+ return `路径处理器 - 指定的参数 ( path.file ) 为空`;
16
+ }
17
+ }
18
+ exports.PathProcessorSourceLostException = PathProcessorSourceLostException;
19
+ /**
20
+ * Path directory name is not valid.
21
+ * Exception will be thrown if the path name has the invalid char
22
+ */
23
+ class PathDirectoryValidationFailException extends Exception_1.Exception {
24
+ constructor(msg) {
25
+ super(msg);
26
+ }
27
+ toString() {
28
+ return `路径处理器 - 指定的路径目录 ( ${this.message} ) 无效`;
29
+ }
30
+ }
31
+ exports.PathDirectoryValidationFailException = PathDirectoryValidationFailException;
32
+ /**
33
+ * Path is file or directory but target type is not.
34
+ * Exception will be thrown if the path is file(directory) but try to convert to directory(file)
35
+ */
36
+ class PathDirAndFileConvertInvaild extends Exception_1.Exception {
37
+ constructor(path, type) {
38
+ super(`${path} 为 ${type === "directory" ? "目录" : "文件"}`);
39
+ }
40
+ toString() {
41
+ return `路径处理器 - 不能将文件与目录相互转换 ( ${this.message} ) `;
42
+ }
43
+ }
44
+ exports.PathDirAndFileConvertInvaild = PathDirAndFileConvertInvaild;
@@ -1,198 +1,210 @@
1
- "use strict";
2
- /**@format */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Path = void 0;
5
- const PathBase_1 = require("../../types/PathBase");
6
- const Error_1 = require("./Error");
7
- const __charInDirValidation = {
8
- "/": { file: false, dir: false },
9
- ".": { file: true, dir: false },
10
- };
11
- function _dirNameChecker(dir) {
12
- if (!dir)
13
- return "drop";
14
- for (const ch of dir) {
15
- const validation = __charInDirValidation[ch];
16
- if (validation && !validation.dir) {
17
- return "invalid";
18
- }
19
- }
20
- return "valid";
21
- }
22
- function _dirFileTypeChecker(src) {
23
- if (!src)
24
- return "drop";
25
- let dirType = false;
26
- let fileType = false;
27
- for (const char of src) {
28
- const validation = __charInDirValidation[char];
29
- if (dirType) {
30
- if (validation && !validation.dir)
31
- return "invalid";
32
- }
33
- else if (fileType) {
34
- if (validation && !validation.file)
35
- return "invalid";
36
- }
37
- else {
38
- if (validation) {
39
- if (validation.dir && !validation.file)
40
- dirType = true;
41
- else if (!validation.dir && validation.file)
42
- fileType = true;
43
- else if (!validation.dir && !validation.file)
44
- return "invalid";
45
- }
46
- }
47
- }
48
- if ((!dirType && !fileType) || dirType)
49
- return "directory";
50
- else
51
- return "file";
52
- }
53
- function _parsePathFromString(src) {
54
- const path = {
55
- dirs: [],
56
- file: undefined,
57
- type: "directory",
58
- };
59
- if (!src) {
60
- return path;
61
- }
62
- const prsedSrc = src.trim();
63
- const srcSplit = prsedSrc.split("/");
64
- if (srcSplit.length === 0) {
65
- return path;
66
- }
67
- for (let i = 0; i < srcSplit.length - 1; ++i) {
68
- const dir = srcSplit[i];
69
- const validation = _dirNameChecker(dir);
70
- if (validation === "invalid") {
71
- throw new Error_1.PathDirectoryValidationFailException(dir);
72
- }
73
- if (validation === "valid") {
74
- path.dirs.push(dir);
75
- }
76
- }
77
- const lastDir = srcSplit[srcSplit.length - 1];
78
- const dirType = _dirFileTypeChecker(lastDir);
79
- if (dirType === "directory") {
80
- path.dirs.push(lastDir);
81
- }
82
- else if (dirType === "file") {
83
- path.file = lastDir;
84
- path.type = "file";
85
- }
86
- return path;
87
- }
88
- /** Path */
89
- class Path extends PathBase_1.PathBase {
90
- _type;
91
- _file;
92
- /**
93
- * Create a new Path instance
94
- *
95
- * @param dirs the directory names
96
- * @param type indicate which type the Path is
97
- * @param file the file name if the type is file
98
- */
99
- constructor(dirs, type, file) {
100
- super();
101
- if (typeof dirs === "string") {
102
- const parsePath = _parsePathFromString(dirs);
103
- if (type && type != parsePath.type) {
104
- throw new Error_1.PathDirAndFileConvertInvaild(dirs, parsePath.type);
105
- }
106
- this._dirs = parsePath.dirs;
107
- type = parsePath.type;
108
- file = parsePath.file;
109
- }
110
- else if (Array.isArray(dirs)) {
111
- this._dirs = dirs;
112
- }
113
- this._type = type || (file && "file") || "directory";
114
- this._file = file;
115
- }
116
- /**
117
- * Convert the path to a string
118
- *
119
- * @returns return the string
120
- */
121
- toString() {
122
- if (this.getType() === "file" && !!!this.getFile()) {
123
- throw new Error_1.PathProcessorSourceLostException();
124
- }
125
- if (this.length() === 0 && !!!this.getFile()) {
126
- return "";
127
- }
128
- const dirs = [];
129
- for (const dirItem of this._dirs) {
130
- const validation = _dirNameChecker(dirItem);
131
- if (validation === "invalid") {
132
- throw new Error_1.PathDirectoryValidationFailException(dirItem);
133
- }
134
- if (validation === "valid") {
135
- dirs.push(dirItem);
136
- }
137
- }
138
- const file = this.getFile();
139
- if (!!file)
140
- dirs.push(file);
141
- if (dirs.length === 0) {
142
- return "";
143
- }
144
- return dirs.join("/");
145
- }
146
- /**
147
- * Set the target type
148
- *
149
- * @param type new type
150
- */
151
- setType(type) {
152
- this._type = type;
153
- }
154
- /**
155
- * Get the path type of current instance
156
- *
157
- * @returns return the path type
158
- */
159
- getType() {
160
- return this._type;
161
- }
162
- /**
163
- * Set the path file name
164
- *
165
- * @param file the new file name
166
- * @returns return the old file name
167
- */
168
- setFile(file) {
169
- const oldFile = this._file;
170
- this._file = file;
171
- return oldFile;
172
- }
173
- /**
174
- * Get the file name of current instance
175
- *
176
- * @returns return the file name
177
- */
178
- getFile() {
179
- return this._file;
180
- }
181
- /**
182
- * IComparable impl to get a string what equals to current instance
183
- *
184
- * @returns return the string
185
- */
186
- getString() {
187
- return this.toString();
188
- }
189
- /**
190
- * Get a hash code of current instance
191
- *
192
- * @returns always return 0
193
- */
194
- getHashCode() {
195
- return 0;
196
- }
197
- }
198
- exports.Path = Path;
1
+ "use strict";
2
+ /**@format */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Path = void 0;
5
+ const PathBase_1 = require("../types/PathBase");
6
+ const Error_1 = require("./Error");
7
+ const __charInDirValidation = {
8
+ "/": { file: false, dir: false },
9
+ ".": { file: true, dir: false },
10
+ };
11
+ function _dirNameChecker(dir) {
12
+ if (!dir) {
13
+ return "drop";
14
+ }
15
+ for (const ch of dir) {
16
+ const validation = __charInDirValidation[ch];
17
+ if (validation && !validation.dir) {
18
+ return "invalid";
19
+ }
20
+ }
21
+ return "valid";
22
+ }
23
+ function _dirFileTypeChecker(src) {
24
+ if (!src) {
25
+ return "drop";
26
+ }
27
+ let dirType = false;
28
+ let fileType = false;
29
+ for (const char of src) {
30
+ const validation = __charInDirValidation[char];
31
+ if (dirType) {
32
+ if (validation && !validation.dir) {
33
+ return "invalid";
34
+ }
35
+ }
36
+ else if (fileType) {
37
+ if (validation && !validation.file) {
38
+ return "invalid";
39
+ }
40
+ }
41
+ else {
42
+ if (validation) {
43
+ if (validation.dir && !validation.file) {
44
+ dirType = true;
45
+ }
46
+ else if (!validation.dir && validation.file) {
47
+ fileType = true;
48
+ }
49
+ else if (!validation.dir && !validation.file) {
50
+ return "invalid";
51
+ }
52
+ }
53
+ }
54
+ }
55
+ if ((!dirType && !fileType) || dirType) {
56
+ return "directory";
57
+ }
58
+ else {
59
+ return "file";
60
+ }
61
+ }
62
+ function _parsePathFromString(src) {
63
+ const path = {
64
+ dirs: [],
65
+ file: undefined,
66
+ type: "directory",
67
+ };
68
+ if (!src) {
69
+ return path;
70
+ }
71
+ const prsedSrc = src.trim();
72
+ const srcSplit = prsedSrc.split("/");
73
+ if (srcSplit.length === 0) {
74
+ return path;
75
+ }
76
+ for (let i = 0; i < srcSplit.length - 1; ++i) {
77
+ const dir = srcSplit[i];
78
+ const validation = _dirNameChecker(dir);
79
+ if (validation === "invalid") {
80
+ throw new Error_1.PathDirectoryValidationFailException(dir);
81
+ }
82
+ if (validation === "valid") {
83
+ path.dirs.push(dir);
84
+ }
85
+ }
86
+ const lastDir = srcSplit[srcSplit.length - 1];
87
+ const dirType = _dirFileTypeChecker(lastDir);
88
+ if (dirType === "directory") {
89
+ path.dirs.push(lastDir);
90
+ }
91
+ else if (dirType === "file") {
92
+ path.file = lastDir;
93
+ path.type = "file";
94
+ }
95
+ return path;
96
+ }
97
+ /** Path */
98
+ class Path extends PathBase_1.PathBase {
99
+ _type;
100
+ _file;
101
+ /**
102
+ * Create a new Path instance
103
+ *
104
+ * @param dirs the directory names
105
+ * @param type indicate which type the Path is
106
+ * @param file the file name if the type is file
107
+ */
108
+ constructor(dirs, type, file) {
109
+ super();
110
+ let actType = type;
111
+ let actFile = file;
112
+ if (typeof dirs === "string") {
113
+ const parsePath = _parsePathFromString(dirs);
114
+ if (type && type !== parsePath.type) {
115
+ throw new Error_1.PathDirAndFileConvertInvaild(dirs, parsePath.type);
116
+ }
117
+ this._dirs = parsePath.dirs;
118
+ actType = parsePath.type;
119
+ actFile = parsePath.file;
120
+ }
121
+ else if (Array.isArray(dirs)) {
122
+ this._dirs = dirs;
123
+ }
124
+ this._type = actType || (actFile && "file") || "directory";
125
+ this._file = actFile;
126
+ }
127
+ /**
128
+ * Convert the path to a string
129
+ *
130
+ * @returns return the string
131
+ */
132
+ toString() {
133
+ if (this.getType() === "file" && !!!this.getFile()) {
134
+ throw new Error_1.PathProcessorSourceLostException();
135
+ }
136
+ if (this.length() === 0 && !!!this.getFile()) {
137
+ return "";
138
+ }
139
+ const dirs = [];
140
+ for (const dirItem of this._dirs) {
141
+ const validation = _dirNameChecker(dirItem);
142
+ if (validation === "invalid") {
143
+ throw new Error_1.PathDirectoryValidationFailException(dirItem);
144
+ }
145
+ if (validation === "valid") {
146
+ dirs.push(dirItem);
147
+ }
148
+ }
149
+ const file = this.getFile();
150
+ if (!!file) {
151
+ dirs.push(file);
152
+ }
153
+ if (dirs.length === 0) {
154
+ return "";
155
+ }
156
+ return dirs.join("/");
157
+ }
158
+ /**
159
+ * Set the target type
160
+ *
161
+ * @param type new type
162
+ */
163
+ setType(type) {
164
+ this._type = type;
165
+ }
166
+ /**
167
+ * Get the path type of current instance
168
+ *
169
+ * @returns return the path type
170
+ */
171
+ getType() {
172
+ return this._type;
173
+ }
174
+ /**
175
+ * Set the path file name
176
+ *
177
+ * @param file the new file name
178
+ * @returns return the old file name
179
+ */
180
+ setFile(file) {
181
+ const oldFile = this._file;
182
+ this._file = file;
183
+ return oldFile;
184
+ }
185
+ /**
186
+ * Get the file name of current instance
187
+ *
188
+ * @returns return the file name
189
+ */
190
+ getFile() {
191
+ return this._file;
192
+ }
193
+ /**
194
+ * IComparable impl to get a string what equals to current instance
195
+ *
196
+ * @returns return the string
197
+ */
198
+ getString() {
199
+ return this.toString();
200
+ }
201
+ /**
202
+ * Get a hash code of current instance
203
+ *
204
+ * @returns always return 0
205
+ */
206
+ getHashCode() {
207
+ return 0;
208
+ }
209
+ }
210
+ exports.Path = Path;