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,19 @@
1
+ /**
2
+ * Converts a number into a percentage string with configurable decimal precision.
3
+ *
4
+ * Supports positive, negative, and whole numbers.
5
+ *
6
+ * Examples:
7
+ * 0.567 → "56.70%"
8
+ * 0.567 → "56.7%" (precision = 1)
9
+ * 0.5 → "50%"
10
+ * 1 → "100%"
11
+ * -0.25 → "-25%"
12
+ * 50 → "5000%"
13
+ *
14
+ * @param {number} num - The number to convert into a percentage.
15
+ * @param {number} [precision=2] - The number of decimal places to include.
16
+ * @returns {string} The formatted percentage string.
17
+ * @throws {TypeError} If the input is not a number or precision is not a number.
18
+ */
19
+ export declare function formatPercentage(num: number, precision?: number): string;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatPercentage = formatPercentage;
4
+ /**
5
+ * Converts a number into a percentage string with configurable decimal precision.
6
+ *
7
+ * Supports positive, negative, and whole numbers.
8
+ *
9
+ * Examples:
10
+ * 0.567 → "56.70%"
11
+ * 0.567 → "56.7%" (precision = 1)
12
+ * 0.5 → "50%"
13
+ * 1 → "100%"
14
+ * -0.25 → "-25%"
15
+ * 50 → "5000%"
16
+ *
17
+ * @param {number} num - The number to convert into a percentage.
18
+ * @param {number} [precision=2] - The number of decimal places to include.
19
+ * @returns {string} The formatted percentage string.
20
+ * @throws {TypeError} If the input is not a number or precision is not a number.
21
+ */
22
+ function formatPercentage(num, precision = 2) {
23
+ if (typeof num !== 'number' || Number.isNaN(num)) {
24
+ throw new TypeError('Input must be a number');
25
+ }
26
+ if (typeof precision !== 'number' || Number.isNaN(precision) || precision < 0) {
27
+ throw new TypeError('Precision must be a non-negative number');
28
+ }
29
+ const percentage = num * 100;
30
+ return `${percentage.toFixed(precision)}%`;
31
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Converts a positive integer into its Roman numeral representation.
3
+ *
4
+ * Supports numbers from 1 to 3999 using standard Roman numeral notation.
5
+ *
6
+ * Examples:
7
+ * 1 → "I"
8
+ * 4 → "IV"
9
+ * 9 → "IX"
10
+ * 58 → "LVIII"
11
+ * 1994 → "MCMXCIV"
12
+ * 2025 → "MMXXV"
13
+ * 3999 → "MMMCMXCIX"
14
+ *
15
+ * @param {number} num - The positive integer to convert (1–3999).
16
+ * @returns {string} The Roman numeral representation of the given number.
17
+ * @throws {RangeError} If the number is less than or equal to 0, or greater than 3999.
18
+ * @throws {TypeError} If the input is not a number.
19
+ */
20
+ export declare function formatRomanNumeral(num: number): string;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatRomanNumeral = formatRomanNumeral;
4
+ /**
5
+ * Converts a positive integer into its Roman numeral representation.
6
+ *
7
+ * Supports numbers from 1 to 3999 using standard Roman numeral notation.
8
+ *
9
+ * Examples:
10
+ * 1 → "I"
11
+ * 4 → "IV"
12
+ * 9 → "IX"
13
+ * 58 → "LVIII"
14
+ * 1994 → "MCMXCIV"
15
+ * 2025 → "MMXXV"
16
+ * 3999 → "MMMCMXCIX"
17
+ *
18
+ * @param {number} num - The positive integer to convert (1–3999).
19
+ * @returns {string} The Roman numeral representation of the given number.
20
+ * @throws {RangeError} If the number is less than or equal to 0, or greater than 3999.
21
+ * @throws {TypeError} If the input is not a number.
22
+ */
23
+ function formatRomanNumeral(num) {
24
+ if (typeof num !== 'number' || Number.isNaN(num)) {
25
+ throw new TypeError('Input must be a number');
26
+ }
27
+ if (num <= 0) {
28
+ throw new RangeError('Roman numerals are only defined for positive integers');
29
+ }
30
+ if (num > 3999) {
31
+ throw new RangeError('Roman numerals are supported only up to 3999');
32
+ }
33
+ const values = [
34
+ 1000, 900, 500, 400,
35
+ 100, 90, 50, 40,
36
+ 10, 9, 5, 4, 1
37
+ ];
38
+ const symbols = [
39
+ 'M', 'CM', 'D', 'CD',
40
+ 'C', 'XC', 'L', 'XL',
41
+ 'X', 'IX', 'V', 'IV', 'I'
42
+ ];
43
+ let result = '';
44
+ let i = 0;
45
+ while (num > 0) {
46
+ while (num >= values[i]) {
47
+ result += symbols[i];
48
+ num -= values[i];
49
+ }
50
+ i++;
51
+ }
52
+ return result;
53
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Converts a number to scientific (exponential) notation.
3
+ *
4
+ * @param {number} num - The number to convert.
5
+ * @param {object} [options] - Optional formatting settings.
6
+ * @param {number} [options.precision=2] - Number of digits after the decimal point.
7
+ * @param {boolean} [options.uppercase=false] - Whether to use uppercase "E" in the notation.
8
+ * @returns {string} Scientific notation of the number.
9
+ * @throws {TypeError} If input is not a valid number.
10
+ */
11
+ export declare function formatScientific(num: number, options?: {
12
+ precision?: number;
13
+ uppercase?: boolean;
14
+ }): string;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatScientific = formatScientific;
4
+ /**
5
+ * Converts a number to scientific (exponential) notation.
6
+ *
7
+ * @param {number} num - The number to convert.
8
+ * @param {object} [options] - Optional formatting settings.
9
+ * @param {number} [options.precision=2] - Number of digits after the decimal point.
10
+ * @param {boolean} [options.uppercase=false] - Whether to use uppercase "E" in the notation.
11
+ * @returns {string} Scientific notation of the number.
12
+ * @throws {TypeError} If input is not a valid number.
13
+ */
14
+ function formatScientific(num, options) {
15
+ if (typeof num !== 'number' || isNaN(num)) {
16
+ throw new TypeError('Input must be a valid number');
17
+ }
18
+ const { precision = 2, uppercase = false } = options || {};
19
+ let scientific = num.toExponential(precision);
20
+ if (uppercase) {
21
+ scientific = scientific.replace('e', 'E');
22
+ }
23
+ return scientific;
24
+ }
@@ -0,0 +1,6 @@
1
+ declare function formatTemperature(value: number, options: {
2
+ from: string;
3
+ to: string;
4
+ precision?: number;
5
+ }): string;
6
+ export { formatTemperature };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatTemperature = formatTemperature;
4
+ function formatTemperature(value, options) {
5
+ const { from, to, precision = 2 } = options;
6
+ const conversions = {
7
+ 'C_F': (v) => (v * 9) / 5 + 32,
8
+ 'C_K': (v) => v + 273.15,
9
+ 'F_C': (v) => ((v - 32) * 5) / 9,
10
+ 'F_K': (v) => ((v - 32) * 5) / 9 + 273.15,
11
+ 'K_C': (v) => v - 273.15,
12
+ 'K_F': (v) => ((v - 273.15) * 9) / 5 + 32
13
+ };
14
+ const conversionKey = `${from}_${to}`;
15
+ const convert = conversions[conversionKey];
16
+ if (!convert) {
17
+ throw new Error(`Invalid conversion from ${from} to ${to}.`);
18
+ }
19
+ if (typeof value !== 'number' || isNaN(value)) {
20
+ throw new Error('Invalid temperature value.');
21
+ }
22
+ const convertedValue = convert(value);
23
+ if (to === 'K') {
24
+ return `${convertedValue.toFixed(precision)}K`;
25
+ }
26
+ return `${convertedValue.toFixed(precision)}°${to}`;
27
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Removes unnecessary whitespace from a string.
3
+ * This includes leading/trailing spaces, multiple consecutive spaces, tabs, and line breaks.
4
+ * The result is a clean, single-spaced string.
5
+ *
6
+ * @param {string} str - The input string to format.
7
+ * @returns {string} The trimmed and normalized string.
8
+ * @throws {TypeError} If the input is not a string.
9
+ */
10
+ export declare function trim(str: string): string;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.trim = trim;
4
+ /**
5
+ * Removes unnecessary whitespace from a string.
6
+ * This includes leading/trailing spaces, multiple consecutive spaces, tabs, and line breaks.
7
+ * The result is a clean, single-spaced string.
8
+ *
9
+ * @param {string} str - The input string to format.
10
+ * @returns {string} The trimmed and normalized string.
11
+ * @throws {TypeError} If the input is not a string.
12
+ */
13
+ function trim(str) {
14
+ if (typeof str !== 'string') {
15
+ throw new TypeError('Input must be a string');
16
+ }
17
+ // 1. Trim leading/trailing whitespace (including newlines/tabs)
18
+ // 2. Replace multiple internal whitespace chars (including \n, \t) with a single space
19
+ return str.trim().replace(/\s+/g, ' ');
20
+ }
package/dist/index.d.ts CHANGED
@@ -12,11 +12,29 @@ declare const _default: {
12
12
  stringSimilarity: typeof import("./analyzing").stringSimilarity;
13
13
  patternCount: typeof import("./analyzing").patternCount;
14
14
  vowelConsonantCount: typeof import("./analyzing").vowelConsonantCount;
15
+ checkMultiplePatterns: typeof import("./analyzing").checkMultiplePatterns;
16
+ checkSubsequence: typeof import("./analyzing").checkSubsequence;
17
+ checkStringRotations: typeof import("./analyzing").checkStringRotations;
18
+ lexicographicalRank: typeof import("./analyzing").lexicographicalRank;
15
19
  };
16
20
  formatting: {
17
21
  capitalize: typeof import("./formatting").capitalize;
18
22
  formatNumber: typeof import("./formatting").formatNumber;
19
23
  formatPhone: typeof import("./formatting").formatPhone;
24
+ formatDuration: typeof import("./formatting").formatDuration;
25
+ trim: typeof import("./formatting").trim;
26
+ formatRomanNumeral: typeof import("./formatting").formatRomanNumeral;
27
+ formatPercentage: typeof import("./formatting").formatPercentage;
28
+ formatFileSize: typeof import("./formatting").formatFileSize;
29
+ formatOrdinal: typeof import("./formatting").formatOrdinal;
30
+ formatList: typeof import("./formatting").formatList;
31
+ formatTemperature: typeof import("./formatting").formatTemperature;
32
+ formatScientific: typeof import("./formatting").formatScientific;
33
+ formatCreditCard: typeof import("./formatting").formatCreditCard;
34
+ formatToBinary: typeof import("./formatting").formatToBinary;
35
+ formatToHexadecimal: typeof import("./formatting").formatToHexadecimal;
36
+ formatToOctal: typeof import("./formatting").formatToOctal;
37
+ formatToDecimal: typeof import("./formatting").formatToDecimal;
20
38
  };
21
39
  transformations: {
22
40
  camelCase: typeof import("./transformations").camelCase;
@@ -36,6 +54,10 @@ declare const _default: {
36
54
  maskSegment: typeof import("./transformations").maskSegment;
37
55
  deburr: typeof import("./transformations/deburr").deburr;
38
56
  numberToText: typeof import("./transformations").numberToText;
57
+ reverseWordsInString: typeof import("./transformations").reverseWordsInString;
58
+ stringPermutations: typeof import("./transformations").stringPermutations;
59
+ stringPermutationsGenerator: typeof import("./transformations").stringPermutationsGenerator;
60
+ stringCombinations: typeof import("./transformations").stringCombinations;
39
61
  };
40
62
  validations: {
41
63
  isCoordinates: typeof import("./validations").isCoordinates;
@@ -45,8 +67,16 @@ declare const _default: {
45
67
  isSlug: typeof import("./validations").isSlug;
46
68
  isURL: typeof import("./validations").isURL;
47
69
  isIPv4: typeof import("./validations").isIPv4;
70
+ isIPv6: typeof import("./validations").isIPv6;
48
71
  isHexColor: typeof import("./validations").isHexColor;
49
72
  isPalindrome: typeof import("./validations").isPalindrome;
73
+ isLowerCase: typeof import("./validations").isLowerCase;
74
+ isUpperCase: typeof import("./validations").isUpperCase;
75
+ isAlphabetic: typeof import("./validations").isAlphabetic;
76
+ isAlphaNumeric: typeof import("./validations").isAlphaNumeric;
77
+ isAnagram: typeof import("./validations").isAnagram;
78
+ isPanagram: typeof import("./validations").isPanagram;
79
+ isMacAddress: typeof import("./validations").isMacAddress;
50
80
  };
51
81
  };
52
82
  export default _default;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_test_1 = require("node:test");
7
+ const node_assert_1 = __importDefault(require("node:assert"));
8
+ const checkMultiplePatterns_1 = require("../../analyzing/checkMultiplePatterns");
9
+ (0, node_test_1.describe)('checkMultiplePatterns', () => {
10
+ (0, node_test_1.it)('finds multiple valid matches', () => {
11
+ const text = 'abracadabra';
12
+ const patterns = ['abra', 'cad'];
13
+ const result = (0, checkMultiplePatterns_1.checkMultiplePatterns)(text, patterns);
14
+ // "abra" occurs at index 0: "abra...cadabra"
15
+ // and again at index 7: "abracad...abra"
16
+ node_assert_1.default.deepStrictEqual(result['abra'], [0, 7]);
17
+ // "cad" occurs once starting at index 4: "abraCADabra"
18
+ node_assert_1.default.deepStrictEqual(result['cad'], [4]);
19
+ });
20
+ (0, node_test_1.it)('handles overlapping patterns', () => {
21
+ const text = 'aaaa';
22
+ const patterns = ['aa', 'aaa'];
23
+ const result = (0, checkMultiplePatterns_1.checkMultiplePatterns)(text, patterns);
24
+ // "aa" occurs at indices 0 ("aa.."), 1 (".aa."), 2 ("..aa")
25
+ node_assert_1.default.deepStrictEqual(result['aa'], [0, 1, 2]);
26
+ // "aaa" occurs at indices 0 ("aaa.") and 1 (".aaa")
27
+ node_assert_1.default.deepStrictEqual(result['aaa'], [0, 1]);
28
+ });
29
+ (0, node_test_1.it)('returns empty arrays when no matches found', () => {
30
+ const text = 'hello world';
31
+ const patterns = ['xyz', '123'];
32
+ const result = (0, checkMultiplePatterns_1.checkMultiplePatterns)(text, patterns);
33
+ // Neither "xyz" nor "123" exist in "hello world"
34
+ node_assert_1.default.deepStrictEqual(result['xyz'], []);
35
+ node_assert_1.default.deepStrictEqual(result['123'], []);
36
+ });
37
+ (0, node_test_1.it)('returns empty object when text is empty', () => {
38
+ // No text to search → nothing to return
39
+ const result = (0, checkMultiplePatterns_1.checkMultiplePatterns)('', ['a', 'b']);
40
+ node_assert_1.default.deepStrictEqual(result, {});
41
+ });
42
+ (0, node_test_1.it)('returns empty object when patterns array is empty', () => {
43
+ // No patterns given → nothing to search for
44
+ const result = (0, checkMultiplePatterns_1.checkMultiplePatterns)('hello', []);
45
+ node_assert_1.default.deepStrictEqual(result, {});
46
+ });
47
+ (0, node_test_1.it)('skips patterns longer than the text', () => {
48
+ const result = (0, checkMultiplePatterns_1.checkMultiplePatterns)('hi', ['longpattern']);
49
+ // pattern is longer than text → no match possible
50
+ node_assert_1.default.deepStrictEqual(result['longpattern'], []);
51
+ });
52
+ (0, node_test_1.it)('is case-sensitive by default', () => {
53
+ const text = 'Hello hello';
54
+ const patterns = ['Hello', 'hello'];
55
+ const result = (0, checkMultiplePatterns_1.checkMultiplePatterns)(text, patterns);
56
+ node_assert_1.default.deepStrictEqual(result['Hello'], [0]);
57
+ node_assert_1.default.deepStrictEqual(result['hello'], [6]);
58
+ });
59
+ (0, node_test_1.it)('handles spaces and special characters as part of patterns', () => {
60
+ const text = 'hi there!';
61
+ const patterns = [' ', '!'];
62
+ const result = (0, checkMultiplePatterns_1.checkMultiplePatterns)(text, patterns);
63
+ // space occurs at index 2, "!" occurs at the end
64
+ node_assert_1.default.deepStrictEqual(result[' '], [2]);
65
+ node_assert_1.default.deepStrictEqual(result['!'], [8]);
66
+ });
67
+ (0, node_test_1.it)('does not match mixed case unless exact', () => {
68
+ const text = 'RabinKarp';
69
+ const patterns = ['rabinkarp'];
70
+ const result = (0, checkMultiplePatterns_1.checkMultiplePatterns)(text, patterns);
71
+ // "rabinkarp" does not match "RabinKarp" because of case
72
+ node_assert_1.default.deepStrictEqual(result['rabinkarp'], []);
73
+ });
74
+ (0, node_test_1.it)('throws if text is not a string', () => {
75
+ node_assert_1.default.throws(() => (0, checkMultiplePatterns_1.checkMultiplePatterns)(123, ['a']), /Text must be a string/);
76
+ });
77
+ (0, node_test_1.it)('throws if patterns is not an array of strings', () => {
78
+ node_assert_1.default.throws(() => (0, checkMultiplePatterns_1.checkMultiplePatterns)('abc', 'a'), /Patterns must be an array of strings/);
79
+ node_assert_1.default.throws(() => (0, checkMultiplePatterns_1.checkMultiplePatterns)('abc', [123]), /Patterns must be an array of strings/);
80
+ });
81
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_test_1 = require("node:test");
7
+ const node_assert_1 = __importDefault(require("node:assert"));
8
+ const checkSubsequence_1 = require("../../analyzing/checkSubsequence");
9
+ (0, node_test_1.describe)('checkSubsequence', () => {
10
+ (0, node_test_1.it)('returns true for valid subsequences', () => {
11
+ node_assert_1.default.strictEqual((0, checkSubsequence_1.checkSubsequence)('abcde', 'ace'), true);
12
+ node_assert_1.default.strictEqual((0, checkSubsequence_1.checkSubsequence)('abracadabra', 'aaa'), true);
13
+ node_assert_1.default.strictEqual((0, checkSubsequence_1.checkSubsequence)('hello world', 'hlo'), true);
14
+ });
15
+ (0, node_test_1.it)('returns false when order is broken', () => {
16
+ node_assert_1.default.strictEqual((0, checkSubsequence_1.checkSubsequence)('abcde', 'aec'), false);
17
+ node_assert_1.default.strictEqual((0, checkSubsequence_1.checkSubsequence)('abcdef', 'z'), false);
18
+ });
19
+ (0, node_test_1.it)('handles empty subsequence', () => {
20
+ node_assert_1.default.strictEqual((0, checkSubsequence_1.checkSubsequence)('anything', ''), true);
21
+ });
22
+ (0, node_test_1.it)('is case-sensitive', () => {
23
+ node_assert_1.default.strictEqual((0, checkSubsequence_1.checkSubsequence)('abc', 'A'), false);
24
+ node_assert_1.default.strictEqual((0, checkSubsequence_1.checkSubsequence)('AbC', 'AC'), true);
25
+ });
26
+ (0, node_test_1.it)('handles spaces as normal characters', () => {
27
+ node_assert_1.default.strictEqual((0, checkSubsequence_1.checkSubsequence)('a b c', 'abc'), true);
28
+ node_assert_1.default.strictEqual((0, checkSubsequence_1.checkSubsequence)('a b c', 'a c'), true);
29
+ });
30
+ (0, node_test_1.it)('throws if inputs are not strings', () => {
31
+ node_assert_1.default.throws(() => (0, checkSubsequence_1.checkSubsequence)(123, 'abc'), /Both inputs must be strings/);
32
+ node_assert_1.default.throws(() => (0, checkSubsequence_1.checkSubsequence)('abc', null), /Both inputs must be strings/);
33
+ });
34
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_test_1 = __importDefault(require("node:test"));
7
+ const strict_1 = __importDefault(require("node:assert/strict"));
8
+ const contentWordCount_js_1 = require("../../analyzing/contentWordCount.js");
9
+ (0, node_test_1.default)("counts content words in a normal sentence", () => {
10
+ strict_1.default.equal((0, contentWordCount_js_1.contentWordCount)("This is a test of the system"), 2);
11
+ });
12
+ (0, node_test_1.default)("returns 0 when there are no content words", () => {
13
+ strict_1.default.equal((0, contentWordCount_js_1.contentWordCount)("is the at of"), 0);
14
+ });
15
+ (0, node_test_1.default)("ignores case and punctuation", () => {
16
+ strict_1.default.equal((0, contentWordCount_js_1.contentWordCount)("Elephants, ELEPHANTS, elephants!"), 3);
17
+ });
18
+ (0, node_test_1.default)("returns 0 for empty string", () => {
19
+ strict_1.default.equal((0, contentWordCount_js_1.contentWordCount)(""), 0);
20
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_test_1 = __importDefault(require("node:test"));
7
+ const strict_1 = __importDefault(require("node:assert/strict"));
8
+ const functionWordCount_js_1 = require("../../analyzing/functionWordCount.js");
9
+ (0, node_test_1.default)("counts function words in a normal sentence", () => {
10
+ strict_1.default.equal((0, functionWordCount_js_1.functionWordCount)("This is a test of the system"), 5);
11
+ });
12
+ (0, node_test_1.default)("returns 0 when there are no function words", () => {
13
+ strict_1.default.equal((0, functionWordCount_js_1.functionWordCount)("Elephants run fast"), 0);
14
+ });
15
+ (0, node_test_1.default)("ignores case and punctuation", () => {
16
+ strict_1.default.equal((0, functionWordCount_js_1.functionWordCount)("The, THE, the!"), 3);
17
+ });
18
+ (0, node_test_1.default)("returns 0 for empty string", () => {
19
+ strict_1.default.equal((0, functionWordCount_js_1.functionWordCount)(""), 0);
20
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_test_1 = require("node:test");
7
+ const node_assert_1 = __importDefault(require("node:assert"));
8
+ const lexicographicalRank_1 = require("../../analyzing/lexicographicalRank");
9
+ (0, node_test_1.describe)('lexicographicalRank', () => {
10
+ (0, node_test_1.it)('returns correct rank for small strings', () => {
11
+ node_assert_1.default.strictEqual((0, lexicographicalRank_1.lexicographicalRank)('acb'), 2);
12
+ node_assert_1.default.strictEqual((0, lexicographicalRank_1.lexicographicalRank)('cba'), 6);
13
+ node_assert_1.default.strictEqual((0, lexicographicalRank_1.lexicographicalRank)('abc'), 1);
14
+ });
15
+ (0, node_test_1.it)('handles strings with repeated characters', () => {
16
+ node_assert_1.default.strictEqual((0, lexicographicalRank_1.lexicographicalRank)('aba'), 2);
17
+ node_assert_1.default.strictEqual((0, lexicographicalRank_1.lexicographicalRank)('aab'), 1);
18
+ node_assert_1.default.strictEqual((0, lexicographicalRank_1.lexicographicalRank)('baa'), 3);
19
+ });
20
+ (0, node_test_1.it)('returns 1 for single character string', () => {
21
+ node_assert_1.default.strictEqual((0, lexicographicalRank_1.lexicographicalRank)('a'), 1);
22
+ node_assert_1.default.strictEqual((0, lexicographicalRank_1.lexicographicalRank)('Z'), 1);
23
+ });
24
+ (0, node_test_1.it)('handles larger examples correctly', () => {
25
+ node_assert_1.default.strictEqual((0, lexicographicalRank_1.lexicographicalRank)('string'), 598);
26
+ });
27
+ (0, node_test_1.it)('handles empty string', () => {
28
+ node_assert_1.default.strictEqual((0, lexicographicalRank_1.lexicographicalRank)(''), 1);
29
+ });
30
+ (0, node_test_1.it)('is case-sensitive', () => {
31
+ node_assert_1.default.strictEqual((0, lexicographicalRank_1.lexicographicalRank)('Abc'), 1); // 'A' < 'b' < 'c'
32
+ node_assert_1.default.strictEqual((0, lexicographicalRank_1.lexicographicalRank)('bAc'), 3);
33
+ });
34
+ (0, node_test_1.it)('handles special characters', () => {
35
+ node_assert_1.default.strictEqual((0, lexicographicalRank_1.lexicographicalRank)('!ab'), 1); // '!' comes first
36
+ node_assert_1.default.strictEqual((0, lexicographicalRank_1.lexicographicalRank)('ab!'), 4); // correct rank is 4
37
+ });
38
+ (0, node_test_1.it)('throws an error if input is not a string', () => {
39
+ node_assert_1.default.throws(() => (0, lexicographicalRank_1.lexicographicalRank)(123), /Input must be a string/);
40
+ node_assert_1.default.throws(() => (0, lexicographicalRank_1.lexicographicalRank)(null), /Input must be a string/);
41
+ node_assert_1.default.throws(() => (0, lexicographicalRank_1.lexicographicalRank)(undefined), /Input must be a string/);
42
+ });
43
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_test_1 = require("node:test");
7
+ const node_assert_1 = __importDefault(require("node:assert"));
8
+ const stringRotation_1 = require("../../analyzing/stringRotation");
9
+ (0, node_test_1.describe)('checkStringRotations', () => {
10
+ (0, node_test_1.it)('returns true for valid rotations', () => {
11
+ node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('abcd', 'cdab'), true);
12
+ node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('hello', 'ohell'), true);
13
+ node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('12345', '45123'), true);
14
+ node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('!@#$', '#$!@'), true);
15
+ });
16
+ (0, node_test_1.it)('returns false for invalid rotations', () => {
17
+ node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('abc', 'acb'), false);
18
+ node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('hello', 'helol'), false);
19
+ node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('12345', '54321'), false);
20
+ });
21
+ (0, node_test_1.it)('is case-sensitive', () => {
22
+ node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('ArB', 'Bar'), false);
23
+ node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('Case', 'case'), false);
24
+ node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('XYZ', 'yzx'), false);
25
+ });
26
+ (0, node_test_1.it)('returns true for empty strings', () => {
27
+ node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('', ''), true);
28
+ });
29
+ (0, node_test_1.it)('returns false for strings of different lengths', () => {
30
+ node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('abc', 'ab'), false);
31
+ node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('abcd', ''), false);
32
+ });
33
+ (0, node_test_1.it)('handles special characters correctly', () => {
34
+ node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('a@b$c', 'b$ca@'), true);
35
+ node_assert_1.default.strictEqual((0, stringRotation_1.checkStringRotations)('a@b$c', 'c$a@b'), false);
36
+ });
37
+ (0, node_test_1.it)('throws an error if inputs are not strings', () => {
38
+ node_assert_1.default.throws(() => (0, stringRotation_1.checkStringRotations)(123, '123'), /Both inputs must be strings/);
39
+ node_assert_1.default.throws(() => (0, stringRotation_1.checkStringRotations)('abc', null), /Both inputs must be strings/);
40
+ node_assert_1.default.throws(() => (0, stringRotation_1.checkStringRotations)(undefined, 'abc'), /Both inputs must be strings/);
41
+ });
42
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_test_1 = require("node:test");
7
+ const node_assert_1 = __importDefault(require("node:assert"));
8
+ const binary_1 = require("../../formatting/binary");
9
+ (0, node_test_1.describe)('formatToBinary', () => {
10
+ (0, node_test_1.it)('converts standard positive integers', () => {
11
+ node_assert_1.default.strictEqual((0, binary_1.formatToBinary)(5), '101');
12
+ node_assert_1.default.strictEqual((0, binary_1.formatToBinary)(10), '1010');
13
+ node_assert_1.default.strictEqual((0, binary_1.formatToBinary)(255), '11111111');
14
+ node_assert_1.default.strictEqual((0, binary_1.formatToBinary)(1), '1');
15
+ node_assert_1.default.strictEqual((0, binary_1.formatToBinary)(2), '10');
16
+ });
17
+ (0, node_test_1.it)('handles zero', () => {
18
+ node_assert_1.default.strictEqual((0, binary_1.formatToBinary)(0), '0');
19
+ });
20
+ (0, node_test_1.it)('prefixes negative numbers with a minus sign', () => {
21
+ node_assert_1.default.strictEqual((0, binary_1.formatToBinary)(-5), '-101');
22
+ node_assert_1.default.strictEqual((0, binary_1.formatToBinary)(-10), '-1010');
23
+ });
24
+ (0, node_test_1.it)('supports optional grouping from right to left (LSB first)', () => {
25
+ node_assert_1.default.strictEqual((0, binary_1.formatToBinary)(255, { group: 4 }), '1111 1111');
26
+ node_assert_1.default.strictEqual((0, binary_1.formatToBinary)(10, { group: 2 }), '10 10');
27
+ node_assert_1.default.strictEqual((0, binary_1.formatToBinary)(5, { group: 4 }), '101'); // no padding on the left
28
+ node_assert_1.default.strictEqual((0, binary_1.formatToBinary)(1023, { group: 4 }), '11 1111 1111');
29
+ });
30
+ (0, node_test_1.it)('applies grouping with negative numbers', () => {
31
+ node_assert_1.default.strictEqual((0, binary_1.formatToBinary)(-255, { group: 4 }), '-1111 1111');
32
+ });
33
+ (0, node_test_1.it)('handles large integers (MAX_SAFE_INTEGER)', () => {
34
+ const expected = Number.MAX_SAFE_INTEGER.toString(2);
35
+ node_assert_1.default.strictEqual((0, binary_1.formatToBinary)(Number.MAX_SAFE_INTEGER), expected);
36
+ });
37
+ (0, node_test_1.it)('throws TypeError for invalid inputs (type/NaN)', () => {
38
+ node_assert_1.default.throws(() => (0, binary_1.formatToBinary)('5'), /Input must be a number/);
39
+ node_assert_1.default.throws(() => (0, binary_1.formatToBinary)(null), /Input must be a number/);
40
+ node_assert_1.default.throws(() => (0, binary_1.formatToBinary)(undefined), /Input must be a number/);
41
+ node_assert_1.default.throws(() => (0, binary_1.formatToBinary)(NaN), /Input must be a number/);
42
+ });
43
+ (0, node_test_1.it)('throws TypeError for non-integer numbers', () => {
44
+ node_assert_1.default.throws(() => (0, binary_1.formatToBinary)(3.14), /Input must be an integer/);
45
+ node_assert_1.default.throws(() => (0, binary_1.formatToBinary)(-2.5), /Input must be an integer/);
46
+ });
47
+ (0, node_test_1.it)('throws TypeError for invalid group size', () => {
48
+ node_assert_1.default.throws(() => (0, binary_1.formatToBinary)(10, { group: 0 }), /Group size must be a positive integer/);
49
+ node_assert_1.default.throws(() => (0, binary_1.formatToBinary)(10, { group: -1 }), /Group size must be a positive integer/);
50
+ node_assert_1.default.throws(() => (0, binary_1.formatToBinary)(10, { group: 2.5 }), /Group size must be a positive integer/);
51
+ node_assert_1.default.throws(() => (0, binary_1.formatToBinary)(10, { group: '4' }), /Group size must be a positive integer/);
52
+ });
53
+ });
@@ -0,0 +1 @@
1
+ export {};