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,83 +1,83 @@
1
- import { TimeOperation } from "./TimeOperation";
2
-
3
- export enum DurationUnit
4
- {
5
- Millisecond = "Millisecond",
6
- Second = "Second",
7
- Minute = "Minute",
8
- Hour = "Hour",
9
- Day = "Day",
10
- Week = "Week",
11
- Month = "Month",
12
- Year = "Year"
13
- };
14
-
15
- export class TimeUnitOperation
16
- {
17
- static later(value: number, unit: DurationUnit, date: Date | null = null)
18
- {
19
- if (!date)
20
- date = new Date();
21
- else
22
- date = new Date(date);
23
-
24
- if (unit === DurationUnit.Millisecond)
25
- return TimeOperation.millisecondsLater(value, date);
26
- if (unit === DurationUnit.Second)
27
- return TimeOperation.secondsLater(value, date);
28
- if (unit === DurationUnit.Minute)
29
- return TimeOperation.minutesLater(value, date);
30
- if (unit === DurationUnit.Hour)
31
- return TimeOperation.hoursAgo(value, date);
32
- if (unit === DurationUnit.Day)
33
- return TimeOperation.daysLater(value, date);
34
- if (unit === DurationUnit.Week)
35
- return TimeOperation.weeksLater(value, date);
36
- if (unit === DurationUnit.Month)
37
- return TimeOperation.monthsLater(value, date);
38
- if (unit === DurationUnit.Year)
39
- return TimeOperation.yearsLater(value, date);
40
- throw new Error("Wrong unit");
41
- }
42
- static ago(value: number, unit: DurationUnit, date: Date | null = null)
43
- {
44
- return this.later(value * -1, unit, date);
45
- }
46
- static toMilliseconds(value: number, unit: DurationUnit): number
47
- {
48
- let milliseconds = 0;
49
- if (unit === DurationUnit.Millisecond)
50
- milliseconds = value;
51
- else if (unit === DurationUnit.Second)
52
- milliseconds = value * 1000;
53
- else if (unit === DurationUnit.Minute)
54
- milliseconds = value * 1000 * 60;
55
- else if (unit === DurationUnit.Hour)
56
- milliseconds = value * 1000 * 60 * 60;
57
- else if (unit === DurationUnit.Day)
58
- milliseconds = value * 1000 * 60 * 60 * 24;
59
- else if (unit === DurationUnit.Week)
60
- milliseconds = value * 1000 * 60 * 60 * 24 * 7;
61
- else if (unit === DurationUnit.Month)
62
- milliseconds = value * 1000 * 60 * 60 * 24 * 30;
63
- else if (unit === DurationUnit.Year)
64
- milliseconds = value * 1000 * 60 * 60 * 24 * 365;
65
- return milliseconds;
66
- }
67
- static toSeconds(value: number, unit: DurationUnit): number
68
- {
69
- return Math.round(TimeUnitOperation.toMilliseconds(value, unit) / 1000);
70
- }
71
- static toMinutes(value: number, unit: DurationUnit): number
72
- {
73
- return Math.round(TimeUnitOperation.toSeconds(value, unit) / 60);
74
- }
75
- static toHours(value: number, unit: DurationUnit): number
76
- {
77
- return Math.round(TimeUnitOperation.toMinutes(value, unit) / 60);
78
- }
79
- static toDays(value: number, unit: DurationUnit): number
80
- {
81
- return Math.round(TimeUnitOperation.toHours(value, unit) / 24);
82
- }
1
+ import { TimeOperation } from "./TimeOperation";
2
+
3
+ export enum DurationUnit
4
+ {
5
+ Millisecond = "Millisecond",
6
+ Second = "Second",
7
+ Minute = "Minute",
8
+ Hour = "Hour",
9
+ Day = "Day",
10
+ Week = "Week",
11
+ Month = "Month",
12
+ Year = "Year"
13
+ };
14
+
15
+ export class TimeUnitOperation
16
+ {
17
+ static later(value: number, unit: DurationUnit, date: Date | null = null)
18
+ {
19
+ if (!date)
20
+ date = new Date();
21
+ else
22
+ date = new Date(date);
23
+
24
+ if (unit === DurationUnit.Millisecond)
25
+ return TimeOperation.millisecondsLater(value, date);
26
+ if (unit === DurationUnit.Second)
27
+ return TimeOperation.secondsLater(value, date);
28
+ if (unit === DurationUnit.Minute)
29
+ return TimeOperation.minutesLater(value, date);
30
+ if (unit === DurationUnit.Hour)
31
+ return TimeOperation.hoursAgo(value, date);
32
+ if (unit === DurationUnit.Day)
33
+ return TimeOperation.daysLater(value, date);
34
+ if (unit === DurationUnit.Week)
35
+ return TimeOperation.weeksLater(value, date);
36
+ if (unit === DurationUnit.Month)
37
+ return TimeOperation.monthsLater(value, date);
38
+ if (unit === DurationUnit.Year)
39
+ return TimeOperation.yearsLater(value, date);
40
+ throw new Error("Wrong unit");
41
+ }
42
+ static ago(value: number, unit: DurationUnit, date: Date | null = null)
43
+ {
44
+ return this.later(value * -1, unit, date);
45
+ }
46
+ static toMilliseconds(value: number, unit: DurationUnit): number
47
+ {
48
+ let milliseconds = 0;
49
+ if (unit === DurationUnit.Millisecond)
50
+ milliseconds = value;
51
+ else if (unit === DurationUnit.Second)
52
+ milliseconds = value * 1000;
53
+ else if (unit === DurationUnit.Minute)
54
+ milliseconds = value * 1000 * 60;
55
+ else if (unit === DurationUnit.Hour)
56
+ milliseconds = value * 1000 * 60 * 60;
57
+ else if (unit === DurationUnit.Day)
58
+ milliseconds = value * 1000 * 60 * 60 * 24;
59
+ else if (unit === DurationUnit.Week)
60
+ milliseconds = value * 1000 * 60 * 60 * 24 * 7;
61
+ else if (unit === DurationUnit.Month)
62
+ milliseconds = value * 1000 * 60 * 60 * 24 * 30;
63
+ else if (unit === DurationUnit.Year)
64
+ milliseconds = value * 1000 * 60 * 60 * 24 * 365;
65
+ return milliseconds;
66
+ }
67
+ static toSeconds(value: number, unit: DurationUnit): number
68
+ {
69
+ return Math.round(TimeUnitOperation.toMilliseconds(value, unit) / 1000);
70
+ }
71
+ static toMinutes(value: number, unit: DurationUnit): number
72
+ {
73
+ return Math.round(TimeUnitOperation.toSeconds(value, unit) / 60);
74
+ }
75
+ static toHours(value: number, unit: DurationUnit): number
76
+ {
77
+ return Math.round(TimeUnitOperation.toMinutes(value, unit) / 60);
78
+ }
79
+ static toDays(value: number, unit: DurationUnit): number
80
+ {
81
+ return Math.round(TimeUnitOperation.toHours(value, unit) / 24);
82
+ }
83
83
  }
@@ -1,67 +1,67 @@
1
- import { ParsedNameValue } from "./ParsedNameValue";
2
-
3
- export abstract class URLOperation
4
- {
5
- static getQuery(query?: { [name: string]: ParsedNameValue }): string
6
- {
7
- let ans = "";
8
- let first = true;
9
- if (query)
10
- for (const key of Object.keys(query))
11
- {
12
- let value = query[key];
13
- if (value != null)
14
- {
15
- if (first)
16
- ans += "?";
17
- else
18
- ans += "&";
19
- if (Array.isArray(value))
20
- value = value.join(",");
21
- ans += `${key}=${value}`;
22
- first = false;
23
- }
24
- }
25
- return ans;
26
- }
27
- static merge(...urlParts: string[]): string
28
- {
29
- let ans = "";
30
- for (let part of urlParts)
31
- {
32
- if (part)
33
- {
34
- if (ans)
35
- {
36
- if (part.startsWith('/'))
37
- part = part.substring(1);
38
- ans += "/";
39
- }
40
- ans += part;
41
- if (ans.endsWith('/'))
42
- ans = ans.substring(0, ans.length - 1);
43
- }
44
- }
45
- return ans;
46
- }
47
- static getSub(sub: string, query?: { [name: string]: ParsedNameValue }): string
48
- {
49
- return this.merge(sub, this.getQuery(query));
50
- }
51
- static getLink(domain: string, sub: string, query?: { [name: string]: ParsedNameValue }): string
52
- {
53
- return this.merge(domain, this.getSub(sub, query));
54
- }
55
- static isEqual(a: string, b: string): boolean
56
- {
57
- try
58
- {
59
- const url_a = new URL(a);
60
- const url_b = new URL(b);
61
- return url_a.origin === url_b.origin && url_a.pathname === url_b.pathname;
62
- } catch (e)
63
- {
64
- return a == b;
65
- }
66
- }
1
+ import { ParsedNameValue } from "./ParsedNameValue";
2
+
3
+ export abstract class URLOperation
4
+ {
5
+ static getQuery(query?: { [name: string]: ParsedNameValue }): string
6
+ {
7
+ let ans = "";
8
+ let first = true;
9
+ if (query)
10
+ for (const key of Object.keys(query))
11
+ {
12
+ let value = query[key];
13
+ if (value != null)
14
+ {
15
+ if (first)
16
+ ans += "?";
17
+ else
18
+ ans += "&";
19
+ if (Array.isArray(value))
20
+ value = value.join(",");
21
+ ans += `${key}=${value}`;
22
+ first = false;
23
+ }
24
+ }
25
+ return ans;
26
+ }
27
+ static merge(...urlParts: string[]): string
28
+ {
29
+ let ans = "";
30
+ for (let part of urlParts)
31
+ {
32
+ if (part)
33
+ {
34
+ if (ans)
35
+ {
36
+ if (part.startsWith('/'))
37
+ part = part.substring(1);
38
+ ans += "/";
39
+ }
40
+ ans += part;
41
+ if (ans.endsWith('/'))
42
+ ans = ans.substring(0, ans.length - 1);
43
+ }
44
+ }
45
+ return ans;
46
+ }
47
+ static getSub(sub: string, query?: { [name: string]: ParsedNameValue }): string
48
+ {
49
+ return this.merge(sub, this.getQuery(query));
50
+ }
51
+ static getLink(domain: string, sub: string, query?: { [name: string]: ParsedNameValue }): string
52
+ {
53
+ return this.merge(domain, this.getSub(sub, query));
54
+ }
55
+ static isEqual(a: string, b: string): boolean
56
+ {
57
+ try
58
+ {
59
+ const url_a = new URL(a);
60
+ const url_b = new URL(b);
61
+ return url_a.origin === url_b.origin && url_a.pathname === url_b.pathname;
62
+ } catch (e)
63
+ {
64
+ return a == b;
65
+ }
66
+ }
67
67
  }
@@ -1,47 +1,47 @@
1
- export class VersionOperation
2
- {
3
- static forEach(v1: string, v2: string, handler: (e1: number, e2: number) => boolean, onEqual: boolean): boolean
4
- {
5
- if (!v1 || !v2)
6
- return false;
7
- let t1s = v1.split('.');
8
- let t2s = v2.split('.');
9
- let len = Math.max(t1s.length, t2s.length);
10
- for (let i = 0; i < len; i++)
11
- {
12
- let e1 = 0;
13
- let e2 = 0;
14
- if (i < t1s.length)
15
- e1 = parseInt(t1s[i]);
16
- if (i < t2s.length)
17
- e2 = parseInt(t2s[i]);
18
- if (e1 != e2)
19
- return handler(e1, e2);
20
- }
21
- return onEqual;
22
- }
23
- static isGreaterThan(v1: string, v2: string): boolean
24
- {
25
- return this.forEach(v1, v2, (e1: number, e2: number) => e1 > e2, false);
26
- }
27
-
28
- static isLessThan(v1: string, v2: string): boolean
29
- {
30
- return this.forEach(v1, v2, (e1: number, e2: number) => e1 < e2, false);
31
- }
32
-
33
- static isEqual(v1: string, v2: string): boolean
34
- {
35
- return this.forEach(v1, v2, () => false, true);
36
- }
37
-
38
- static isGreaterThanOrEqual(v1: string, v2: string): boolean
39
- {
40
- return this.forEach(v1, v2, (e1: number, e2: number) => e1 > e2, true);
41
- }
42
-
43
- static isLessThanOrEqual(v1: string, v2: string): boolean
44
- {
45
- return this.forEach(v1, v2, (e1: number, e2: number) => e1 < e2, true);
46
- }
1
+ export class VersionOperation
2
+ {
3
+ static forEach(v1: string, v2: string, handler: (e1: number, e2: number) => boolean, onEqual: boolean): boolean
4
+ {
5
+ if (!v1 || !v2)
6
+ return false;
7
+ let t1s = v1.split('.');
8
+ let t2s = v2.split('.');
9
+ let len = Math.max(t1s.length, t2s.length);
10
+ for (let i = 0; i < len; i++)
11
+ {
12
+ let e1 = 0;
13
+ let e2 = 0;
14
+ if (i < t1s.length)
15
+ e1 = parseInt(t1s[i]);
16
+ if (i < t2s.length)
17
+ e2 = parseInt(t2s[i]);
18
+ if (e1 != e2)
19
+ return handler(e1, e2);
20
+ }
21
+ return onEqual;
22
+ }
23
+ static isGreaterThan(v1: string, v2: string): boolean
24
+ {
25
+ return this.forEach(v1, v2, (e1: number, e2: number) => e1 > e2, false);
26
+ }
27
+
28
+ static isLessThan(v1: string, v2: string): boolean
29
+ {
30
+ return this.forEach(v1, v2, (e1: number, e2: number) => e1 < e2, false);
31
+ }
32
+
33
+ static isEqual(v1: string, v2: string): boolean
34
+ {
35
+ return this.forEach(v1, v2, () => false, true);
36
+ }
37
+
38
+ static isGreaterThanOrEqual(v1: string, v2: string): boolean
39
+ {
40
+ return this.forEach(v1, v2, (e1: number, e2: number) => e1 > e2, true);
41
+ }
42
+
43
+ static isLessThanOrEqual(v1: string, v2: string): boolean
44
+ {
45
+ return this.forEach(v1, v2, (e1: number, e2: number) => e1 < e2, true);
46
+ }
47
47
  }
package/src/index.ts CHANGED
@@ -1,53 +1,53 @@
1
- export * from "./BaseDatabaseRow";
2
- export * from "./BaseLogger";
3
- export * from "./BaseMetaColumn";
4
- export * from "./BaseMetaDatabase";
5
- export * from "./BaseMetaTable";
6
- export * from "./BaseServer";
7
- export * from "./BaseUUID";
8
- export * from "./ByteOperation";
9
- export * from "./CacheService";
10
- export * from "./ColorOperation";
11
- export * from "./ConsoleOperation";
12
- export * from "./ConvertService";
13
- export * from "./CookieService";
14
- export * from "./Countries";
15
- export * from "./Country";
16
- export * from "./CountryOperation";
17
- export * from "./CronOperation";
18
- export * from "./EncodingOperation";
19
- export * from "./EnvService";
20
- export * from "./ErrorOperation";
21
- export * from "./FileOperation";
22
- export * from "./FilterItem";
23
- export * from "./FilterItemColumnType";
24
- export * from "./FilterItemOperator";
25
- export * from "./GeoOperation";
26
- export * from "./HashOperation";
27
- export * from "./HTTPError";
28
- export * from "./HTTPMethod";
29
- export * from "./ILogger";
30
- export * from "./IStorage";
31
- export * from "./IStorageCookie";
32
- export * from "./IStorageJsonFile";
33
- export * from "./IStorageLocal";
34
- export * from "./IStorageMemoryDedicated";
35
- export * from "./IStorageMemoryShared";
36
- export * from "./IStorageSession";
37
- export * from "./LogLevel";
38
- export * from "./NamingConvention";
39
- export * from "./ObjectService";
40
- export * from "./PackageService";
41
- export * from "./ParsedNameValue";
42
- export * from "./PasswordOperation";
43
- export * from "./PhoneOperation";
44
- export * from "./PriceOperation";
45
- export * from "./SearchOperation";
46
- export * from "./SetTimeouService";
47
- export * from "./SortItem";
48
- export * from "./StringOperation";
49
- export * from "./TimeOperation";
50
- export * from "./TimeUnitOperation";
51
- export * from "./TimeZone";
52
- export * from "./URLOperation";
1
+ export * from "./BaseDatabaseRow";
2
+ export * from "./BaseLogger";
3
+ export * from "./BaseMetaColumn";
4
+ export * from "./BaseMetaDatabase";
5
+ export * from "./BaseMetaTable";
6
+ export * from "./BaseServer";
7
+ export * from "./BaseUUID";
8
+ export * from "./ByteOperation";
9
+ export * from "./CacheService";
10
+ export * from "./ColorOperation";
11
+ export * from "./ConsoleOperation";
12
+ export * from "./ConvertService";
13
+ export * from "./CookieService";
14
+ export * from "./Countries";
15
+ export * from "./Country";
16
+ export * from "./CountryOperation";
17
+ export * from "./CronOperation";
18
+ export * from "./EncodingOperation";
19
+ export * from "./EnvService";
20
+ export * from "./ErrorOperation";
21
+ export * from "./FileOperation";
22
+ export * from "./FilterItem";
23
+ export * from "./FilterItemColumnType";
24
+ export * from "./FilterItemOperator";
25
+ export * from "./GeoOperation";
26
+ export * from "./HashOperation";
27
+ export * from "./HTTPError";
28
+ export * from "./HTTPMethod";
29
+ export * from "./ILogger";
30
+ export * from "./IStorage";
31
+ export * from "./IStorageCookie";
32
+ export * from "./IStorageJsonFile";
33
+ export * from "./IStorageLocal";
34
+ export * from "./IStorageMemoryDedicated";
35
+ export * from "./IStorageMemoryShared";
36
+ export * from "./IStorageSession";
37
+ export * from "./LogLevel";
38
+ export * from "./NamingConvention";
39
+ export * from "./ObjectService";
40
+ export * from "./PackageService";
41
+ export * from "./ParsedNameValue";
42
+ export * from "./PasswordOperation";
43
+ export * from "./PhoneOperation";
44
+ export * from "./PriceOperation";
45
+ export * from "./SearchOperation";
46
+ export * from "./SetTimeouService";
47
+ export * from "./SortItem";
48
+ export * from "./StringOperation";
49
+ export * from "./TimeOperation";
50
+ export * from "./TimeUnitOperation";
51
+ export * from "./TimeZone";
52
+ export * from "./URLOperation";
53
53
  export * from "./VersionOperation";