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