namirasoft-core 1.4.96 → 1.4.98

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.
@@ -0,0 +1,6 @@
1
+ export declare class CronOperation {
2
+ static splitPatterns(pattern: string): string[];
3
+ static isValid(pattern: string): boolean;
4
+ static check(pattern: string): void;
5
+ static getNumbers(pattern: string, min: number, max: number): number[];
6
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CronOperation = void 0;
4
+ class CronOperation {
5
+ static splitPatterns(pattern) {
6
+ return pattern.split(',').map(p => p.trim()).filter(p => p);
7
+ }
8
+ static isValid(pattern) {
9
+ let patterns = CronOperation.splitPatterns(pattern);
10
+ if (patterns.length == 0)
11
+ return false;
12
+ if (patterns.length == 1) {
13
+ let regexes = [/\*[/\d+]/gm, /\d+[/\d+]/gm, /\d+-\d+[/\d+]/gm];
14
+ for (let i = 0; i < regexes.length; i++)
15
+ if (regexes[i].test(patterns[0]))
16
+ return true;
17
+ return false;
18
+ }
19
+ for (let i = 0; i < patterns.length; i++)
20
+ if (!CronOperation.isValid(patterns[i]))
21
+ return false;
22
+ return true;
23
+ }
24
+ static check(pattern) {
25
+ if (!CronOperation.isValid(pattern))
26
+ throw new Error("Invalid schedule/cron format. Use one of: *, */5, 8, 0-10, 2-10/3, or a comma-separated list (e.g. 0,4,5-10/2).");
27
+ }
28
+ static getNumbers(pattern, min, max) {
29
+ let patterns = CronOperation.splitPatterns(pattern);
30
+ let ans = [];
31
+ for (let i = 0; i < patterns.length; i++) {
32
+ const element = patterns[i];
33
+ let ts = element.split('/').map(p => p.trim());
34
+ let step = ts.length == 1 ? 1 : parseInt(ts[1]);
35
+ if (element.includes("-")) {
36
+ let ns = element.split('-').map(p => p.trim());
37
+ let from = parseInt(ns[0]);
38
+ let to = parseInt(ns[1]);
39
+ for (let p = from; p <= to; p += step)
40
+ ans.push(p);
41
+ }
42
+ else if (element.includes("*"))
43
+ for (let p = min; p <= max; p += step)
44
+ ans.push(p);
45
+ else
46
+ ans.push(parseInt(element));
47
+ }
48
+ ans = ans.sort();
49
+ ans.forEach(p => {
50
+ if (p < min)
51
+ throw new Error(`Number must be more than or equal to ${min}`);
52
+ if (p > max)
53
+ throw new Error(`Number must be less than or equal to ${max}`);
54
+ });
55
+ return ans;
56
+ }
57
+ }
58
+ exports.CronOperation = CronOperation;
59
+ //# sourceMappingURL=CronOperation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CronOperation.js","sourceRoot":"","sources":["../src/CronOperation.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAa;IAEtB,MAAM,CAAC,aAAa,CAAC,OAAe;QAEhC,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;IACD,MAAM,CAAC,OAAO,CAAC,OAAe;QAE1B,IAAI,QAAQ,GAAG,aAAa,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACpD,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC;YACpB,OAAO,KAAK,CAAC;QACjB,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,EACxB,CAAC;YACG,IAAI,OAAO,GAAG,CAAC,YAAY,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAA;YAC9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE;gBACnC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;oBAC5B,OAAO,IAAI,CAAC;YACpB,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAA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GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;gBACzB,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI;oBACjC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACpB,CAAC;iBACI,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAC1B,KAAK,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,IAAI;oBACjC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;;gBAEhB,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QACpC,CAAC;QACD,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QACjB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YAEZ,IAAI,CAAC,GAAG,GAAG;gBACP,MAAM,IAAI,KAAK,CAAC,wCAAwC,GAAG,EAAE,CAAC,CAAC;YACnE,IAAI,CAAC,GAAG,GAAG;gBACP,MAAM,IAAI,KAAK,CAAC,wCAAwC,GAAG,EAAE,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,CAAC;IACf,CAAC;CACJ;AA9DD,sCA8DC"}
package/dist/index.d.ts CHANGED
@@ -7,11 +7,12 @@ export * from "./BaseUUID";
7
7
  export * from "./ByteOperation";
8
8
  export * from "./CacheService";
9
9
  export * from "./ConsoleOperation";
10
+ export * from "./ConvertService";
10
11
  export * from "./CookieService";
11
12
  export * from "./Countries";
12
- export * from "./ConvertService";
13
13
  export * from "./Country";
14
14
  export * from "./CountryOperation";
15
+ export * from "./CronOperation";
15
16
  export * from "./EncodingOperation";
16
17
  export * from "./EnvService";
17
18
  export * from "./ErrorOperation";
@@ -38,10 +39,10 @@ export * from "./PasswordOperation";
38
39
  export * from "./PhoneOperation";
39
40
  export * from "./PriceOperation";
40
41
  export * from "./SearchOperation";
42
+ export * from "./SetTimeouService";
41
43
  export * from "./SortItem";
42
44
  export * from "./StringOperation";
43
45
  export * from "./TimeOperation";
44
46
  export * from "./TimeUnitOperation";
45
- export * from "./SetTimeouService";
46
47
  export * from "./URLOperation";
47
48
  export * from "./VersionOperation";
package/dist/index.js CHANGED
@@ -23,11 +23,12 @@ __exportStar(require("./BaseUUID"), exports);
23
23
  __exportStar(require("./ByteOperation"), exports);
24
24
  __exportStar(require("./CacheService"), exports);
25
25
  __exportStar(require("./ConsoleOperation"), exports);
26
+ __exportStar(require("./ConvertService"), exports);
26
27
  __exportStar(require("./CookieService"), exports);
27
28
  __exportStar(require("./Countries"), exports);
28
- __exportStar(require("./ConvertService"), exports);
29
29
  __exportStar(require("./Country"), exports);
30
30
  __exportStar(require("./CountryOperation"), exports);
31
+ __exportStar(require("./CronOperation"), exports);
31
32
  __exportStar(require("./EncodingOperation"), exports);
32
33
  __exportStar(require("./EnvService"), exports);
33
34
  __exportStar(require("./ErrorOperation"), exports);
@@ -54,11 +55,11 @@ __exportStar(require("./PasswordOperation"), exports);
54
55
  __exportStar(require("./PhoneOperation"), exports);
55
56
  __exportStar(require("./PriceOperation"), exports);
56
57
  __exportStar(require("./SearchOperation"), exports);
58
+ __exportStar(require("./SetTimeouService"), exports);
57
59
  __exportStar(require("./SortItem"), exports);
58
60
  __exportStar(require("./StringOperation"), exports);
59
61
  __exportStar(require("./TimeOperation"), exports);
60
62
  __exportStar(require("./TimeUnitOperation"), exports);
61
- __exportStar(require("./SetTimeouService"), exports);
62
63
  __exportStar(require("./URLOperation"), exports);
63
64
  __exportStar(require("./VersionOperation"), exports);
64
65
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,mDAAiC;AACjC,qDAAmC;AACnC,kDAAgC;AAChC,+CAA6B;AAC7B,6CAA2B;AAC3B,kDAAgC;AAChC,iDAA+B;AAC/B,qDAAmC;AACnC,kDAAgC;AAChC,8CAA4B;AAC5B,mDAAiC;AACjC,4CAA0B;AAC1B,qDAAmC;AACnC,sDAAoC;AACpC,+CAA6B;AAC7B,mDAAiC;AACjC,kDAAgC;AAChC,+CAA6B;AAC7B,yDAAuC;AACvC,uDAAqC;AACrC,iDAA+B;AAC/B,kDAAgC;AAChC,8CAA4B;AAC5B,+CAA6B;AAC7B,6CAA2B;AAC3B,mDAAiC;AACjC,qDAAmC;AACnC,kDAAgC;AAChC,4DAA0C;AAC1C,yDAAuC;AACvC,oDAAkC;AAClC,qDAAmC;AACnC,kDAAgC;AAChC,mDAAiC;AACjC,oDAAkC;AAClC,sDAAoC;AACpC,mDAAiC;AACjC,mDAAiC;AACjC,oDAAkC;AAClC,6CAA2B;AAC3B,oDAAkC;AAClC,kDAAgC;AAChC,sDAAoC;AACpC,qDAAmC;AACnC,iDAA+B;AAC/B,qDAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,mDAAiC;AACjC,qDAAmC;AACnC,kDAAgC;AAChC,+CAA6B;AAC7B,6CAA2B;AAC3B,kDAAgC;AAChC,iDAA+B;AAC/B,qDAAmC;AACnC,mDAAiC;AACjC,kDAAgC;AAChC,8CAA4B;AAC5B,4CAA0B;AAC1B,qDAAmC;AACnC,kDAAgC;AAChC,sDAAoC;AACpC,+CAA6B;AAC7B,mDAAiC;AACjC,kDAAgC;AAChC,+CAA6B;AAC7B,yDAAuC;AACvC,uDAAqC;AACrC,iDAA+B;AAC/B,kDAAgC;AAChC,8CAA4B;AAC5B,+CAA6B;AAC7B,6CAA2B;AAC3B,mDAAiC;AACjC,qDAAmC;AACnC,kDAAgC;AAChC,4DAA0C;AAC1C,yDAAuC;AACvC,oDAAkC;AAClC,qDAAmC;AACnC,kDAAgC;AAChC,mDAAiC;AACjC,oDAAkC;AAClC,sDAAoC;AACpC,mDAAiC;AACjC,mDAAiC;AACjC,oDAAkC;AAClC,qDAAmC;AACnC,6CAA2B;AAC3B,oDAAkC;AAClC,kDAAgC;AAChC,sDAAoC;AACpC,iDAA+B;AAC/B,qDAAmC"}
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "framework": "npm",
9
9
  "application": "package",
10
10
  "private": false,
11
- "version": "1.4.96",
11
+ "version": "1.4.98",
12
12
  "author": "Amir Abolhasani",
13
13
  "license": "MIT",
14
14
  "main": "./dist/index.js",
@@ -17,7 +17,7 @@
17
17
  "build": ""
18
18
  },
