namirasoft-core 1.2.0 → 1.2.2

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.
@@ -1,65 +1,65 @@
1
- import fs from "fs";
2
- import { FileOperation } from "./FileOperation";
3
-
4
- export class PackageService
5
- {
6
- static get(path: string): PackageService
7
- {
8
- if (path)
9
- {
10
- const json = JSON.parse(fs.readFileSync(path, 'utf8'));
11
- if (json)
12
- return new PackageService(path, json);
13
- }
14
- throw new Error("Coundn't find package");
15
- }
16
- static getMain(): PackageService
17
- {
18
- const paths = FileOperation.findUp('package.json');
19
- if (paths)
20
- return this.get(paths[paths.length - 1]);
21
- throw new Error("Coundn't find package");
22
- }
23
- static getThis(): PackageService
24
- {
25
- const paths = FileOperation.findUp('package.json');
26
- if (paths)
27
- return this.get(paths[0]);
28
- throw new Error("Coundn't find package");
29
- }
30
- private path: string;
31
- private json: any;
32
- constructor(path: string, json: any)
33
- {
34
- this.json = json;
35
- this.path = path;
36
- }
37
- getPath(): string
38
- {
39
- return this.path;
40
- }
41
- getName(): string
42
- {
43
- return this.json.name;
44
- }
45
- getTitle(): string
46
- {
47
- return this.json.title;
48
- }
49
- getDescription(): string
50
- {
51
- return this.json.description;
52
- }
53
- getIcon(): string
54
- {
55
- return this.json.icon;
56
- }
57
- getLogo(): string
58
- {
59
- return this.json.logo;
60
- }
61
- getVersion(): string
62
- {
63
- return this.json.version;
64
- }
1
+ import fs from "fs";
2
+ import { FileOperation } from "./FileOperation";
3
+
4
+ export class PackageService
5
+ {
6
+ static get(path: string): PackageService
7
+ {
8
+ if (path)
9
+ {
10
+ const json = JSON.parse(fs.readFileSync(path, 'utf8'));
11
+ if (json)
12
+ return new PackageService(path, json);
13
+ }
14
+ throw new Error("Coundn't find package");
15
+ }
16
+ static getMain(): PackageService
17
+ {
18
+ const paths = FileOperation.findUp('package.json');
19
+ if (paths)
20
+ return this.get(paths[paths.length - 1]);
21
+ throw new Error("Coundn't find package");
22
+ }
23
+ static getThis(): PackageService
24
+ {
25
+ const paths = FileOperation.findUp('package.json');
26
+ if (paths)
27
+ return this.get(paths[0]);
28
+ throw new Error("Coundn't find package");
29
+ }
30
+ private path: string;
31
+ private json: any;
32
+ constructor(path: string, json: any)
33
+ {
34
+ this.json = json;
35
+ this.path = path;
36
+ }
37
+ getPath(): string
38
+ {
39
+ return this.path;
40
+ }
41
+ getName(): string
42
+ {
43
+ return this.json.name;
44
+ }
45
+ getTitle(): string
46
+ {
47
+ return this.json.title;
48
+ }
49
+ getDescription(): string
50
+ {
51
+ return this.json.description;
52
+ }
53
+ getIcon(): string
54
+ {
55
+ return this.json.icon;
56
+ }
57
+ getLogo(): string
58
+ {
59
+ return this.json.logo;
60
+ }
61
+ getVersion(): string
62
+ {
63
+ return this.json.version;
64
+ }
65
65
  }
@@ -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
  }
@@ -1,15 +1,15 @@
1
- import md5 from 'md5';
2
- export class SignOperation
3
- {
4
- static sign(key: string, values: any)
5
- {
6
- let message = key;
7
- for (let i in values)
8
- message += "-" + values[i];
9
- return md5(message);
10
- }
11
- static isValid(key: string, values: any, signature: string)
12
- {
13
- return this.sign(key, values).toLowerCase() === signature.toLowerCase();
14
- }
1
+ import md5 from 'md5';
2
+ export class SignOperation
3
+ {
4
+ static sign(key: string, values: any)
5
+ {
6
+ let message = key;
7
+ for (let i in values)
8
+ message += "-" + values[i];
9
+ return md5(message);
10
+ }
11
+ static isValid(key: string, values: any, signature: string)
12
+ {
13
+ return this.sign(key, values).toLowerCase() === signature.toLowerCase();
14
+ }
15
15
  }
@@ -1,19 +1,19 @@
1
- export class StringOperation
2
- {
3
- static format(string: string, ...args: string[]): string
4
- {
5
- return string.replace(/{(\d+)}/g, (match, index) =>
6
- {
7
- const arg = args[index];
8
- return typeof arg !== 'undefined' ? arg : match;
9
- });
10
- }
11
- static repair(value: string): string
12
- {
13
- if (value == null)
14
- value = '';
15
- value = value.replace(/\s\s+/gm, ' ');
16
- value = value.trim();
17
- return value;
18
- }
1
+ export class StringOperation
2
+ {
3
+ static format(string: string, ...args: string[]): string
4
+ {
5
+ return string.replace(/{(\d+)}/g, (match, index) =>
6
+ {
7
+ const arg = args[index];
8
+ return typeof arg !== 'undefined' ? arg : match;
9
+ });
10
+ }
11
+ static repair(value: string): string
12
+ {
13
+ if (value == null)
14
+ value = '';
15
+ value = value.replace(/\s\s+/gm, ' ');
16
+ value = value.trim();
17
+ return value;
18
+ }
19
19
  }