@arkyn/shared 3.0.1-beta.20 → 3.0.1-beta.201
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 +344 -69
- package/dist/formats/formatDate.d.ts +18 -26
- package/dist/formats/formatDate.d.ts.map +1 -1
- package/dist/formats/formatJsonObject.d.ts +5 -7
- package/dist/formats/formatJsonObject.d.ts.map +1 -1
- package/dist/formats/formatJsonString.d.ts +5 -21
- package/dist/formats/formatJsonString.d.ts.map +1 -1
- package/dist/formats/formatToCapitalizeFirstWordLetter.d.ts +5 -24
- package/dist/formats/formatToCapitalizeFirstWordLetter.d.ts.map +1 -1
- package/dist/formats/formatToCep.d.ts +3 -11
- package/dist/formats/formatToCep.d.ts.map +1 -1
- package/dist/formats/formatToCnpj.d.ts +3 -14
- package/dist/formats/formatToCnpj.d.ts.map +1 -1
- package/dist/formats/formatToCpf.d.ts +4 -13
- package/dist/formats/formatToCpf.d.ts.map +1 -1
- package/dist/formats/formatToCurrency.d.ts +10 -23
- package/dist/formats/formatToCurrency.d.ts.map +1 -1
- package/dist/formats/formatToEllipsis.d.ts +5 -5
- package/dist/formats/formatToEllipsis.d.ts.map +1 -1
- package/dist/formats/formatToHiddenDigits.d.ts +15 -26
- package/dist/formats/formatToHiddenDigits.d.ts.map +1 -1
- package/dist/formats/formatToPhone.d.ts +11 -23
- package/dist/formats/formatToPhone.d.ts.map +1 -1
- package/dist/generators/generateColorByString.d.ts +6 -4
- package/dist/generators/generateColorByString.d.ts.map +1 -1
- package/dist/generators/generateId.d.ts +8 -19
- package/dist/generators/generateId.d.ts.map +1 -1
- package/dist/generators/generateSlug.d.ts +8 -2
- package/dist/generators/generateSlug.d.ts.map +1 -1
- package/dist/index.d.ts +11 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +371 -34
- package/dist/modules/formats/formatDate.js +35 -0
- package/dist/modules/formats/formatJsonObject.js +23 -0
- package/dist/modules/formats/formatJsonString.js +11 -0
- package/dist/modules/formats/formatToCapitalizeFirstWordLetter.js +6 -0
- package/dist/modules/formats/formatToCep.js +9 -0
- package/dist/modules/formats/formatToCnpj.js +9 -0
- package/dist/modules/formats/formatToCpf.js +9 -0
- package/dist/modules/formats/formatToCurrency.js +13 -0
- package/dist/modules/formats/formatToEllipsis.js +10 -0
- package/dist/modules/formats/formatToHiddenDigits.js +22 -0
- package/dist/modules/formats/formatToPhone.js +14 -0
- package/dist/modules/generators/generateColorByString.js +9 -0
- package/dist/modules/generators/generateId.js +32 -0
- package/dist/modules/generators/generateSlug.js +7 -0
- package/dist/modules/index.js +26 -0
- package/dist/modules/parsers/parseLargeFields.js +17 -0
- package/dist/modules/parsers/parseSensitiveData.js +28 -0
- package/dist/modules/parsers/parseToDate.js +23 -0
- package/dist/modules/services/validateDateService.js +61 -0
- package/dist/modules/utilities/calculateCardInstallment.js +17 -0
- package/dist/modules/utilities/ensureQuotes.js +7 -0
- package/dist/modules/utilities/findCountryMask.js +23 -0
- package/dist/modules/utilities/isHtml.js +6 -0
- package/dist/modules/utilities/removeCurrencySymbols.js +6 -0
- package/dist/modules/utilities/removeNonNumeric.js +6 -0
- package/dist/modules/utilities/stripHtmlTags.js +6 -0
- package/dist/{services/truncateLargeFields.d.ts → parsers/parseLargeFields.d.ts} +5 -8
- package/dist/parsers/parseLargeFields.d.ts.map +1 -0
- package/dist/parsers/parseSensitiveData.d.ts +22 -0
- package/dist/parsers/parseSensitiveData.d.ts.map +1 -0
- package/dist/parsers/parseToDate.d.ts +25 -0
- package/dist/parsers/parseToDate.d.ts.map +1 -0
- package/dist/services/validateDateService.d.ts +34 -0
- package/dist/services/validateDateService.d.ts.map +1 -0
- package/dist/utilities/calculateCardInstallment.d.ts +25 -0
- package/dist/utilities/calculateCardInstallment.d.ts.map +1 -0
- package/dist/utilities/ensureQuotes.d.ts +20 -0
- package/dist/utilities/ensureQuotes.d.ts.map +1 -0
- package/dist/utilities/findCountryMask.d.ts +21 -0
- package/dist/utilities/findCountryMask.d.ts.map +1 -0
- package/dist/utilities/isHtml.d.ts +21 -0
- package/dist/utilities/isHtml.d.ts.map +1 -0
- package/dist/{services/removeCurrencySymbols.js → utilities/removeCurrencySymbols.d.ts} +6 -7
- package/dist/utilities/removeCurrencySymbols.d.ts.map +1 -0
- package/dist/utilities/removeNonNumeric.d.ts +15 -0
- package/dist/utilities/removeNonNumeric.d.ts.map +1 -0
- package/dist/utilities/stripHtmlTags.d.ts +18 -0
- package/dist/utilities/stripHtmlTags.d.ts.map +1 -0
- package/package.json +183 -13
- package/dist/formats/formatDate.js +0 -66
- package/dist/formats/formatJsonObject.js +0 -90
- package/dist/formats/formatJsonString.js +0 -46
- package/dist/formats/formatToCapitalizeFirstWordLetter.js +0 -42
- package/dist/formats/formatToCep.js +0 -34
- package/dist/formats/formatToCnpj.js +0 -35
- package/dist/formats/formatToCpf.js +0 -35
- package/dist/formats/formatToCpfCnpj.d.ts +0 -24
- package/dist/formats/formatToCpfCnpj.d.ts.map +0 -1
- package/dist/formats/formatToCpfCnpj.js +0 -33
- package/dist/formats/formatToCurrency.js +0 -41
- package/dist/formats/formatToDate.d.ts +0 -32
- package/dist/formats/formatToDate.d.ts.map +0 -1
- package/dist/formats/formatToDate.js +0 -50
- package/dist/formats/formatToEllipsis.js +0 -21
- package/dist/formats/formatToHiddenDigits.js +0 -60
- package/dist/formats/formatToPhone.js +0 -131
- package/dist/generators/generateColorByString.js +0 -25
- package/dist/generators/generateId.js +0 -29
- package/dist/generators/generateSlug.js +0 -25
- package/dist/services/calculateCardInstallment.d.ts +0 -40
- package/dist/services/calculateCardInstallment.d.ts.map +0 -1
- package/dist/services/calculateCardInstallment.js +0 -55
- package/dist/services/ensureQuotes.d.ts +0 -14
- package/dist/services/ensureQuotes.d.ts.map +0 -1
- package/dist/services/ensureQuotes.js +0 -19
- package/dist/services/maskSensitiveData.d.ts +0 -26
- package/dist/services/maskSensitiveData.d.ts.map +0 -1
- package/dist/services/maskSensitiveData.js +0 -60
- package/dist/services/removeCurrencySymbols.d.ts +0 -21
- package/dist/services/removeCurrencySymbols.d.ts.map +0 -1
- package/dist/services/removeNonNumeric.d.ts +0 -16
- package/dist/services/removeNonNumeric.d.ts.map +0 -1
- package/dist/services/removeNonNumeric.js +0 -16
- package/dist/services/stripHtmlTags.d.ts +0 -16
- package/dist/services/stripHtmlTags.d.ts.map +0 -1
- package/dist/services/stripHtmlTags.js +0 -16
- package/dist/services/truncateLargeFields.d.ts.map +0 -1
- package/dist/services/truncateLargeFields.js +0 -57
- package/dist/validations/validateCep.d.ts +0 -24
- package/dist/validations/validateCep.d.ts.map +0 -1
- package/dist/validations/validateCep.js +0 -33
- package/dist/validations/validateCnpj.d.ts +0 -22
- package/dist/validations/validateCnpj.d.ts.map +0 -1
- package/dist/validations/validateCnpj.js +0 -52
- package/dist/validations/validateCpf.d.ts +0 -24
- package/dist/validations/validateCpf.d.ts.map +0 -1
- package/dist/validations/validateCpf.js +0 -54
- package/dist/validations/validateDate.d.ts +0 -34
- package/dist/validations/validateDate.d.ts.map +0 -1
- package/dist/validations/validateDate.js +0 -73
- package/dist/validations/validatePassword.d.ts +0 -21
- package/dist/validations/validatePassword.d.ts.map +0 -1
- package/dist/validations/validatePassword.js +0 -34
- package/dist/validations/validatePhone.d.ts +0 -29
- package/dist/validations/validatePhone.d.ts.map +0 -1
- package/dist/validations/validatePhone.js +0 -44
- package/dist/validations/validateRg.d.ts +0 -22
- package/dist/validations/validateRg.d.ts.map +0 -1
- package/dist/validations/validateRg.js +0 -31
- package/src/formats/formatDate.ts +0 -92
- package/src/formats/formatJsonObject.ts +0 -90
- package/src/formats/formatJsonString.ts +0 -50
- package/src/formats/formatToCapitalizeFirstWordLetter.ts +0 -46
- package/src/formats/formatToCep.ts +0 -39
- package/src/formats/formatToCnpj.ts +0 -40
- package/src/formats/formatToCpf.ts +0 -40
- package/src/formats/formatToCpfCnpj.ts +0 -38
- package/src/formats/formatToCurrency.ts +0 -63
- package/src/formats/formatToDate.ts +0 -70
- package/src/formats/formatToEllipsis.ts +0 -25
- package/src/formats/formatToHiddenDigits.ts +0 -92
- package/src/formats/formatToPhone.ts +0 -170
- package/src/generators/generateColorByString.ts +0 -33
- package/src/generators/generateId.ts +0 -61
- package/src/generators/generateSlug.ts +0 -31
- package/src/index.ts +0 -37
- package/src/services/calculateCardInstallment.ts +0 -73
- package/src/services/ensureQuotes.ts +0 -25
- package/src/services/maskSensitiveData.ts +0 -68
- package/src/services/removeCurrencySymbols.ts +0 -29
- package/src/services/removeNonNumeric.ts +0 -20
- package/src/services/stripHtmlTags.ts +0 -20
- package/src/services/truncateLargeFields.ts +0 -69
- package/src/validations/validateCep.ts +0 -41
- package/src/validations/validateCnpj.ts +0 -65
- package/src/validations/validateCpf.ts +0 -62
- package/src/validations/validateDate.ts +0 -86
- package/src/validations/validatePassword.ts +0 -41
- package/src/validations/validatePhone.ts +0 -50
- package/src/validations/validateRg.ts +0 -37
- package/tsconfig.json +0 -20
- package/vitest.config.ts +0 -5
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
type FormatToCepFunction = (value: string) => string;
|
|
2
1
|
/**
|
|
3
2
|
* Formats a given string into a Brazilian postal code (CEP) format.
|
|
4
3
|
*
|
|
@@ -6,24 +5,17 @@ type FormatToCepFunction = (value: string) => string;
|
|
|
6
5
|
* and attempts to format it as a CEP in the pattern `XXXXX-XXX`.
|
|
7
6
|
* If the input does not match the expected format, an error is thrown.
|
|
8
7
|
*
|
|
9
|
-
* @param value -
|
|
8
|
+
* @param value - Input string with 8 numeric digits (special characters are stripped).
|
|
10
9
|
* @returns The formatted CEP string in the pattern `XXXXX-XXX`.
|
|
10
|
+
*
|
|
11
11
|
* @throws {Error} If the input does not match the expected CEP format.
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```typescript
|
|
15
|
-
* import { formatToCep } from "./formatToCep";
|
|
16
|
-
*
|
|
17
15
|
* const formattedCep = formatToCep("12345678");
|
|
18
16
|
* console.log(formattedCep); // Output: "12345-678"
|
|
19
|
-
*
|
|
20
|
-
* try {
|
|
21
|
-
* formatToCep("1234");
|
|
22
|
-
* } catch (error) {
|
|
23
|
-
* console.error(error.message); // Output: "Invalid CEP format"
|
|
24
|
-
* }
|
|
25
17
|
* ```
|
|
26
18
|
*/
|
|
27
|
-
declare
|
|
19
|
+
declare function formatToCep(value: string): string;
|
|
28
20
|
export { formatToCep };
|
|
29
21
|
//# sourceMappingURL=formatToCep.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatToCep.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCep.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"formatToCep.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCep.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAEH,iBAAS,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ1C;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1,30 +1,19 @@
|
|
|
1
|
-
type FormatToCnpjFunction = (value: string) => string;
|
|
2
1
|
/**
|
|
3
2
|
* Formats a given string or number into a CNPJ (Cadastro Nacional da Pessoa Jurídica) format.
|
|
4
3
|
*
|
|
5
4
|
* The CNPJ format is: `XX.XXX.XXX/XXXX-XX`, where `X` represents a digit.
|
|
6
5
|
*
|
|
7
|
-
* @param value -
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @returns A string formatted as a CNPJ.
|
|
6
|
+
* @param value - Input string with 14 numeric digits (special characters are stripped).
|
|
7
|
+
* @returns The formatted CNPJ string in the pattern `XX.XXX.XXX/XXXX-XX`.
|
|
11
8
|
*
|
|
12
9
|
* @throws {Error} Throws an error if the input does not contain exactly 14 numeric digits.
|
|
13
10
|
*
|
|
14
11
|
* @example
|
|
15
12
|
* ```typescript
|
|
16
|
-
* import { formatToCnpj } from "./formatToCNPJ";
|
|
17
|
-
*
|
|
18
13
|
* const formattedCnpj = formatToCnpj("12345678000195");
|
|
19
14
|
* console.log(formattedCnpj); // Output: "12.345.678/0001-95"
|
|
20
|
-
*
|
|
21
|
-
* try {
|
|
22
|
-
* formatToCnpj("12345");
|
|
23
|
-
* } catch (error) {
|
|
24
|
-
* console.error(error.message); // Output: "Invalid CNPJ length"
|
|
25
|
-
* }
|
|
26
15
|
* ```
|
|
27
16
|
*/
|
|
28
|
-
declare
|
|
17
|
+
declare function formatToCnpj(value: string): string;
|
|
29
18
|
export { formatToCnpj };
|
|
30
19
|
//# sourceMappingURL=formatToCnpj.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatToCnpj.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCnpj.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"formatToCnpj.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCnpj.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AAEH,iBAAS,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ3C;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
type FormatToCpfFunction = (value: string) => string;
|
|
2
1
|
/**
|
|
3
2
|
* Formats a given string into a CPF (Cadastro de Pessoas Físicas) format.
|
|
4
3
|
*
|
|
@@ -6,25 +5,17 @@ type FormatToCpfFunction = (value: string) => string;
|
|
|
6
5
|
* This function ensures the input is cleaned of non-numeric characters and
|
|
7
6
|
* then formats it into the standard CPF format: `XXX.XXX.XXX-XX`.
|
|
8
7
|
*
|
|
9
|
-
* @param value -
|
|
10
|
-
* @returns The formatted CPF string.
|
|
8
|
+
* @param value - Input string with 11 numeric digits (special characters are stripped).
|
|
9
|
+
* @returns The formatted CPF string in the pattern `XXX.XXX.XXX-XX`.
|
|
10
|
+
*
|
|
11
11
|
* @throws {Error} If the input string does not match the expected CPF format.
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```typescript
|
|
15
|
-
* import { formatToCpf } from "./formatToCPF";
|
|
16
|
-
*
|
|
17
15
|
* const formattedCpf = formatToCpf("12345678909");
|
|
18
16
|
* console.log(formattedCpf); // Output: "123.456.789-09"
|
|
19
|
-
|
|
20
|
-
* try {
|
|
21
|
-
* const formattedCpf = formatToCpf("12345");
|
|
22
|
-
* } catch (error) {
|
|
23
|
-
* console.error(error.message); // Output: "Invalid CPF format"
|
|
24
|
-
* }
|
|
25
|
-
*
|
|
26
17
|
* ```
|
|
27
18
|
*/
|
|
28
|
-
declare
|
|
19
|
+
declare function formatToCpf(value: string): string;
|
|
29
20
|
export { formatToCpf };
|
|
30
21
|
//# sourceMappingURL=formatToCpf.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatToCpf.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCpf.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"formatToCpf.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCpf.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAEH,iBAAS,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ1C;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1,34 +1,21 @@
|
|
|
1
1
|
import { countryCurrencies } from "@arkyn/templates";
|
|
2
2
|
type Currencies = keyof typeof countryCurrencies;
|
|
3
|
-
type Config = {
|
|
4
|
-
showPrefix?: boolean;
|
|
5
|
-
};
|
|
6
|
-
type FormatToCurrency = (value: number, currency: Currencies, config?: Config) => string;
|
|
7
3
|
/**
|
|
8
|
-
* Formats a
|
|
9
|
-
*
|
|
10
|
-
* @param value - The numeric value to be formatted.
|
|
11
|
-
* @param currency - The currency code used to determine the formatting style.
|
|
12
|
-
* @param config - Optional configuration object.
|
|
13
|
-
* @param config.showPrefix - Determines whether the currency symbol/prefix should be included in the formatted string. Defaults to `true`.
|
|
4
|
+
* Formats a number into a locale-aware currency string using `Intl.NumberFormat`.
|
|
14
5
|
*
|
|
15
|
-
* @
|
|
6
|
+
* @param value - The numeric value to format.
|
|
7
|
+
* @param currency - A currency code from `@arkyn/templates` (e.g. `"BRL"`, `"USD"`).
|
|
8
|
+
* @param config.showPrefix - Whether to include the currency symbol. Defaults to `true`.
|
|
9
|
+
* @returns The formatted currency string.
|
|
16
10
|
*
|
|
17
11
|
* @example
|
|
18
12
|
* ```typescript
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* const withoutPrefix = formatToCurrency(1234.56, "USD", { showPrefix: false });
|
|
23
|
-
* console.log(withoutPrefix); // "1,234.56"
|
|
24
|
-
*
|
|
25
|
-
* const formattedBRL = formatToCurrency(1234.56, "BRL", { showPrefix: true });
|
|
26
|
-
* console.log(formattedBRL); // "R$ 1.234,56"
|
|
27
|
-
*
|
|
28
|
-
* const withoutPrefixBRL = formatToCurrency(1234.56, "BRL", { showPrefix: false });
|
|
29
|
-
* console.log(withoutPrefixBRL); // "1.234,56"
|
|
13
|
+
* formatToCurrency(1234.56, "BRL"); // "R$ 1.234,56"
|
|
14
|
+
* formatToCurrency(1234.56, "USD", { showPrefix: false }); // "1,234.56"
|
|
30
15
|
* ```
|
|
31
16
|
*/
|
|
32
|
-
declare
|
|
17
|
+
declare function formatToCurrency(value: number, currency: Currencies, config?: {
|
|
18
|
+
showPrefix?: boolean;
|
|
19
|
+
}): string;
|
|
33
20
|
export { formatToCurrency };
|
|
34
21
|
//# sourceMappingURL=formatToCurrency.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatToCurrency.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCurrency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,KAAK,UAAU,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAEjD
|
|
1
|
+
{"version":3,"file":"formatToCurrency.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCurrency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,KAAK,UAAU,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAEjD;;;;;;;;;;;;;GAaG;AACH,iBAAS,gBAAgB,CACxB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,UAAU,EACpB,MAAM,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAC/B,MAAM,CAiBR;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
type FormatToEllipsisFunction = (value: string, maxLength: number) => string;
|
|
2
1
|
/**
|
|
3
2
|
* Truncates a given text to a specified maximum length and appends an ellipsis ("...")
|
|
4
3
|
* if the text exceeds the maximum length.
|
|
5
4
|
*
|
|
6
5
|
* @param text - The input string to be truncated.
|
|
7
|
-
* @param maxLength -
|
|
8
|
-
* @returns The truncated string with
|
|
9
|
-
* or the original string if it does not.
|
|
6
|
+
* @param maxLength - Maximum allowed length before truncation.
|
|
7
|
+
* @returns The truncated string with `"..."` appended, or the original string if it fits.
|
|
10
8
|
* @example
|
|
9
|
+
* ```typescript
|
|
11
10
|
* const result = formatToEllipsis("Hello, world!", 5);
|
|
12
11
|
* console.log(result); // Output: "Hello..."
|
|
12
|
+
* ```
|
|
13
13
|
*/
|
|
14
|
-
declare
|
|
14
|
+
declare function formatToEllipsis(text: string, maxLength: number): string;
|
|
15
15
|
export { formatToEllipsis };
|
|
16
16
|
//# sourceMappingURL=formatToEllipsis.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatToEllipsis.d.ts","sourceRoot":"","sources":["../../src/formats/formatToEllipsis.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"formatToEllipsis.d.ts","sourceRoot":"","sources":["../../src/formats/formatToEllipsis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,iBAAS,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAsBjE;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,35 +1,24 @@
|
|
|
1
|
-
type FormatToHiddenDigitsFunction = (value: string, options: {
|
|
2
|
-
range?: number | [number, number];
|
|
3
|
-
hider?: string;
|
|
4
|
-
}) => string;
|
|
5
1
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* This function takes a string input and replaces digits within a specified range
|
|
9
|
-
* with a hiding character (e.g., "*"). Non-digit characters remain unchanged.
|
|
10
|
-
*
|
|
11
|
-
* @param value - The input string to be formatted.
|
|
12
|
-
* @param options - Configuration options for formatting.
|
|
13
|
-
* @param options.range - The range of digits to hide. It can be:
|
|
14
|
-
* - A single number (e.g., `3`), which hides the first `n` digits if positive,
|
|
15
|
-
* or the last `n` digits if negative.
|
|
16
|
-
* - A tuple `[start, end]` specifying the range of digits to hide (inclusive).
|
|
17
|
-
* - Defaults to `3`, hiding the first three digits.
|
|
18
|
-
* @param options.hider - The character used to hide digits. Defaults to `"*"`.
|
|
2
|
+
* Replaces specific digits in a string with a masking character, leaving non-digit characters unchanged.
|
|
19
3
|
*
|
|
20
|
-
* @
|
|
4
|
+
* @param value - The input string to mask.
|
|
5
|
+
* @param options.range - Which digits to hide:
|
|
6
|
+
* - Positive number `n` — hides the first `n` digits.
|
|
7
|
+
* - Negative number `-n` — hides the last `n` digits.
|
|
8
|
+
* - Tuple `[start, end]` — hides digits from position `start` to `end` (inclusive, 1-indexed).
|
|
9
|
+
* - Defaults to `3`.
|
|
10
|
+
* @param options.hider - The masking character. Defaults to `"*"`.
|
|
11
|
+
* @returns The string with the specified digit positions replaced.
|
|
21
12
|
*
|
|
22
13
|
* @example
|
|
23
14
|
* ```typescript
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* formatToHiddenDigits("123-456-7890", { range: 3 });
|
|
27
|
-
* // Output: "***-456-7890"
|
|
28
|
-
*
|
|
29
|
-
* formatToHiddenDigits("123-456-7890", { range: [4, 6], hider: "#" });
|
|
30
|
-
* // Output: "123-###-7890"
|
|
15
|
+
* formatToHiddenDigits("123-456-7890", { range: 3 }); // "***-456-7890"
|
|
16
|
+
* formatToHiddenDigits("123-456-7890", { range: [4, 6], hider: "#" }); // "123-###-7890"
|
|
31
17
|
* ```
|
|
32
18
|
*/
|
|
33
|
-
declare
|
|
19
|
+
declare function formatToHiddenDigits(value: string, options?: {
|
|
20
|
+
range?: number | [number, number];
|
|
21
|
+
hider?: string;
|
|
22
|
+
}): string;
|
|
34
23
|
export { formatToHiddenDigits };
|
|
35
24
|
//# sourceMappingURL=formatToHiddenDigits.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatToHiddenDigits.d.ts","sourceRoot":"","sources":["../../src/formats/formatToHiddenDigits.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatToHiddenDigits.d.ts","sourceRoot":"","sources":["../../src/formats/formatToHiddenDigits.ts"],"names":[],"mappings":"AA6CA;;;;;;;;;;;;;;;;;GAiBG;AAEH,iBAAS,oBAAoB,CAC5B,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7D,MAAM,CAWR;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -1,34 +1,22 @@
|
|
|
1
|
-
type FormatToPhoneFunction = (prop: string) => string;
|
|
2
1
|
/**
|
|
3
|
-
* Formats a phone number string
|
|
2
|
+
* Formats a phone number string according to the country mask defined in `@arkyn/templates`.
|
|
4
3
|
*
|
|
5
|
-
* The
|
|
6
|
-
*
|
|
4
|
+
* The function parses the input using libphonenumber-js to determine the country and
|
|
5
|
+
* national number, then applies the corresponding country's mask (underscore `_` used
|
|
6
|
+
* as digit placeholder) replacing placeholders with actual digits.
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
*
|
|
10
|
-
* - "+55 32912345678"
|
|
11
|
-
* - "+1 1234567890"
|
|
8
|
+
* @param phoneNumber - The input phone number in E.164 format (e.g. `"+5534920524282"`).
|
|
9
|
+
* @returns The phone number formatted according to the country's mask.
|
|
12
10
|
*
|
|
13
|
-
* @
|
|
14
|
-
*
|
|
15
|
-
* @throws {Error} If the input phone number does not match the expected format.
|
|
16
|
-
* @throws {Error} If the country code or phone number is missing from the input string.
|
|
17
|
-
* @throws {Error} If the provided country code and prefix combination is invalid.
|
|
18
|
-
* @throws {Error} If the provided country code is invalid.
|
|
19
|
-
* @throws {Error} If the provided country code has a prefix but none is supplied in the input.
|
|
11
|
+
* @throws {Error} If the phone number is invalid or if no country mask is found for the parsed country.
|
|
20
12
|
*
|
|
21
13
|
* @example
|
|
22
14
|
* ```typescript
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* console.log(formattedPhone1); // Output: "(11) 91234-5678" (brazilian phone number format)
|
|
27
|
-
*
|
|
28
|
-
* const formattedPhone2 = formatToPhone("+1-123 4567890");
|
|
29
|
-
* console.log(formattedPhone2); // Output: "(123) 456-7890" (us phone number format)
|
|
15
|
+
* console.log(formatToPhone("+5534920524282")); // Output: "(34) 92052-4282" (Brazilian format)
|
|
16
|
+
* console.log(formatToPhone("+553420524282")); // Output: "(34) 2052-4282" (Brazilian format with optional ninth digit)
|
|
17
|
+
* console.log(formatToPhone("+12125550199")); // Output: "(212) 555-0199" (American Samoa format)
|
|
30
18
|
* ```
|
|
31
19
|
*/
|
|
32
|
-
declare
|
|
20
|
+
declare function formatToPhone(phoneNumber: string): string;
|
|
33
21
|
export { formatToPhone };
|
|
34
22
|
//# sourceMappingURL=formatToPhone.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatToPhone.d.ts","sourceRoot":"","sources":["../../src/formats/formatToPhone.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatToPhone.d.ts","sourceRoot":"","sources":["../../src/formats/formatToPhone.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,iBAAS,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CA0BlD;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
type GenerateColorByStringFunction = (prop: string) => string;
|
|
2
1
|
/**
|
|
3
2
|
* Generates a hexadecimal color code based on the input string.
|
|
4
3
|
* The function creates a hash from the string and uses it to calculate
|
|
5
4
|
* RGB values, which are then converted to a hexadecimal color code.
|
|
6
5
|
*
|
|
7
|
-
* @param
|
|
8
|
-
* @returns A hexadecimal color code (e.g., "#a1b2c3") derived from the input string.
|
|
6
|
+
* @param rawString - The input string used to generate the color.
|
|
7
|
+
* @returns A hexadecimal color code (e.g., `"#a1b2c3"`) derived from the input string.
|
|
8
|
+
*
|
|
9
9
|
* @example
|
|
10
|
+
* ```typescript
|
|
10
11
|
* const color = generateColorByString("example");
|
|
11
12
|
* console.log(color); // Outputs a consistent hex color like "#5e8f9a"
|
|
13
|
+
* ```
|
|
12
14
|
*/
|
|
13
|
-
declare
|
|
15
|
+
declare function generateColorByString(rawString: string): string;
|
|
14
16
|
export { generateColorByString };
|
|
15
17
|
//# sourceMappingURL=generateColorByString.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateColorByString.d.ts","sourceRoot":"","sources":["../../src/generators/generateColorByString.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"generateColorByString.d.ts","sourceRoot":"","sources":["../../src/generators/generateColorByString.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,iBAAS,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAgBxD;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -1,26 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generates a
|
|
2
|
+
* Generates a UUID in the specified version and output type.
|
|
3
3
|
*
|
|
4
|
-
* @param type -
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @param format - The version of the UUID to generate. Can be:
|
|
8
|
-
* - `"v4"`: Generates a random UUID (version 4).
|
|
9
|
-
* - `"v7"`: Generates a time-ordered UUID (version 7).
|
|
10
|
-
* @returns The generated UUID in the specified type and format.
|
|
11
|
-
* - If `type` is `"text"`, a string representation of the UUID is returned.
|
|
12
|
-
* - If `type` is `"binary"`, a `Uint8Array` representation of the UUID is returned.
|
|
13
|
-
* @throws {Error} If an invalid `type` or `format` is provided.
|
|
4
|
+
* @param type - Output representation: `"text"` (string) or `"binary"` (`Uint8Array`).
|
|
5
|
+
* @param format - UUID version: `"v4"` (random) or `"v7"` (time-ordered).
|
|
6
|
+
* @returns The UUID as a string or `Uint8Array` depending on `type`.
|
|
14
7
|
*
|
|
15
8
|
* @example
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* // Generate a version 7 UUID as binary
|
|
22
|
-
* const idBinaryV7 = generateId("binary", "v7");
|
|
23
|
-
* console.log(idBinaryV7); // Uint8Array([...])
|
|
9
|
+
* ```typescript
|
|
10
|
+
* generateId("text", "v4"); // "550e8400-e29b-41d4-a716-446655440000"
|
|
11
|
+
* generateId("binary", "v7"); // Uint8Array([...])
|
|
12
|
+
* ```
|
|
24
13
|
*/
|
|
25
14
|
declare function generateId(type: "text", format: "v4" | "v7"): string;
|
|
26
15
|
declare function generateId(type: "binary", format: "v4" | "v7"): Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateId.d.ts","sourceRoot":"","sources":["../../src/generators/generateId.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generateId.d.ts","sourceRoot":"","sources":["../../src/generators/generateId.ts"],"names":[],"mappings":"AA6CA;;;;;;;;;;;;GAYG;AACH,iBAAS,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;AAC/D,iBAAS,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,GAAG,UAAU,CAAC;AAYrE,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -9,9 +9,15 @@
|
|
|
9
9
|
* - Collapses multiple consecutive hyphens into a single hyphen.
|
|
10
10
|
* - Trims leading and trailing hyphens.
|
|
11
11
|
*
|
|
12
|
-
* @param
|
|
12
|
+
* @param rawString - The input string to be converted into a slug.
|
|
13
13
|
* @returns A URL-friendly slug derived from the input string.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const slug = generateSlug("Hello, World! This is a Test.");
|
|
18
|
+
* console.log(slug); // Outputs: "hello-world-this-is-a-test"
|
|
19
|
+
* ```
|
|
14
20
|
*/
|
|
15
|
-
declare function generateSlug(
|
|
21
|
+
declare function generateSlug(rawString: string): string;
|
|
16
22
|
export { generateSlug };
|
|
17
23
|
//# sourceMappingURL=generateSlug.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateSlug.d.ts","sourceRoot":"","sources":["../../src/generators/generateSlug.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"generateSlug.d.ts","sourceRoot":"","sources":["../../src/generators/generateSlug.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,iBAAS,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAa/C;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,27 +5,22 @@ export { formatToCapitalizeFirstWordLetter } from "./formats/formatToCapitalizeF
|
|
|
5
5
|
export { formatToCep } from "./formats/formatToCep";
|
|
6
6
|
export { formatToCnpj } from "./formats/formatToCnpj";
|
|
7
7
|
export { formatToCpf } from "./formats/formatToCpf";
|
|
8
|
-
export { formatToCpfCnpj } from "./formats/formatToCpfCnpj";
|
|
9
8
|
export { formatToCurrency } from "./formats/formatToCurrency";
|
|
10
|
-
export { formatToDate } from "./formats/formatToDate";
|
|
11
9
|
export { formatToEllipsis } from "./formats/formatToEllipsis";
|
|
12
10
|
export { formatToHiddenDigits } from "./formats/formatToHiddenDigits";
|
|
13
11
|
export { formatToPhone } from "./formats/formatToPhone";
|
|
14
12
|
export { generateColorByString } from "./generators/generateColorByString";
|
|
15
13
|
export { generateId } from "./generators/generateId";
|
|
16
14
|
export { generateSlug } from "./generators/generateSlug";
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export { validatePassword } from "./validations/validatePassword";
|
|
29
|
-
export { validatePhone } from "./validations/validatePhone";
|
|
30
|
-
export { validateRg } from "./validations/validateRg";
|
|
15
|
+
export { parseLargeFields } from "./parsers/parseLargeFields";
|
|
16
|
+
export { parseSensitiveData } from "./parsers/parseSensitiveData";
|
|
17
|
+
export { parseToDate } from "./parsers/parseToDate";
|
|
18
|
+
export { ValidateDateService } from "./services/validateDateService";
|
|
19
|
+
export { calculateCardInstallment } from "./utilities/calculateCardInstallment";
|
|
20
|
+
export { ensureQuotes } from "./utilities/ensureQuotes";
|
|
21
|
+
export { findCountryMask } from "./utilities/findCountryMask";
|
|
22
|
+
export { isHtml } from "./utilities/isHtml";
|
|
23
|
+
export { removeCurrencySymbols } from "./utilities/removeCurrencySymbols";
|
|
24
|
+
export { removeNonNumeric } from "./utilities/removeNonNumeric";
|
|
25
|
+
export { stripHtmlTags } from "./utilities/stripHtmlTags";
|
|
31
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,iCAAiC,EAAE,MAAM,6CAA6C,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,iCAAiC,EAAE,MAAM,6CAA6C,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAGrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC"}
|