19
19
  "dependencies": {
20
- "@types/node": "^24.7.0",
20
+ "@types/node": "^24.7.2",
21
21
  "async-mutex": "^0.5.0",
22
22
  "axios": "^1.12.2",
23
23
  "buffer": "^6.0.3",
@@ -0,0 +1,63 @@
1
+ export class CronOperation
2
+ {
3
+ static splitPatterns(pattern: string): string[]
4
+ {
5
+ return pattern.split(',').map(p => p.trim()).filter(p => p);
6
+ }
7
+ static isValid(pattern: string): boolean
8
+ {
9
+ let patterns = CronOperation.splitPatterns(pattern);
10
+ if (patterns.length == 0)
11
+ return false;
12
+ if (patterns.length == 1)
13
+ {
14
+ let regexes = [/\*[/\d+]/gm, /\d+[/\d+]/gm, /\d+-\d+[/\d+]/gm]
15
+ for (let i = 0; i < regexes.length; i++)
16
+ if (regexes[i].test(patterns[0]))
17
+ return true;
18
+ return false;
19
+ }
20
+ for (let i = 0; i < patterns.length; i++)
21
+ if (!CronOperation.isValid(patterns[i]))
22
+ return false;
23
+ return true;
24
+ }
25
+ static check(pattern: string): void
26
+ {
27
+ if (!CronOperation.isValid(pattern))
28
+ throw new Error("Invalid schedule/cron format. Use one of: *, */5, 8, 0-10, 2-10/3, or a comma-separated list (e.g. 0,4,5-10/2).");
29
+ }
30
+ static getNumbers(pattern: string, min: number, max: number): number[]
31
+ {
32
+ let patterns = CronOperation.splitPatterns(pattern);
33
+ let ans: number[] = [];
34
+ for (let i = 0; i < patterns.length; i++)
35
+ {
36
+ const element = patterns[i];
37
+ let ts = element.split('/').map(p => p.trim());
38
+ let step = ts.length == 1 ? 1 : parseInt(ts[1]);
39
+ if (element.includes("-"))
40
+ {
41
+ let ns = element.split('-').map(p => p.trim());
42
+ let from = parseInt(ns[0]);
43
+ let to = parseInt(ns[1]);
44
+ for (let p = from; p <= to; p += step)
45
+ ans.push(p);
46
+ }
47
+ else if (element.includes("*"))
48
+ for (let p = min; p <= max; p += step)
49
+ ans.push(p);
50
+ else
51
+ ans.push(parseInt(element));
52
+ }
53
+ ans = ans.sort();
54
+ ans.forEach(p =>
55
+ {
56
+ if (p < min)
57
+ throw new Error(`Number must be more than or equal to ${min}`);
58
+ if (p > max)
59
+ throw new Error(`Number must be less than or equal to ${max}`);
60
+ });
61
+ return ans;
62
+ }
63
+ }
package/src/index.ts CHANGED
@@ -7,11 +7,12 @@ export * from "./BaseUUID";
7
7
  export * from "./ByteOperation";
8
8
  export * from "./CacheService";
9
9
  export * from "./ConsoleOperation";
10
+ export * from "./ConvertService";
10
11
  export * from "./CookieService";
11
12
  export * from "./Countries";
12
- export * from "./ConvertService";
13
13
  export * from "./Country";
14
14
  export * from "./CountryOperation";
15
+ export * from "./CronOperation";
15
16
  export * from "./EncodingOperation";
16
17
  export * from "./EnvService";
17
18
  export * from "./ErrorOperation";
@@ -38,10 +39,10 @@ export * from "./PasswordOperation";
38
39
  export * from "./PhoneOperation";
39
40
  export * from "./PriceOperation";
40
41
  export * from "./SearchOperation";
42
+ export * from "./SetTimeouService";
41
43
  export * from "./SortItem";
42
44
  export * from "./StringOperation";
43
45
  export * from "./TimeOperation";
44
46
  export * from "./TimeUnitOperation";
45
- export * from "./SetTimeouService";
46
47
  export * from "./URLOperation";
47
48
  export * from "./VersionOperation";