@arkyn/shared 2.0.1-beta.14 → 2.0.1-beta.16
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/README.md +68 -55
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,100 +1,113 @@
|
|
|
1
|
-
|
|
1
|
+
The `@arkyn/shared` package provides reusable utilities such as formatting functions, generators, services, and validations. It is designed to be used across different parts of a project, offering common and practical solutions to streamline development.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
validations. It is designed to be used in different parts of a project, providing common and practical solutions.
|
|
3
|
+
---
|
|
5
4
|
|
|
6
5
|
## Installation
|
|
7
6
|
|
|
7
|
+
Install the package using npm:
|
|
8
|
+
|
|
8
9
|
```bash
|
|
9
10
|
npm install @arkyn/shared
|
|
10
11
|
```
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Features
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
### Formatting
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
Formats a date
|
|
19
|
+
- **`formatDate(date: Date): string`**
|
|
20
|
+
Formats a date into a readable string.
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
Converts a JSON object into a formatted string.
|
|
22
|
+
- **`formatJsonObject(obj: object): string`**
|
|
23
|
+
Converts a JSON object into a formatted string.
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
Converts a JSON string into an object.
|
|
25
|
+
- **`formatJsonString(json: string): object`**
|
|
26
|
+
Converts a JSON string into an object.
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
Formats a string into the CEP format (XXXXX-XXX).
|
|
28
|
+
- **`formatToCep(value: string): string`**
|
|
29
|
+
Formats a string into the CEP format (`XXXXX-XXX`).
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
Formats a string into the CNPJ format (XX.XXX.XXX/XXXX-XX).
|
|
31
|
+
- **`formatToCnpj(value: string): string`**
|
|
32
|
+
Formats a string into the CNPJ format (`XX.XXX.XXX/XXXX-XX`).
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
Formats a string into the CPF format (XXX.XXX.XXX-XX).
|
|
34
|
+
- **`formatToCpf(value: string): string`**
|
|
35
|
+
Formats a string into the CPF format (`XXX.XXX.XXX-XX`).
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
Formats a string into
|
|
37
|
+
- **`formatToCpfCnpj(value: string): string`**
|
|
38
|
+
Formats a string into either CPF or CNPJ format, depending on its length.
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
Converts a number
|
|
40
|
+
- **`formatToCurrency(value: number): string`**
|
|
41
|
+
Converts a number into a currency format.
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
Truncates a string and
|
|
43
|
+
- **`formatToEllipsis(value: string, maxLength: number): string`**
|
|
44
|
+
Truncates a string and appends an ellipsis if it exceeds the maximum length.
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
- **`formatToHiddenDigits(value: string): string`**
|
|
47
|
+
Masks part of a string by replacing it with asterisks.
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
Formats a string
|
|
49
|
+
- **`formatToPhone(value: string): string`**
|
|
50
|
+
Formats a string into a phone number format.
|
|
51
|
+
|
|
52
|
+
---
|
|
48
53
|
|
|
49
54
|
### Generators
|
|
50
55
|
|
|
51
|
-
|
|
52
|
-
Generates a hexadecimal color
|
|
56
|
+
- **`generateColorByString(value: string): string`**
|
|
57
|
+
Generates a hexadecimal color based on a string.
|
|
58
|
+
|
|
59
|
+
- **`generateId(): string`**
|
|
60
|
+
Generates a unique identifier.
|
|
53
61
|
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
- **`generateSlug(value: string): string`**
|
|
63
|
+
Converts a string into a URL-friendly slug.
|
|
56
64
|
|
|
57
|
-
|
|
58
|
-
Generates a URL-friendly slug from a string.
|
|
65
|
+
---
|
|
59
66
|
|
|
60
67
|
### Services
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
Calculates the installment
|
|
69
|
+
- **`calculateCardInstallment(total: number, installments: number): number[]`**
|
|
70
|
+
Calculates the installment values for a given total.
|
|
64
71
|
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
- **`maskSensitiveData(data: string): string`**
|
|
73
|
+
Masks sensitive data in a string.
|
|
67
74
|
|
|
68
|
-
|
|
69
|
-
Removes non-numeric characters from a string.
|
|
75
|
+
- **`removeNonNumeric(value: string): string`**
|
|
76
|
+
Removes all non-numeric characters from a string.
|
|
70
77
|
|
|
71
|
-
|
|
72
|
-
Truncates large fields in an object.
|
|
78
|
+
- **`truncateLargeFields(obj: object, maxLength: number): object`**
|
|
79
|
+
Truncates large fields in an object to a specified maximum length.
|
|
80
|
+
|
|
81
|
+
---
|
|
73
82
|
|
|
74
83
|
### Validations
|
|
75
84
|
|
|
76
|
-
|
|
77
|
-
Validates whether a string is a valid CEP.
|
|
85
|
+
- **`validateCep(value: string): boolean`**
|
|
86
|
+
Validates whether a string is a valid CEP.
|
|
87
|
+
|
|
88
|
+
- **`validateCnpj(value: string): boolean`**
|
|
89
|
+
Validates whether a string is a valid CNPJ.
|
|
78
90
|
|
|
79
|
-
|
|
80
|
-
Validates whether a string is a valid
|
|
91
|
+
- **`validateCpf(value: string): boolean`**
|
|
92
|
+
Validates whether a string is a valid CPF.
|
|
81
93
|
|
|
82
|
-
|
|
83
|
-
Validates whether a string is a valid
|
|
94
|
+
- **`validateDate(value: string): boolean`**
|
|
95
|
+
Validates whether a string is a valid date.
|
|
84
96
|
|
|
85
|
-
|
|
86
|
-
Validates whether a string is a valid
|
|
97
|
+
- **`validatePhone(value: string): boolean`**
|
|
98
|
+
Validates whether a string is a valid phone number.
|
|
87
99
|
|
|
88
|
-
|
|
89
|
-
Validates whether a string is a valid
|
|
100
|
+
- **`validateRg(value: string): boolean`**
|
|
101
|
+
Validates whether a string is a valid ID (RG).
|
|
90
102
|
|
|
91
|
-
|
|
92
|
-
Validates whether a string is a valid ID.
|
|
103
|
+
---
|
|
93
104
|
|
|
94
105
|
## Contribution
|
|
95
106
|
|
|
96
|
-
Contributions are welcome! Feel free to open issues or submit pull requests.
|
|
107
|
+
Contributions are welcome! Feel free to open issues or submit pull requests to improve the project.
|
|
108
|
+
|
|
109
|
+
---
|
|
97
110
|
|
|
98
111
|
## License
|
|
99
112
|
|
|
100
|
-
MIT
|
|
113
|
+
This project is licensed under the MIT License. See the `LICENSE` file for more details.
|