stringzy 4.0.0 → 4.2.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 (139) hide show
  1. package/.github/workflows/auto-assign.yml +26 -0
  2. package/CODE_OF_CONDUCT.MD +115 -0
  3. package/README.md +963 -40
  4. package/dist/analyzing/checkMultiplePatterns.d.ts +14 -0
  5. package/dist/analyzing/checkMultiplePatterns.js +75 -0
  6. package/dist/analyzing/checkSubsequence.d.ts +14 -0
  7. package/dist/analyzing/checkSubsequence.js +33 -0
  8. package/dist/analyzing/contentWordCount.d.ts +11 -0
  9. package/dist/analyzing/contentWordCount.js +23 -0
  10. package/dist/analyzing/functionWordCount.d.ts +11 -0
  11. package/dist/analyzing/functionWordCount.js +33 -0
  12. package/dist/analyzing/index.d.ts +14 -0
  13. package/dist/analyzing/index.js +22 -2
  14. package/dist/analyzing/lexicographicalRank.d.ts +26 -0
  15. package/dist/analyzing/lexicographicalRank.js +66 -0
  16. package/dist/analyzing/patternCount.d.ts +6 -5
  17. package/dist/analyzing/patternCount.js +19 -17
  18. package/dist/analyzing/stringRotation.d.ts +29 -0
  19. package/dist/analyzing/stringRotation.js +44 -0
  20. package/dist/formatting/binary.d.ts +24 -0
  21. package/dist/formatting/binary.js +49 -0
  22. package/dist/formatting/creditCard.d.ts +8 -0
  23. package/dist/formatting/creditCard.js +28 -0
  24. package/dist/formatting/decimal.d.ts +21 -0
  25. package/dist/formatting/decimal.js +73 -0
  26. package/dist/formatting/duration.d.ts +27 -0
  27. package/dist/formatting/duration.js +92 -0
  28. package/dist/formatting/fileSize.d.ts +18 -0
  29. package/dist/formatting/fileSize.js +39 -0
  30. package/dist/formatting/hexadecimal.d.ts +14 -0
  31. package/dist/formatting/hexadecimal.js +38 -0
  32. package/dist/formatting/index.d.ts +42 -0
  33. package/dist/formatting/index.js +57 -1
  34. package/dist/formatting/listToString.d.ts +17 -0
  35. package/dist/formatting/listToString.js +35 -0
  36. package/dist/formatting/octal.d.ts +19 -0
  37. package/dist/formatting/octal.js +31 -0
  38. package/dist/formatting/ordinal.d.ts +20 -0
  39. package/dist/formatting/ordinal.js +43 -0
  40. package/dist/formatting/percentage.d.ts +19 -0
  41. package/dist/formatting/percentage.js +31 -0
  42. package/dist/formatting/romanNumerals.d.ts +20 -0
  43. package/dist/formatting/romanNumerals.js +53 -0
  44. package/dist/formatting/scientific.d.ts +14 -0
  45. package/dist/formatting/scientific.js +24 -0
  46. package/dist/formatting/temperature.d.ts +6 -0
  47. package/dist/formatting/temperature.js +27 -0
  48. package/dist/formatting/trim.d.ts +10 -0
  49. package/dist/formatting/trim.js +20 -0
  50. package/dist/index.d.ts +30 -0
  51. package/dist/tests/analyzing/checkMultiplePatterns.test.d.ts +1 -0
  52. package/dist/tests/analyzing/checkMultiplePatterns.test.js +81 -0
  53. package/dist/tests/analyzing/checkSubsequence.test.d.ts +1 -0
  54. package/dist/tests/analyzing/checkSubsequence.test.js +34 -0
  55. package/dist/tests/analyzing/contentWordCount.test.d.ts +1 -0
  56. package/dist/tests/analyzing/contentWordCount.test.js +20 -0
  57. package/dist/tests/analyzing/functionWordCount.test.d.ts +1 -0
  58. package/dist/tests/analyzing/functionWordCount.test.js +20 -0
  59. package/dist/tests/analyzing/lexicographicalRank.test.d.ts +1 -0
  60. package/dist/tests/analyzing/lexicographicalRank.test.js +43 -0
  61. package/dist/tests/analyzing/stringRotation.test.d.ts +1 -0
  62. package/dist/tests/analyzing/stringRotation.test.js +42 -0
  63. package/dist/tests/formatting/binary.test.d.ts +1 -0
  64. package/dist/tests/formatting/binary.test.js +53 -0
  65. package/dist/tests/formatting/creditCard.test.d.ts +1 -0
  66. package/dist/tests/formatting/creditCard.test.js +31 -0
  67. package/dist/tests/formatting/decimal.test.d.ts +1 -0
  68. package/dist/tests/formatting/decimal.test.js +62 -0
  69. package/dist/tests/formatting/duration.test.d.ts +1 -0
  70. package/dist/tests/formatting/duration.test.js +61 -0
  71. package/dist/tests/formatting/fileSize.test.d.ts +1 -0
  72. package/dist/tests/formatting/fileSize.test.js +39 -0
  73. package/dist/tests/formatting/hexadecimal.test.d.ts +1 -0
  74. package/dist/tests/formatting/hexadecimal.test.js +38 -0
  75. package/dist/tests/formatting/listToString.test.d.ts +1 -0
  76. package/dist/tests/formatting/listToString.test.js +37 -0
  77. package/dist/tests/formatting/octal.test.d.ts +1 -0
  78. package/dist/tests/formatting/octal.test.js +36 -0
  79. package/dist/tests/formatting/ordinal.test.d.ts +1 -0
  80. package/dist/tests/formatting/ordinal.test.js +37 -0
  81. package/dist/tests/formatting/percentage.test.d.ts +1 -0
  82. package/dist/tests/formatting/percentage.test.js +38 -0
  83. package/dist/tests/formatting/romanNumerals.test.d.ts +1 -0
  84. package/dist/tests/formatting/romanNumerals.test.js +35 -0
  85. package/dist/tests/formatting/scientific.test.d.ts +1 -0
  86. package/dist/tests/formatting/scientific.test.js +35 -0
  87. package/dist/tests/formatting/temperature.test.d.ts +1 -0
  88. package/dist/tests/formatting/temperature.test.js +34 -0
  89. package/dist/tests/formatting/trim.test.d.ts +1 -0
  90. package/dist/tests/formatting/trim.test.js +42 -0
  91. package/dist/tests/transformations/reverseString.test.d.ts +1 -0
  92. package/dist/tests/transformations/reverseString.test.js +41 -0
  93. package/dist/tests/transformations/stringCombinations.test.d.ts +1 -0
  94. package/dist/tests/transformations/stringCombinations.test.js +41 -0
  95. package/dist/tests/transformations/stringPermutations.test.d.ts +1 -0
  96. package/dist/tests/transformations/stringPermutations.test.js +110 -0
  97. package/dist/tests/validations/isAlphaNumeric.test.d.ts +1 -0
  98. package/dist/tests/validations/isAlphaNumeric.test.js +30 -0
  99. package/dist/tests/validations/isAlphabetic.test.d.ts +1 -0
  100. package/dist/tests/validations/isAlphabetic.test.js +32 -0
  101. package/dist/tests/validations/isAnagram.test.d.ts +1 -0
  102. package/dist/tests/validations/isAnagram.test.js +44 -0
  103. package/dist/tests/validations/isIPv6.test.d.ts +1 -0
  104. package/dist/tests/validations/isIPv6.test.js +65 -0
  105. package/dist/tests/validations/isLowerCase.test.d.ts +1 -0
  106. package/dist/tests/validations/isLowerCase.test.js +50 -0
  107. package/dist/tests/validations/isMacAddress.test.d.ts +1 -0
  108. package/dist/tests/validations/isMacAddress.test.js +72 -0
  109. package/dist/tests/validations/isPanagram.test.d.ts +1 -0
  110. package/dist/tests/validations/isPanagram.test.js +39 -0
  111. package/dist/tests/validations/isUpperCase.test.d.ts +1 -0
  112. package/dist/tests/validations/isUpperCase.test.js +50 -0
  113. package/dist/transformations/index.d.ts +10 -0
  114. package/dist/transformations/index.js +16 -2
  115. package/dist/transformations/reverseWordsInString .d.ts +9 -0
  116. package/dist/transformations/reverseWordsInString .js +49 -0
  117. package/dist/transformations/stringCombinations.d.ts +28 -0
  118. package/dist/transformations/stringCombinations.js +44 -0
  119. package/dist/transformations/stringPermutations.d.ts +53 -0
  120. package/dist/transformations/stringPermutations.js +179 -0
  121. package/dist/validations/index.d.ts +24 -0
  122. package/dist/validations/index.js +34 -2
  123. package/dist/validations/isAlphaNumeric.d.ts +11 -0
  124. package/dist/validations/isAlphaNumeric.js +22 -0
  125. package/dist/validations/isAlphabetic.d.ts +9 -0
  126. package/dist/validations/isAlphabetic.js +21 -0
  127. package/dist/validations/isAnagram.d.ts +13 -0
  128. package/dist/validations/isAnagram.js +23 -0
  129. package/dist/validations/isIPv6.d.ts +24 -0
  130. package/dist/validations/isIPv6.js +45 -0
  131. package/dist/validations/isLowerCase.d.ts +12 -0
  132. package/dist/validations/isLowerCase.js +32 -0
  133. package/dist/validations/isMacAddress.d.ts +27 -0
  134. package/dist/validations/isMacAddress.js +43 -0
  135. package/dist/validations/isPanagram.d.ts +20 -0
  136. package/dist/validations/isPanagram.js +35 -0
  137. package/dist/validations/isUpperCase.d.ts +12 -0
  138. package/dist/validations/isUpperCase.js +32 -0
  139. package/package.json +3 -3
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Checks if a given string is a valid IPv6 address.
3
+ *
4
+ * Valid IPv6 addresses consist of eight groups of four hexadecimal digits (0-9, a-f, A-F)
5
+ * separated by colons (:). Each group can have 1 to 4 hex digits.
6
+ * Leading zeros are allowed. IPv6 addresses can also use the "::" shorthand once
7
+ * to represent one or more groups of zeros.
8
+ *
9
+ * @param {string} str - The string to validate as an IPv6 address.
10
+ * @returns {boolean} `true` if the string is a valid IPv6 address, otherwise `false`.
11
+ *
12
+ * @example
13
+ * isIPv6("2001:0db8:85a3:0000:0000:8a2e:0370:7334"); // true
14
+ *
15
+ * @example
16
+ * isIPv6("2001:db8:85a3::8a2e:370:7334"); // true (uses shorthand)
17
+ *
18
+ * @example
19
+ * isIPv6("2001:db8:::1"); // false (invalid use of shorthand)
20
+ *
21
+ * @example
22
+ * isIPv6("12345::abcd"); // false (group too long)
23
+ */
24
+ export declare function isIPv6(str: string): boolean;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isIPv6 = isIPv6;
4
+ /**
5
+ * Checks if a given string is a valid IPv6 address.
6
+ *
7
+ * Valid IPv6 addresses consist of eight groups of four hexadecimal digits (0-9, a-f, A-F)
8
+ * separated by colons (:). Each group can have 1 to 4 hex digits.
9
+ * Leading zeros are allowed. IPv6 addresses can also use the "::" shorthand once
10
+ * to represent one or more groups of zeros.
11
+ *
12
+ * @param {string} str - The string to validate as an IPv6 address.
13
+ * @returns {boolean} `true` if the string is a valid IPv6 address, otherwise `false`.
14
+ *
15
+ * @example
16
+ * isIPv6("2001:0db8:85a3:0000:0000:8a2e:0370:7334"); // true
17
+ *
18
+ * @example
19
+ * isIPv6("2001:db8:85a3::8a2e:370:7334"); // true (uses shorthand)
20
+ *
21
+ * @example
22
+ * isIPv6("2001:db8:::1"); // false (invalid use of shorthand)
23
+ *
24
+ * @example
25
+ * isIPv6("12345::abcd"); // false (group too long)
26
+ */
27
+ function isIPv6(str) {
28
+ const lower = str.toLowerCase();
29
+ if (!/^[0-9a-f:]+$/.test(lower))
30
+ return false;
31
+ const parts = lower.split("::");
32
+ if (parts.length > 2)
33
+ return false;
34
+ const left = parts[0] ? parts[0].split(":") : [];
35
+ const right = parts[1] ? parts[1].split(":") : [];
36
+ // Each part (excluding shorthand) must be 1–4 hex digits
37
+ const validGroup = (g) => /^[0-9a-f]{1,4}$/.test(g);
38
+ if (!left.every(validGroup) || !right.every(validGroup))
39
+ return false;
40
+ const totalGroups = left.length + right.length;
41
+ if (parts.length === 1)
42
+ return totalGroups === 8;
43
+ else
44
+ return totalGroups < 8;
45
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Checks whether the given string contains only lowercase alphabetic characters.
3
+ *
4
+ * - At least one alphabetic character must be present.
5
+ * - Digits, spaces, and special characters are ignored.
6
+ * - If any uppercase 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 lowercase and at least one exists, false otherwise.
10
+ * @throws {TypeError} If the input is not a string.
11
+ */
12
+ export declare function isLowerCase(str: string): boolean;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isLowerCase = isLowerCase;
4
+ /**
5
+ * Checks whether the given string contains only lowercase alphabetic characters.
6
+ *
7
+ * - At least one alphabetic character must be present.
8
+ * - Digits, spaces, and special characters are ignored.
9
+ * - If any uppercase 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 lowercase and at least one exists, false otherwise.
13
+ * @throws {TypeError} If the input is not a string.
14
+ */
15
+ function isLowerCase(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
+ }
@@ -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,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
+ }
@@ -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,11 +1,11 @@
1
1
  {
2
2
  "name": "stringzy",
3
- "version": "4.0.0",
3
+ "version": "4.2.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",
8
+ "test": " npm run build && node --test",
9
9
  "prepublishOnly": "npm run build",
10
10
  "format": "prettier --write ."
11
11
  },
@@ -45,7 +45,7 @@
45
45
  "url": "git+https://github.com/Samarth2190/stringzy.git"
46
46
  },
47
47
  "devDependencies": {
48
- "@types/node": "^24.0.4",
48
+ "@types/node": "^24.5.2",
49
49
  "prettier": "^3.6.2",
50
50
  "typescript": "^5.8.3"
51
51
  }