stringzy 3.0.0 → 4.1.0

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.
Files changed (171) hide show
  1. package/.prettierignore +4 -0
  2. package/.prettierrc +7 -0
  3. package/CONTRIBUTING.md +41 -29
  4. package/README.md +811 -163
  5. package/dist/analyzing/characterCount.d.ts +19 -0
  6. package/dist/analyzing/characterCount.js +21 -2
  7. package/dist/analyzing/characterFrequency.d.ts +19 -0
  8. package/dist/analyzing/characterFrequency.js +22 -3
  9. package/dist/analyzing/checkMultiplePatterns.d.ts +14 -0
  10. package/dist/analyzing/checkMultiplePatterns.js +63 -0
  11. package/dist/analyzing/checkSubsequence.d.ts +14 -0
  12. package/dist/analyzing/checkSubsequence.js +33 -0
  13. package/dist/analyzing/complexity.d.ts +33 -0
  14. package/dist/analyzing/complexity.js +35 -2
  15. package/dist/analyzing/contentWordCount.d.ts +11 -0
  16. package/dist/analyzing/contentWordCount.js +23 -0
  17. package/dist/analyzing/functionWordCount.d.ts +11 -0
  18. package/dist/analyzing/functionWordCount.js +33 -0
  19. package/dist/analyzing/index.d.ts +29 -12
  20. package/dist/analyzing/index.js +26 -2
  21. package/dist/analyzing/patternCount.d.ts +11 -0
  22. package/dist/analyzing/patternCount.js +54 -0
  23. package/dist/analyzing/stringRotation.d.ts +29 -0
  24. package/dist/analyzing/stringRotation.js +44 -0
  25. package/dist/analyzing/stringSimilarity.js +1 -1
  26. package/dist/analyzing/vowelConsonantCount.d.ts +22 -0
  27. package/dist/analyzing/vowelConsonantCount.js +38 -0
  28. package/dist/analyzing/wordCount.d.ts +22 -0
  29. package/dist/analyzing/wordCount.js +24 -2
  30. package/dist/formatting/capitalize.d.ts +21 -0
  31. package/dist/formatting/capitalize.js +22 -1
  32. package/dist/formatting/index.d.ts +6 -6
  33. package/dist/formatting/number.d.ts +23 -0
  34. package/dist/formatting/number.js +24 -1
  35. package/dist/formatting/phone.d.ts +23 -0
  36. package/dist/formatting/phone.js +23 -0
  37. package/dist/index.d.ts +22 -4
  38. package/dist/tests/analyzing/checkMultiplePatterns.test.d.ts +1 -0
  39. package/dist/tests/analyzing/checkMultiplePatterns.test.js +81 -0
  40. package/dist/tests/analyzing/checkSubsequence.test.d.ts +1 -0
  41. package/dist/tests/analyzing/checkSubsequence.test.js +34 -0
  42. package/dist/tests/analyzing/contentWordCount.test.d.ts +1 -0
  43. package/dist/tests/analyzing/contentWordCount.test.js +20 -0
  44. package/dist/tests/analyzing/functionWordCount.test.d.ts +1 -0
  45. package/dist/tests/analyzing/functionWordCount.test.js +20 -0
  46. package/dist/tests/analyzing/patternCount.test.d.ts +1 -0
  47. package/dist/tests/analyzing/patternCount.test.js +34 -0
  48. package/dist/tests/analyzing/readingDuration.test.js +12 -12
  49. package/dist/tests/analyzing/stringRotation.test.d.ts +1 -0
  50. package/dist/tests/analyzing/stringRotation.test.js +42 -0
  51. package/dist/tests/analyzing/vowelConsonantCount.test.d.ts +1 -0
  52. package/dist/tests/analyzing/vowelConsonantCount.test.js +25 -0
  53. package/dist/tests/transformations/numberToText.test.d.ts +1 -0
  54. package/dist/tests/transformations/numberToText.test.js +60 -0
  55. package/dist/tests/transformations/reverseString.test.d.ts +1 -0
  56. package/dist/tests/transformations/reverseString.test.js +41 -0
  57. package/dist/tests/transformations/splitChunks.test.d.ts +1 -0
  58. package/dist/tests/transformations/splitChunks.test.js +31 -0
  59. package/dist/tests/transformations/stringCombinations.test.d.ts +1 -0
  60. package/dist/tests/transformations/stringCombinations.test.js +41 -0
  61. package/dist/tests/transformations/stringPermutations.test.d.ts +1 -0
  62. package/dist/tests/transformations/stringPermutations.test.js +40 -0
  63. package/dist/tests/validations/isAlphaNumeric.test.d.ts +1 -0
  64. package/dist/tests/validations/isAlphaNumeric.test.js +30 -0
  65. package/dist/tests/validations/isAlphabetic.test.d.ts +1 -0
  66. package/dist/tests/validations/isAlphabetic.test.js +32 -0
  67. package/dist/tests/validations/isAnagram.test.d.ts +1 -0
  68. package/dist/tests/validations/isAnagram.test.js +44 -0
  69. package/dist/tests/validations/isCoordinates.test.d.ts +1 -0
  70. package/dist/tests/validations/isCoordinates.test.js +18 -0
  71. package/dist/tests/validations/isEmail.smtpUTF8.test.d.ts +1 -0
  72. package/dist/tests/validations/isEmail.smtpUTF8.test.js +16 -0
  73. package/dist/tests/validations/isEmail.test.js +56 -6
  74. package/dist/tests/validations/isHexColor.test.js +21 -21
  75. package/dist/tests/validations/isLowerCase.test.d.ts +1 -0
  76. package/dist/tests/validations/isLowerCase.test.js +50 -0
  77. package/dist/tests/validations/isMacAddress.test.d.ts +1 -0
  78. package/dist/tests/validations/isMacAddress.test.js +72 -0
  79. package/dist/tests/validations/isPalindrome.test.d.ts +1 -0
  80. package/dist/tests/validations/isPalindrome.test.js +39 -0
  81. package/dist/tests/validations/isPanagram.test.d.ts +1 -0
  82. package/dist/tests/validations/isPanagram.test.js +39 -0
  83. package/dist/tests/validations/isTypeOf.test.d.ts +1 -0
  84. package/dist/tests/validations/isTypeOf.test.js +28 -0
  85. package/dist/tests/validations/isUpperCase.test.d.ts +1 -0
  86. package/dist/tests/validations/isUpperCase.test.js +50 -0
  87. package/dist/transformations/camelCase.d.ts +24 -0
  88. package/dist/transformations/camelCase.js +24 -0
  89. package/dist/transformations/capitalizeWords.d.ts +21 -0
  90. package/dist/transformations/capitalizeWords.js +23 -2
  91. package/dist/transformations/constantCase.d.ts +26 -0
  92. package/dist/transformations/constantCase.js +26 -0
  93. package/dist/transformations/escapeHTML.d.ts +23 -0
  94. package/dist/transformations/escapeHTML.js +24 -2
  95. package/dist/transformations/index.d.ts +12 -0
  96. package/dist/transformations/index.js +18 -2
  97. package/dist/transformations/initials.d.ts +27 -0
  98. package/dist/transformations/initials.js +38 -8
  99. package/dist/transformations/kebabCase.d.ts +26 -0
  100. package/dist/transformations/kebabCase.js +26 -0
  101. package/dist/transformations/maskSegment.js +4 -6
  102. package/dist/transformations/numberToText/helpers.d.ts +10 -0
  103. package/dist/transformations/numberToText/helpers.js +31 -0
  104. package/dist/transformations/numberToText/implementation_EN.d.ts +10 -0
  105. package/dist/transformations/numberToText/implementation_EN.js +45 -0
  106. package/dist/transformations/numberToText/implementation_PL.d.ts +10 -0
  107. package/dist/transformations/numberToText/implementation_PL.js +79 -0
  108. package/dist/transformations/numberToText/main.d.ts +19 -0
  109. package/dist/transformations/numberToText/main.js +67 -0
  110. package/dist/transformations/numberToText/types.d.ts +3 -0
  111. package/dist/transformations/numberToText/types.js +82 -0
  112. package/dist/transformations/pascalCase.d.ts +25 -0
  113. package/dist/transformations/pascalCase.js +25 -0
  114. package/dist/transformations/removeDuplicates.d.ts +21 -0
  115. package/dist/transformations/removeDuplicates.js +25 -4
  116. package/dist/transformations/removeSpecialChars.d.ts +22 -0
  117. package/dist/transformations/removeSpecialChars.js +26 -4
  118. package/dist/transformations/removeWords.d.ts +27 -0
  119. package/dist/transformations/removeWords.js +31 -4
  120. package/dist/transformations/reverseWordsInString .d.ts +9 -0
  121. package/dist/transformations/reverseWordsInString .js +49 -0
  122. package/dist/transformations/snakeCase.d.ts +26 -0
  123. package/dist/transformations/snakeCase.js +26 -0
  124. package/dist/transformations/splitChunks.d.ts +8 -0
  125. package/dist/transformations/splitChunks.js +24 -0
  126. package/dist/transformations/stringCombinations.d.ts +28 -0
  127. package/dist/transformations/stringCombinations.js +44 -0
  128. package/dist/transformations/stringPermutations.d.ts +31 -0
  129. package/dist/transformations/stringPermutations.js +53 -0
  130. package/dist/transformations/titleCase.d.ts +25 -0
  131. package/dist/transformations/titleCase.js +25 -0
  132. package/dist/transformations/toSlug.d.ts +24 -0
  133. package/dist/transformations/toSlug.js +28 -4
  134. package/dist/transformations/truncateText.d.ts +25 -0
  135. package/dist/transformations/truncateText.js +28 -3
  136. package/dist/validations/index.d.ts +27 -0
  137. package/dist/validations/index.js +38 -2
  138. package/dist/validations/isAlphaNumeric.d.ts +11 -0
  139. package/dist/validations/isAlphaNumeric.js +22 -0
  140. package/dist/validations/isAlphabetic.d.ts +9 -0
  141. package/dist/validations/isAlphabetic.js +21 -0
  142. package/dist/validations/isAnagram.d.ts +13 -0
  143. package/dist/validations/isAnagram.js +23 -0
  144. package/dist/validations/isCoordinates.d.ts +8 -0
  145. package/dist/validations/isCoordinates.js +19 -0
  146. package/dist/validations/isDate.d.ts +1 -1
  147. package/dist/validations/isDate.js +6 -8
  148. package/dist/validations/isEmail.d.ts +13 -1
  149. package/dist/validations/isEmail.js +176 -3
  150. package/dist/validations/isEmpty.d.ts +9 -0
  151. package/dist/validations/isEmpty.js +9 -0
  152. package/dist/validations/isHexColor.js +1 -1
  153. package/dist/validations/isIPv4.d.ts +21 -0
  154. package/dist/validations/isIPv4.js +22 -2
  155. package/dist/validations/isLowerCase.d.ts +12 -0
  156. package/dist/validations/isLowerCase.js +32 -0
  157. package/dist/validations/isMacAddress.d.ts +27 -0
  158. package/dist/validations/isMacAddress.js +43 -0
  159. package/dist/validations/isPalindrome.d.ts +10 -0
  160. package/dist/validations/isPalindrome.js +21 -0
  161. package/dist/validations/isPanagram.d.ts +20 -0
  162. package/dist/validations/isPanagram.js +35 -0
  163. package/dist/validations/isSlug.d.ts +27 -0
  164. package/dist/validations/isSlug.js +27 -0
  165. package/dist/validations/isTypeOf.d.ts +9 -0
  166. package/dist/validations/isTypeOf.js +30 -0
  167. package/dist/validations/isURL.d.ts +21 -0
  168. package/dist/validations/isURL.js +21 -0
  169. package/dist/validations/isUpperCase.d.ts +12 -0
  170. package/dist/validations/isUpperCase.js +32 -0
  171. package/package.json +6 -4
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Checks if a given string is a valid MAC address.
3
+ *
4
+ * Valid MAC addresses consist of six pairs of hexadecimal digits (0-9, A-F)
5
+ * separated either by colons (:) or hyphens (-). Example formats:
6
+ * - "00:1A:2B:3C:4D:5E"
7
+ * - "00-1A-2B-3C-4D-5E"
8
+ *
9
+ * Mixed or missing separators, invalid hex characters, or incorrect lengths
10
+ * are not allowed.
11
+ *
12
+ * @param {string} str - The string to validate as a MAC address.
13
+ * @returns {boolean} `true` if the string is a valid MAC address, otherwise `false`.
14
+ *
15
+ * @example
16
+ * isMacAddress("00:1A:2B:3C:4D:5E"); // true
17
+ *
18
+ * @example
19
+ * isMacAddress("00-1A-2B-3C-4D-5E"); // true
20
+ *
21
+ * @example
22
+ * isMacAddress("001A:2B:3C:4D:5E"); // false (wrong length)
23
+ *
24
+ * @example
25
+ * isMacAddress("00:1G:2B:3C:4D:5E"); // false (invalid hex digit 'G')
26
+ */
27
+ export declare function isMacAddress(str: string): boolean;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMacAddress = isMacAddress;
4
+ /**
5
+ * Checks if a given string is a valid MAC address.
6
+ *
7
+ * Valid MAC addresses consist of six pairs of hexadecimal digits (0-9, A-F)
8
+ * separated either by colons (:) or hyphens (-). Example formats:
9
+ * - "00:1A:2B:3C:4D:5E"
10
+ * - "00-1A-2B-3C-4D-5E"
11
+ *
12
+ * Mixed or missing separators, invalid hex characters, or incorrect lengths
13
+ * are not allowed.
14
+ *
15
+ * @param {string} str - The string to validate as a MAC address.
16
+ * @returns {boolean} `true` if the string is a valid MAC address, otherwise `false`.
17
+ *
18
+ * @example
19
+ * isMacAddress("00:1A:2B:3C:4D:5E"); // true
20
+ *
21
+ * @example
22
+ * isMacAddress("00-1A-2B-3C-4D-5E"); // true
23
+ *
24
+ * @example
25
+ * isMacAddress("001A:2B:3C:4D:5E"); // false (wrong length)
26
+ *
27
+ * @example
28
+ * isMacAddress("00:1G:2B:3C:4D:5E"); // false (invalid hex digit 'G')
29
+ */
30
+ function isMacAddress(str) {
31
+ const macRegex = /^([0-9A-Fa-f]{2}([:-])){5}([0-9A-Fa-f]{2})$/;
32
+ // Check regex first
33
+ if (!macRegex.test(str))
34
+ return false;
35
+ // Ensure all separators are the same (either all ':' or all '-')
36
+ const separator = str[2];
37
+ const expectedSeparator = separator === ':' ? ':' : '-';
38
+ for (let i = 2; i < str.length; i += 3) {
39
+ if (str[i] !== expectedSeparator)
40
+ return false;
41
+ }
42
+ return true;
43
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Checks whether the given string is a palindrome.
3
+ *
4
+ * The check is case-insensitive and ignores all non-alphanumeric characters.
5
+ *
6
+ * @param {string} str - The input string to check.
7
+ * @returns {boolean} True if the input is a palindrome, false otherwise.
8
+ * @throws {TypeError} If the input is not a string.
9
+ */
10
+ export declare function isPalindrome(str: string): boolean;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPalindrome = isPalindrome;
4
+ /**
5
+ * Checks whether the given string is a palindrome.
6
+ *
7
+ * The check is case-insensitive and ignores all non-alphanumeric characters.
8
+ *
9
+ * @param {string} str - The input string to check.
10
+ * @returns {boolean} True if the input is a palindrome, false otherwise.
11
+ * @throws {TypeError} If the input is not a string.
12
+ */
13
+ function isPalindrome(str) {
14
+ if (typeof str !== 'string') {
15
+ throw new TypeError('Input must be a string');
16
+ }
17
+ const sanitized = str
18
+ .toLowerCase()
19
+ .replace(/[^a-z0-9]/gi, '');
20
+ return sanitized === sanitized.split('').reverse().join('');
21
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Checks if a given string is a pangram (contains every letter of the English alphabet at least once).
3
+ *
4
+ * The check is case-insensitive, and non-alphabetic characters (numbers, punctuation, spaces)
5
+ * are ignored. An empty string is not considered a pangram.
6
+ *
7
+ * @param {string} str - The input string to validate.
8
+ * @returns {boolean} True if the string is a pangram, otherwise false.
9
+ * @throws {TypeError} If the input is not a string.
10
+ *
11
+ * @example
12
+ * isPangram("The quick brown fox jumps over the lazy dog."); // true
13
+ *
14
+ * @example
15
+ * isPangram("This is not a pangram."); // false
16
+ *
17
+ * @example
18
+ * isPangram("Abcdefghijklmnopqrstuvwxyz"); // true
19
+ */
20
+ export declare function isPanagram(str: string): boolean;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPanagram = isPanagram;
4
+ /**
5
+ * Checks if a given string is a pangram (contains every letter of the English alphabet at least once).
6
+ *
7
+ * The check is case-insensitive, and non-alphabetic characters (numbers, punctuation, spaces)
8
+ * are ignored. An empty string is not considered a pangram.
9
+ *
10
+ * @param {string} str - The input string to validate.
11
+ * @returns {boolean} True if the string is a pangram, otherwise false.
12
+ * @throws {TypeError} If the input is not a string.
13
+ *
14
+ * @example
15
+ * isPangram("The quick brown fox jumps over the lazy dog."); // true
16
+ *
17
+ * @example
18
+ * isPangram("This is not a pangram."); // false
19
+ *
20
+ * @example
21
+ * isPangram("Abcdefghijklmnopqrstuvwxyz"); // true
22
+ */
23
+ function isPanagram(str) {
24
+ if (typeof str !== 'string') {
25
+ throw new TypeError('Input must be a string');
26
+ }
27
+ if (str === '')
28
+ return false;
29
+ // Normalize string: lowercase and remove non-letters
30
+ const normalized = str.toLowerCase().replace(/[^a-z]/g, '');
31
+ // Create a set of unique letters
32
+ const uniqueLetters = new Set(normalized);
33
+ // Pangram if it has all 26 letters
34
+ return uniqueLetters.size === 26;
35
+ }
@@ -1 +1,28 @@
1
+ /**
2
+ * Checks if a given string is a valid slug.
3
+ *
4
+ * A valid slug:
5
+ * - Contains only lowercase letters (`a-z`), numbers (`0-9`), and hyphens (`-`).
6
+ * - Does not start or end with a hyphen.
7
+ * - Does not contain consecutive hyphens.
8
+ * - Is not an empty string.
9
+ *
10
+ * @param {string} str - The string to validate as a slug.
11
+ * @returns {boolean} `true` if the string is a valid slug, otherwise `false`.
12
+ *
13
+ * @example
14
+ * isSlug("valid-slug-123"); // true
15
+ *
16
+ * @example
17
+ * isSlug("Invalid-Slug"); // false (uppercase letters)
18
+ *
19
+ * @example
20
+ * isSlug("-starts-with-hyphen"); // false
21
+ *
22
+ * @example
23
+ * isSlug("ends-with-hyphen-"); // false
24
+ *
25
+ * @example
26
+ * isSlug("double--hyphen"); // false
27
+ */
1
28
  export declare function isSlug(str: string): boolean;
@@ -1,6 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isSlug = isSlug;
4
+ /**
5
+ * Checks if a given string is a valid slug.
6
+ *
7
+ * A valid slug:
8
+ * - Contains only lowercase letters (`a-z`), numbers (`0-9`), and hyphens (`-`).
9
+ * - Does not start or end with a hyphen.
10
+ * - Does not contain consecutive hyphens.
11
+ * - Is not an empty string.
12
+ *
13
+ * @param {string} str - The string to validate as a slug.
14
+ * @returns {boolean} `true` if the string is a valid slug, otherwise `false`.
15
+ *
16
+ * @example
17
+ * isSlug("valid-slug-123"); // true
18
+ *
19
+ * @example
20
+ * isSlug("Invalid-Slug"); // false (uppercase letters)
21
+ *
22
+ * @example
23
+ * isSlug("-starts-with-hyphen"); // false
24
+ *
25
+ * @example
26
+ * isSlug("ends-with-hyphen-"); // false
27
+ *
28
+ * @example
29
+ * isSlug("double--hyphen"); // false
30
+ */
4
31
  function isSlug(str) {
5
32
  if (typeof str !== 'string' || str.length === 0) {
6
33
  return false;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Checks if a file name or URL string has a valid extension for a given type.
3
+ *
4
+ * @param {string} input - File name or URL.
5
+ * @param {string} type - The type category to validate.
6
+ * @returns {boolean}
7
+ * @throws error when input is not string or type is not defined
8
+ */
9
+ export declare function isTypeOf(input: string, type: string): boolean;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTypeOf = isTypeOf;
4
+ /**
5
+ * Checks if a file name or URL string has a valid extension for a given type.
6
+ *
7
+ * @param {string} input - File name or URL.
8
+ * @param {string} type - The type category to validate.
9
+ * @returns {boolean}
10
+ * @throws error when input is not string or type is not defined
11
+ */
12
+ function isTypeOf(input, type) {
13
+ var _a;
14
+ if (typeof input !== "string" || typeof type !== "string")
15
+ return false;
16
+ // Gets the substring after the last (.), then converts to lowercase, removes (?) and (#)
17
+ // Example: "image.png?version=2#top", returns "png"
18
+ const extension = (_a = input.split(".").pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase().split("?")[0].split("#")[0];
19
+ if (!extension)
20
+ return false;
21
+ const typeMap = {
22
+ image: ["png", "jpg", "jpeg", "gif", "bmp", "svg", "webp", "ico"],
23
+ video: ["mp4", "webm", "avi", "mkv", "mov", "flv"],
24
+ audio: ["mp3", "wav", "ogg", "flac", "aac"],
25
+ document: ["pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt", "md"],
26
+ archive: ["zip", "rar", "tar", "gz", "7z"],
27
+ };
28
+ const allowed = typeMap[type.toLowerCase()];
29
+ return allowed ? allowed.includes(extension) : false;
30
+ }
@@ -1 +1,22 @@
1
+ /**
2
+ * Checks if a given string is a valid URL.
3
+ *
4
+ * Uses the built-in `URL` constructor to attempt parsing the input string.
5
+ * Returns `true` if the string is a valid URL, otherwise `false`.
6
+ *
7
+ * @param {string} str - The string to validate as a URL.
8
+ * @returns {boolean} `true` if the string is a valid URL, otherwise `false`.
9
+ *
10
+ * @example
11
+ * isURL("https://www.example.com"); // true
12
+ *
13
+ * @example
14
+ * isURL("ftp://ftp.example.com/resource.txt"); // true
15
+ *
16
+ * @example
17
+ * isURL("not a url"); // false
18
+ *
19
+ * @example
20
+ * isURL("http:/invalid-url"); // false
21
+ */
1
22
  export declare function isURL(str: string): boolean;
@@ -1,6 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isURL = isURL;
4
+ /**
5
+ * Checks if a given string is a valid URL.
6
+ *
7
+ * Uses the built-in `URL` constructor to attempt parsing the input string.
8
+ * Returns `true` if the string is a valid URL, otherwise `false`.
9
+ *
10
+ * @param {string} str - The string to validate as a URL.
11
+ * @returns {boolean} `true` if the string is a valid URL, otherwise `false`.
12
+ *
13
+ * @example
14
+ * isURL("https://www.example.com"); // true
15
+ *
16
+ * @example
17
+ * isURL("ftp://ftp.example.com/resource.txt"); // true
18
+ *
19
+ * @example
20
+ * isURL("not a url"); // false
21
+ *
22
+ * @example
23
+ * isURL("http:/invalid-url"); // false
24
+ */
4
25
  function isURL(str) {
5
26
  try {
6
27
  new URL(str);
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Checks whether the given string contains only uppercase alphabetic characters.
3
+ *
4
+ * - At least one alphabetic character must be present.
5
+ * - Digits, spaces, and special characters are ignored.
6
+ * - If any lowercase alphabetic character is found, it returns false.
7
+ *
8
+ * @param {string} str - The input string to check.
9
+ * @returns {boolean} True if all alphabetic characters are uppercase and at least one exists, false otherwise.
10
+ * @throws {TypeError} If the input is not a string.
11
+ */
12
+ export declare function isUpperCase(str: string): boolean;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUpperCase = isUpperCase;
4
+ /**
5
+ * Checks whether the given string contains only uppercase alphabetic characters.
6
+ *
7
+ * - At least one alphabetic character must be present.
8
+ * - Digits, spaces, and special characters are ignored.
9
+ * - If any lowercase alphabetic character is found, it returns false.
10
+ *
11
+ * @param {string} str - The input string to check.
12
+ * @returns {boolean} True if all alphabetic characters are uppercase and at least one exists, false otherwise.
13
+ * @throws {TypeError} If the input is not a string.
14
+ */
15
+ function isUpperCase(str) {
16
+ if (typeof str !== 'string') {
17
+ throw new TypeError('Input must be a string');
18
+ }
19
+ if (str.length === 0) {
20
+ return false;
21
+ }
22
+ let hasLetter = false;
23
+ for (const char of str) {
24
+ if (/[a-z]/.test(char)) {
25
+ return false;
26
+ }
27
+ if (/[A-Z]/.test(char)) {
28
+ hasLetter = true;
29
+ }
30
+ }
31
+ return hasLetter;
32
+ }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "stringzy",
3
- "version": "3.0.0",
3
+ "version": "4.1.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
7
7
  "build": "tsc",
8
- "test": "npm run build && node --test",
9
- "prepublishOnly": "npm run build"
8
+ "test": " npm run build && node --test",
9
+ "prepublishOnly": "npm run build",
10
+ "format": "prettier --write ."
10
11
  },
11
12
  "author": "Samarth Ruia",
12
13
  "readmeFilename": "README.md",
@@ -44,7 +45,8 @@
44
45
  "url": "git+https://github.com/Samarth2190/stringzy.git"
45
46
  },
46
47
  "devDependencies": {
47
- "@types/node": "^24.0.0",
48
+ "@types/node": "^24.5.2",
49
+ "prettier": "^3.6.2",
48
50
  "typescript": "^5.8.3"
49
51
  }
50
52
  }