@arkyn/shared 3.0.1-beta.142 → 3.0.1-beta.144
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/dist/bundle.js +6 -36
- package/dist/formats/formatDate.d.ts +16 -52
- package/dist/formats/formatDate.d.ts.map +1 -1
- package/dist/formats/formatDate.js +15 -51
- package/dist/formats/formatJsonObject.d.ts +3 -4
- package/dist/formats/formatJsonObject.d.ts.map +1 -1
- package/dist/formats/formatJsonObject.js +3 -4
- package/dist/formats/formatJsonString.d.ts +5 -21
- package/dist/formats/formatJsonString.d.ts.map +1 -1
- package/dist/formats/formatJsonString.js +5 -21
- package/dist/formats/formatToCapitalizeFirstWordLetter.d.ts +5 -24
- package/dist/formats/formatToCapitalizeFirstWordLetter.d.ts.map +1 -1
- package/dist/formats/formatToCapitalizeFirstWordLetter.js +5 -24
- package/dist/formats/formatToCep.d.ts +2 -3
- package/dist/formats/formatToCep.d.ts.map +1 -1
- package/dist/formats/formatToCep.js +2 -3
- package/dist/formats/formatToCnpj.d.ts +2 -3
- package/dist/formats/formatToCnpj.d.ts.map +1 -1
- package/dist/formats/formatToCnpj.js +2 -3
- package/dist/formats/formatToCpf.d.ts +2 -3
- package/dist/formats/formatToCpf.d.ts.map +1 -1
- package/dist/formats/formatToCpf.js +2 -3
- package/dist/formats/formatToCurrency.d.ts +8 -25
- package/dist/formats/formatToCurrency.d.ts.map +1 -1
- package/dist/formats/formatToCurrency.js +8 -25
- package/dist/formats/formatToEllipsis.d.ts +3 -6
- package/dist/formats/formatToEllipsis.d.ts.map +1 -1
- package/dist/formats/formatToEllipsis.js +3 -6
- package/dist/formats/formatToHiddenDigits.d.ts +11 -22
- package/dist/formats/formatToHiddenDigits.d.ts.map +1 -1
- package/dist/formats/formatToHiddenDigits.js +11 -22
- package/dist/formats/formatToPhone.d.ts +2 -3
- package/dist/formats/formatToPhone.d.ts.map +1 -1
- package/dist/formats/formatToPhone.js +2 -3
- package/dist/generators/generateColorByString.d.ts +2 -3
- package/dist/generators/generateColorByString.d.ts.map +1 -1
- package/dist/generators/generateColorByString.js +2 -3
- package/dist/generators/generateId.d.ts +8 -19
- package/dist/generators/generateId.d.ts.map +1 -1
- package/dist/generators/generateSlug.d.ts +2 -3
- package/dist/generators/generateSlug.d.ts.map +1 -1
- package/dist/generators/generateSlug.js +2 -3
- package/dist/parsers/parseLargeFields.d.ts +3 -4
- package/dist/parsers/parseLargeFields.d.ts.map +1 -1
- package/dist/parsers/parseLargeFields.js +3 -4
- package/dist/parsers/parseSensitiveData.d.ts +3 -4
- package/dist/parsers/parseSensitiveData.d.ts.map +1 -1
- package/dist/parsers/parseSensitiveData.js +3 -4
- package/dist/parsers/parseToDate.d.ts +16 -32
- package/dist/parsers/parseToDate.d.ts.map +1 -1
- package/dist/parsers/parseToDate.js +16 -32
- package/dist/services/validateDateService.d.ts +13 -64
- package/dist/services/validateDateService.d.ts.map +1 -1
- package/dist/services/validateDateService.js +13 -64
- package/dist/utilities/calculateCardInstallment.d.ts +8 -21
- package/dist/utilities/calculateCardInstallment.d.ts.map +1 -1
- package/dist/utilities/calculateCardInstallment.js +8 -21
- package/dist/utilities/ensureQuotes.d.ts +2 -3
- package/dist/utilities/ensureQuotes.d.ts.map +1 -1
- package/dist/utilities/ensureQuotes.js +2 -3
- package/dist/utilities/findCountryMask.d.ts +10 -34
- package/dist/utilities/findCountryMask.d.ts.map +1 -1
- package/dist/utilities/findCountryMask.js +10 -34
- package/dist/utilities/isHtml.d.ts +2 -3
- package/dist/utilities/isHtml.d.ts.map +1 -1
- package/dist/utilities/isHtml.js +2 -3
- package/dist/utilities/removeCurrencySymbols.d.ts +2 -3
- package/dist/utilities/removeCurrencySymbols.d.ts.map +1 -1
- package/dist/utilities/removeCurrencySymbols.js +2 -3
- package/dist/utilities/removeNonNumeric.d.ts +2 -3
- package/dist/utilities/removeNonNumeric.d.ts.map +1 -1
- package/dist/utilities/removeNonNumeric.js +2 -3
- package/dist/utilities/stripHtmlTags.d.ts +2 -3
- package/dist/utilities/stripHtmlTags.d.ts.map +1 -1
- package/dist/utilities/stripHtmlTags.js +2 -3
- package/package.json +1 -1
|
@@ -1,35 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Validates date components and input format strings for date-parsing utilities.
|
|
3
|
+
* Enforces 4-digit years, month/day ranges, month-specific day counts, and leap year rules.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
* input format strings used in date parsing operations. It includes leap year
|
|
6
|
-
* validation and month-specific day validation.
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* The service validates:
|
|
10
|
-
* - Year must be exactly 4 digits (1000-9999)
|
|
11
|
-
* - Month must be between 1 and 12
|
|
12
|
-
* - Day must be between 1 and 31
|
|
13
|
-
* - Day must be valid for the specific month (e.g., no February 30)
|
|
14
|
-
* - Leap year rules for February 29
|
|
15
|
-
*
|
|
16
|
-
* @example Validate a valid date
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const service = new ValidateDateService();
|
|
19
|
-
* service.validateDateParts(2024, 1, 15); // No error thrown
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* @example Validate an invalid date
|
|
5
|
+
* @example
|
|
23
6
|
* ```typescript
|
|
24
7
|
* const service = new ValidateDateService();
|
|
25
|
-
* service.validateDateParts(
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* ```typescript
|
|
30
|
-
* const service = new ValidateDateService();
|
|
31
|
-
* service.validateInputFormat("brazilianDate"); // No error thrown
|
|
32
|
-
* service.validateInputFormat("invalidFormat"); // Throws: "Invalid input format: invalidFormat"
|
|
8
|
+
* service.validateDateParts(2024, 2, 29); // OK — leap year
|
|
9
|
+
* service.validateDateParts(2023, 2, 29); // throws — not a leap year
|
|
10
|
+
* service.validateInputFormat("brazilianDate"); // OK
|
|
11
|
+
* service.validateInputFormat("custom"); // throws
|
|
33
12
|
* ```
|
|
34
13
|
*/
|
|
35
14
|
class ValidateDateService {
|
|
@@ -67,24 +46,11 @@ class ValidateDateService {
|
|
|
67
46
|
}
|
|
68
47
|
}
|
|
69
48
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* @param {number} year - The year to validate (must be 4 digits).
|
|
73
|
-
* @param {number} month - The month to validate (must be between 1 and 12).
|
|
74
|
-
* @param {number} day - The day to validate (must be between 1 and 31, and valid for the month).
|
|
75
|
-
*
|
|
76
|
-
* @throws {Error} "Year should be four digits" - If the year doesn't have exactly 4 digits.
|
|
77
|
-
* @throws {Error} "Month should be between 1 and 12" - If the month is out of valid range.
|
|
78
|
-
* @throws {Error} "Day should be between 1 and 31" - If the day is out of valid range.
|
|
79
|
-
* @throws {Error} Month-specific error - If the day is invalid for the specific month.
|
|
49
|
+
* Throws if year, month, or day are out of valid range or inconsistent with the calendar.
|
|
80
50
|
*
|
|
81
|
-
* @
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* service.validateDateParts(2024, 2, 29); // Valid leap year date
|
|
85
|
-
* service.validateDateParts(2023, 2, 29); // Throws error - not a leap year
|
|
86
|
-
* service.validateDateParts(2024, 4, 31); // Throws error - April has only 30 days
|
|
87
|
-
* ```
|
|
51
|
+
* @param year - 4-digit year (1000–9999).
|
|
52
|
+
* @param month - Month number (1–12).
|
|
53
|
+
* @param day - Day number (1–31, validated against the specific month).
|
|
88
54
|
*/
|
|
89
55
|
validateDateParts(year, month, day) {
|
|
90
56
|
const messageErrors = {
|
|
@@ -101,26 +67,9 @@ class ValidateDateService {
|
|
|
101
67
|
this.validateDayInMonth(day, month, year);
|
|
102
68
|
}
|
|
103
69
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* @param {string} format - The format string to validate.
|
|
107
|
-
*
|
|
108
|
-
* @throws {Error} "Invalid input format: {format}" - If the format is not one of the valid formats.
|
|
109
|
-
*
|
|
110
|
-
* @remarks
|
|
111
|
-
* Valid formats are:
|
|
112
|
-
* - "brazilianDate": DD/MM/YYYY format
|
|
113
|
-
* - "isoDate": MM-DD-YYYY format
|
|
114
|
-
* - "timestamp": YYYY-MM-DD format
|
|
70
|
+
* Throws if `format` is not one of `"brazilianDate"`, `"isoDate"`, or `"timestamp"`.
|
|
115
71
|
*
|
|
116
|
-
* @
|
|
117
|
-
* ```typescript
|
|
118
|
-
* const service = new ValidateDateService();
|
|
119
|
-
* service.validateInputFormat("brazilianDate"); // Valid
|
|
120
|
-
* service.validateInputFormat("isoDate"); // Valid
|
|
121
|
-
* service.validateInputFormat("timestamp"); // Valid
|
|
122
|
-
* service.validateInputFormat("customFormat"); // Throws error
|
|
123
|
-
* ```
|
|
72
|
+
* @param format - The format string to check.
|
|
124
73
|
*/
|
|
125
74
|
validateInputFormat(format) {
|
|
126
75
|
const validFormats = ["brazilianDate", "isoDate", "timestamp"];
|
|
@@ -1,29 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Calculates the installment
|
|
2
|
+
* Calculates the per-installment and total price for a card payment plan with compound interest.
|
|
3
|
+
* No interest is applied when `fees` is `0` or `numberInstallments` is `1`.
|
|
3
4
|
*
|
|
4
|
-
* @
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @
|
|
8
|
-
* @param {number} props.cashPrice - The total cash price of the product or service.
|
|
9
|
-
* @param {number} props.numberInstallments - The number of installments for the payment plan.
|
|
10
|
-
* @param {number} [props.fees=0.0349] - The interest rate per installment (default is 0.0349).
|
|
11
|
-
*
|
|
12
|
-
* @throws {Error} If `numberInstallments` is less than or equal to 0.
|
|
13
|
-
* @throws {Error} If `fees` is less than 0.
|
|
14
|
-
*
|
|
15
|
-
* @returns {object} An object containing:
|
|
16
|
-
* - `totalPrice`: The total price to be paid, rounded to two decimal places.
|
|
17
|
-
* - `installmentPrice`: The price of each installment, rounded to two decimal places.
|
|
5
|
+
* @param props.cashPrice - The base price of the item.
|
|
6
|
+
* @param props.numberInstallments - Number of installments (must be > 0).
|
|
7
|
+
* @param props.fees - Monthly interest rate (defaults to `0.0349`).
|
|
8
|
+
* @returns `{ totalPrice, installmentPrice }` — both rounded to 2 decimal places.
|
|
18
9
|
*
|
|
19
10
|
* @example
|
|
20
11
|
* ```typescript
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* numberInstallments: 12,
|
|
24
|
-
* fees: 0.02,
|
|
25
|
-
* });
|
|
26
|
-
* console.log(result); // Output: { totalPrice: 1124.62, installmentPrice: 93.72 }
|
|
12
|
+
* calculateCardInstallment({ cashPrice: 1000, numberInstallments: 12, fees: 0.02 });
|
|
13
|
+
* // { totalPrice: 1124.62, installmentPrice: 93.72 }
|
|
27
14
|
* ```
|
|
28
15
|
*/
|
|
29
16
|
declare function calculateCardInstallment(props: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculateCardInstallment.d.ts","sourceRoot":"","sources":["../../src/utilities/calculateCardInstallment.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"calculateCardInstallment.d.ts","sourceRoot":"","sources":["../../src/utilities/calculateCardInstallment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,iBAAS,wBAAwB,CAAC,KAAK,EAAE;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,CA4BnD;AAED,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -1,29 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Calculates the installment
|
|
2
|
+
* Calculates the per-installment and total price for a card payment plan with compound interest.
|
|
3
|
+
* No interest is applied when `fees` is `0` or `numberInstallments` is `1`.
|
|
3
4
|
*
|
|
4
|
-
* @
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @
|
|
8
|
-
* @param {number} props.cashPrice - The total cash price of the product or service.
|
|
9
|
-
* @param {number} props.numberInstallments - The number of installments for the payment plan.
|
|
10
|
-
* @param {number} [props.fees=0.0349] - The interest rate per installment (default is 0.0349).
|
|
11
|
-
*
|
|
12
|
-
* @throws {Error} If `numberInstallments` is less than or equal to 0.
|
|
13
|
-
* @throws {Error} If `fees` is less than 0.
|
|
14
|
-
*
|
|
15
|
-
* @returns {object} An object containing:
|
|
16
|
-
* - `totalPrice`: The total price to be paid, rounded to two decimal places.
|
|
17
|
-
* - `installmentPrice`: The price of each installment, rounded to two decimal places.
|
|
5
|
+
* @param props.cashPrice - The base price of the item.
|
|
6
|
+
* @param props.numberInstallments - Number of installments (must be > 0).
|
|
7
|
+
* @param props.fees - Monthly interest rate (defaults to `0.0349`).
|
|
8
|
+
* @returns `{ totalPrice, installmentPrice }` — both rounded to 2 decimal places.
|
|
18
9
|
*
|
|
19
10
|
* @example
|
|
20
11
|
* ```typescript
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* numberInstallments: 12,
|
|
24
|
-
* fees: 0.02,
|
|
25
|
-
* });
|
|
26
|
-
* console.log(result); // Output: { totalPrice: 1124.62, installmentPrice: 93.72 }
|
|
12
|
+
* calculateCardInstallment({ cashPrice: 1000, numberInstallments: 12, fees: 0.02 });
|
|
13
|
+
* // { totalPrice: 1124.62, installmentPrice: 93.72 }
|
|
27
14
|
* ```
|
|
28
15
|
*/
|
|
29
16
|
function calculateCardInstallment(props) {
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
* quotes (`'`) or double quotes (`"`). If the string is already quoted, it is
|
|
6
6
|
* returned as-is. Otherwise, the function wraps the string in double quotes.
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
*
|
|
10
|
-
* @returns {string} The input string, either unchanged if it is already quoted, or wrapped in double quotes.
|
|
8
|
+
* @param rawValue - The string to be checked and potentially quoted.
|
|
9
|
+
* @returns The original string if already quoted, otherwise the string wrapped in double quotes.
|
|
11
10
|
*
|
|
12
11
|
* @example
|
|
13
12
|
* ```typescript
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureQuotes.d.ts","sourceRoot":"","sources":["../../src/utilities/ensureQuotes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ensureQuotes.d.ts","sourceRoot":"","sources":["../../src/utilities/ensureQuotes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,iBAAS,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAS9C;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
* quotes (`'`) or double quotes (`"`). If the string is already quoted, it is
|
|
6
6
|
* returned as-is. Otherwise, the function wraps the string in double quotes.
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
*
|
|
10
|
-
* @returns {string} The input string, either unchanged if it is already quoted, or wrapped in double quotes.
|
|
8
|
+
* @param rawValue - The string to be checked and potentially quoted.
|
|
9
|
+
* @returns The original string if already quoted, otherwise the string wrapped in double quotes.
|
|
11
10
|
*
|
|
12
11
|
* @example
|
|
13
12
|
* ```typescript
|
|
@@ -1,43 +1,19 @@
|
|
|
1
1
|
import { type CountryType } from "@arkyn/templates";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Resolves the matching phone mask and country metadata for a given phone number.
|
|
4
|
+
* Masks use `"_"` as digit placeholders. For countries with multiple mask lengths
|
|
5
|
+
* (e.g. Brazil with and without the ninth digit), the mask matching the number's
|
|
6
|
+
* digit count is returned.
|
|
5
7
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* - Returns the mask string (e.g. "(__) _____-____") to be used for formatting.
|
|
10
|
-
*
|
|
11
|
-
* @param {string} phoneNumber - The input phone number (can include country code or be in national format).
|
|
12
|
-
* @returns {string} The country mask string containing "_" placeholders for digits.
|
|
13
|
-
*
|
|
14
|
-
* @throws {Error} If the phone number is invalid or if no mask is found for the parsed country.
|
|
8
|
+
* @param phoneNumber - Phone number in E.164 format (e.g. `"+5511999999999"`).
|
|
9
|
+
* @returns A tuple of `[maskString, CountryType]`.
|
|
10
|
+
* @throws If the number is invalid or no mask is found for the parsed country.
|
|
15
11
|
*
|
|
16
12
|
* @example
|
|
17
13
|
* ```typescript
|
|
18
|
-
*
|
|
19
|
-
* //
|
|
20
|
-
*
|
|
21
|
-
* ["(__) _____-____", ["(__) ____-____"]],
|
|
22
|
-
* {
|
|
23
|
-
* name: "Brazil",
|
|
24
|
-
* code: "+55",
|
|
25
|
-
* iso: "BR",
|
|
26
|
-
* flag: "🇧🇷",
|
|
27
|
-
* mask: ["(__) _____-____", ["(__) ____-____"]] }
|
|
28
|
-
* ]
|
|
29
|
-
*
|
|
30
|
-
* console.log(findCountryMask("+19700000000"));
|
|
31
|
-
* // output:
|
|
32
|
-
* [
|
|
33
|
-
* "(___) ___-____",
|
|
34
|
-
* {
|
|
35
|
-
* name: "United States",
|
|
36
|
-
* code: "+1",
|
|
37
|
-
* iso: "US",
|
|
38
|
-
* flag: "🇺🇸",
|
|
39
|
-
* mask: "(___) ___-____" }
|
|
40
|
-
* ]
|
|
14
|
+
* const [mask, country] = findCountryMask("+5511999999999");
|
|
15
|
+
* // mask: "(__) _____-____"
|
|
16
|
+
* // country.name: "Brazil"
|
|
41
17
|
* ```
|
|
42
18
|
*/
|
|
43
19
|
declare function findCountryMask(phoneNumber: string): [string, CountryType];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findCountryMask.d.ts","sourceRoot":"","sources":["../../src/utilities/findCountryMask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAI/D
|
|
1
|
+
{"version":3,"file":"findCountryMask.d.ts","sourceRoot":"","sources":["../../src/utilities/findCountryMask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAI/D;;;;;;;;;;;;;;;;GAgBG;AAEH,iBAAS,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CA+BnE;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -2,44 +2,20 @@ import { countries } from "@arkyn/templates";
|
|
|
2
2
|
import { parsePhoneNumberWithError } from "libphonenumber-js";
|
|
3
3
|
import { removeNonNumeric } from "./removeNonNumeric";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Resolves the matching phone mask and country metadata for a given phone number.
|
|
6
|
+
* Masks use `"_"` as digit placeholders. For countries with multiple mask lengths
|
|
7
|
+
* (e.g. Brazil with and without the ninth digit), the mask matching the number's
|
|
8
|
+
* digit count is returned.
|
|
7
9
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* - Returns the mask string (e.g. "(__) _____-____") to be used for formatting.
|
|
12
|
-
*
|
|
13
|
-
* @param {string} phoneNumber - The input phone number (can include country code or be in national format).
|
|
14
|
-
* @returns {string} The country mask string containing "_" placeholders for digits.
|
|
15
|
-
*
|
|
16
|
-
* @throws {Error} If the phone number is invalid or if no mask is found for the parsed country.
|
|
10
|
+
* @param phoneNumber - Phone number in E.164 format (e.g. `"+5511999999999"`).
|
|
11
|
+
* @returns A tuple of `[maskString, CountryType]`.
|
|
12
|
+
* @throws If the number is invalid or no mask is found for the parsed country.
|
|
17
13
|
*
|
|
18
14
|
* @example
|
|
19
15
|
* ```typescript
|
|
20
|
-
*
|
|
21
|
-
* //
|
|
22
|
-
*
|
|
23
|
-
* ["(__) _____-____", ["(__) ____-____"]],
|
|
24
|
-
* {
|
|
25
|
-
* name: "Brazil",
|
|
26
|
-
* code: "+55",
|
|
27
|
-
* iso: "BR",
|
|
28
|
-
* flag: "🇧🇷",
|
|
29
|
-
* mask: ["(__) _____-____", ["(__) ____-____"]] }
|
|
30
|
-
* ]
|
|
31
|
-
*
|
|
32
|
-
* console.log(findCountryMask("+19700000000"));
|
|
33
|
-
* // output:
|
|
34
|
-
* [
|
|
35
|
-
* "(___) ___-____",
|
|
36
|
-
* {
|
|
37
|
-
* name: "United States",
|
|
38
|
-
* code: "+1",
|
|
39
|
-
* iso: "US",
|
|
40
|
-
* flag: "🇺🇸",
|
|
41
|
-
* mask: "(___) ___-____" }
|
|
42
|
-
* ]
|
|
16
|
+
* const [mask, country] = findCountryMask("+5511999999999");
|
|
17
|
+
* // mask: "(__) _____-____"
|
|
18
|
+
* // country.name: "Brazil"
|
|
43
19
|
* ```
|
|
44
20
|
*/
|
|
45
21
|
function findCountryMask(phoneNumber) {
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
* in a string. The check is case-insensitive and detects both opening
|
|
6
6
|
* and closing tags.
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
*
|
|
10
|
-
* @returns {boolean} `true` if the string contains HTML markup, `false` otherwise
|
|
8
|
+
* @param rawString - The string to check.
|
|
9
|
+
* @returns `true` if the string contains HTML markup, `false` otherwise.
|
|
11
10
|
*
|
|
12
11
|
* @example
|
|
13
12
|
* ```typescript
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isHtml.d.ts","sourceRoot":"","sources":["../../src/utilities/isHtml.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"isHtml.d.ts","sourceRoot":"","sources":["../../src/utilities/isHtml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,iBAAS,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAG1C;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/dist/utilities/isHtml.js
CHANGED
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
* in a string. The check is case-insensitive and detects both opening
|
|
6
6
|
* and closing tags.
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
*
|
|
10
|
-
* @returns {boolean} `true` if the string contains HTML markup, `false` otherwise
|
|
8
|
+
* @param rawString - The string to check.
|
|
9
|
+
* @returns `true` if the string contains HTML markup, `false` otherwise.
|
|
11
10
|
*
|
|
12
11
|
* @example
|
|
13
12
|
* ```typescript
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
* and removes them using a regular expression. The resulting string
|
|
6
6
|
* is also trimmed of any leading or trailing whitespace.
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
*
|
|
10
|
-
* @returns {string} A string with all currency symbols removed and trimmed of whitespace.
|
|
8
|
+
* @param rawString - The formatted string that may contain currency symbols.
|
|
9
|
+
* @returns The string with all currency symbols removed and trimmed of whitespace.
|
|
11
10
|
*
|
|
12
11
|
* @example
|
|
13
12
|
* ```typescript
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeCurrencySymbols.d.ts","sourceRoot":"","sources":["../../src/utilities/removeCurrencySymbols.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"removeCurrencySymbols.d.ts","sourceRoot":"","sources":["../../src/utilities/removeCurrencySymbols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,iBAAS,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
* and removes them using a regular expression. The resulting string
|
|
6
6
|
* is also trimmed of any leading or trailing whitespace.
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
*
|
|
10
|
-
* @returns {string} A string with all currency symbols removed and trimmed of whitespace.
|
|
8
|
+
* @param rawString - The formatted string that may contain currency symbols.
|
|
9
|
+
* @returns The string with all currency symbols removed and trimmed of whitespace.
|
|
11
10
|
*
|
|
12
11
|
* @example
|
|
13
12
|
* ```typescript
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Removes all non-numeric characters from a given string.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
*
|
|
6
|
-
* @returns {string} A new string containing only numeric characters from the input.
|
|
4
|
+
* @param rawString - The input string to strip non-numeric characters from.
|
|
5
|
+
* @returns A new string containing only the numeric characters from the input.
|
|
7
6
|
*
|
|
8
7
|
* @example
|
|
9
8
|
* ```typescript
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeNonNumeric.d.ts","sourceRoot":"","sources":["../../src/utilities/removeNonNumeric.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"removeNonNumeric.d.ts","sourceRoot":"","sources":["../../src/utilities/removeNonNumeric.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,iBAAS,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Removes all non-numeric characters from a given string.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
*
|
|
6
|
-
* @returns {string} A new string containing only numeric characters from the input.
|
|
4
|
+
* @param rawString - The input string to strip non-numeric characters from.
|
|
5
|
+
* @returns A new string containing only the numeric characters from the input.
|
|
7
6
|
*
|
|
8
7
|
* @example
|
|
9
8
|
* ```typescript
|
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
* This function removes all HTML tags from the provided string by replacing any content
|
|
5
5
|
* that matches the HTML tag pattern with an empty string.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
8
|
-
*
|
|
9
|
-
* @returns {string} The input string with all HTML tags removed
|
|
7
|
+
* @param rawHtml - The HTML string to strip tags from.
|
|
8
|
+
* @returns The plain text with all HTML tags (including `<script>`, `<style>`, and comments) removed.
|
|
10
9
|
*
|
|
11
10
|
* @example
|
|
12
11
|
* ```typescript
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripHtmlTags.d.ts","sourceRoot":"","sources":["../../src/utilities/stripHtmlTags.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"stripHtmlTags.d.ts","sourceRoot":"","sources":["../../src/utilities/stripHtmlTags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,iBAAS,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAM9C;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
* This function removes all HTML tags from the provided string by replacing any content
|
|
5
5
|
* that matches the HTML tag pattern with an empty string.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
8
|
-
*
|
|
9
|
-
* @returns {string} The input string with all HTML tags removed
|
|
7
|
+
* @param rawHtml - The HTML string to strip tags from.
|
|
8
|
+
* @returns The plain text with all HTML tags (including `<script>`, `<style>`, and comments) removed.
|
|
10
9
|
*
|
|
11
10
|
* @example
|
|
12
11
|
* ```typescript
|