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.
- package/.prettierignore +4 -0
- package/.prettierrc +7 -0
- package/CONTRIBUTING.md +41 -29
- package/README.md +811 -163
- package/dist/analyzing/characterCount.d.ts +19 -0
- package/dist/analyzing/characterCount.js +21 -2
- package/dist/analyzing/characterFrequency.d.ts +19 -0
- package/dist/analyzing/characterFrequency.js +22 -3
- package/dist/analyzing/checkMultiplePatterns.d.ts +14 -0
- package/dist/analyzing/checkMultiplePatterns.js +63 -0
- package/dist/analyzing/checkSubsequence.d.ts +14 -0
- package/dist/analyzing/checkSubsequence.js +33 -0
- package/dist/analyzing/complexity.d.ts +33 -0
- package/dist/analyzing/complexity.js +35 -2
- package/dist/analyzing/contentWordCount.d.ts +11 -0
- package/dist/analyzing/contentWordCount.js +23 -0
- package/dist/analyzing/functionWordCount.d.ts +11 -0
- package/dist/analyzing/functionWordCount.js +33 -0
- package/dist/analyzing/index.d.ts +29 -12
- package/dist/analyzing/index.js +26 -2
- package/dist/analyzing/patternCount.d.ts +11 -0
- package/dist/analyzing/patternCount.js +54 -0
- package/dist/analyzing/stringRotation.d.ts +29 -0
- package/dist/analyzing/stringRotation.js +44 -0
- package/dist/analyzing/stringSimilarity.js +1 -1
- package/dist/analyzing/vowelConsonantCount.d.ts +22 -0
- package/dist/analyzing/vowelConsonantCount.js +38 -0
- package/dist/analyzing/wordCount.d.ts +22 -0
- package/dist/analyzing/wordCount.js +24 -2
- package/dist/formatting/capitalize.d.ts +21 -0
- package/dist/formatting/capitalize.js +22 -1
- package/dist/formatting/index.d.ts +6 -6
- package/dist/formatting/number.d.ts +23 -0
- package/dist/formatting/number.js +24 -1
- package/dist/formatting/phone.d.ts +23 -0
- package/dist/formatting/phone.js +23 -0
- package/dist/index.d.ts +22 -4
- package/dist/tests/analyzing/checkMultiplePatterns.test.d.ts +1 -0
- package/dist/tests/analyzing/checkMultiplePatterns.test.js +81 -0
- package/dist/tests/analyzing/checkSubsequence.test.d.ts +1 -0
- package/dist/tests/analyzing/checkSubsequence.test.js +34 -0
- package/dist/tests/analyzing/contentWordCount.test.d.ts +1 -0
- package/dist/tests/analyzing/contentWordCount.test.js +20 -0
- package/dist/tests/analyzing/functionWordCount.test.d.ts +1 -0
- package/dist/tests/analyzing/functionWordCount.test.js +20 -0
- package/dist/tests/analyzing/patternCount.test.d.ts +1 -0
- package/dist/tests/analyzing/patternCount.test.js +34 -0
- package/dist/tests/analyzing/readingDuration.test.js +12 -12
- package/dist/tests/analyzing/stringRotation.test.d.ts +1 -0
- package/dist/tests/analyzing/stringRotation.test.js +42 -0
- package/dist/tests/analyzing/vowelConsonantCount.test.d.ts +1 -0
- package/dist/tests/analyzing/vowelConsonantCount.test.js +25 -0
- package/dist/tests/transformations/numberToText.test.d.ts +1 -0
- package/dist/tests/transformations/numberToText.test.js +60 -0
- package/dist/tests/transformations/reverseString.test.d.ts +1 -0
- package/dist/tests/transformations/reverseString.test.js +41 -0
- package/dist/tests/transformations/splitChunks.test.d.ts +1 -0
- package/dist/tests/transformations/splitChunks.test.js +31 -0
- package/dist/tests/transformations/stringCombinations.test.d.ts +1 -0
- package/dist/tests/transformations/stringCombinations.test.js +41 -0
- package/dist/tests/transformations/stringPermutations.test.d.ts +1 -0
- package/dist/tests/transformations/stringPermutations.test.js +40 -0
- package/dist/tests/validations/isAlphaNumeric.test.d.ts +1 -0
- package/dist/tests/validations/isAlphaNumeric.test.js +30 -0
- package/dist/tests/validations/isAlphabetic.test.d.ts +1 -0
- package/dist/tests/validations/isAlphabetic.test.js +32 -0
- package/dist/tests/validations/isAnagram.test.d.ts +1 -0
- package/dist/tests/validations/isAnagram.test.js +44 -0
- package/dist/tests/validations/isCoordinates.test.d.ts +1 -0
- package/dist/tests/validations/isCoordinates.test.js +18 -0
- package/dist/tests/validations/isEmail.smtpUTF8.test.d.ts +1 -0
- package/dist/tests/validations/isEmail.smtpUTF8.test.js +16 -0
- package/dist/tests/validations/isEmail.test.js +56 -6
- package/dist/tests/validations/isHexColor.test.js +21 -21
- package/dist/tests/validations/isLowerCase.test.d.ts +1 -0
- package/dist/tests/validations/isLowerCase.test.js +50 -0
- package/dist/tests/validations/isMacAddress.test.d.ts +1 -0
- package/dist/tests/validations/isMacAddress.test.js +72 -0
- package/dist/tests/validations/isPalindrome.test.d.ts +1 -0
- package/dist/tests/validations/isPalindrome.test.js +39 -0
- package/dist/tests/validations/isPanagram.test.d.ts +1 -0
- package/dist/tests/validations/isPanagram.test.js +39 -0
- package/dist/tests/validations/isTypeOf.test.d.ts +1 -0
- package/dist/tests/validations/isTypeOf.test.js +28 -0
- package/dist/tests/validations/isUpperCase.test.d.ts +1 -0
- package/dist/tests/validations/isUpperCase.test.js +50 -0
- package/dist/transformations/camelCase.d.ts +24 -0
- package/dist/transformations/camelCase.js +24 -0
- package/dist/transformations/capitalizeWords.d.ts +21 -0
- package/dist/transformations/capitalizeWords.js +23 -2
- package/dist/transformations/constantCase.d.ts +26 -0
- package/dist/transformations/constantCase.js +26 -0
- package/dist/transformations/escapeHTML.d.ts +23 -0
- package/dist/transformations/escapeHTML.js +24 -2
- package/dist/transformations/index.d.ts +12 -0
- package/dist/transformations/index.js +18 -2
- package/dist/transformations/initials.d.ts +27 -0
- package/dist/transformations/initials.js +38 -8
- package/dist/transformations/kebabCase.d.ts +26 -0
- package/dist/transformations/kebabCase.js +26 -0
- package/dist/transformations/maskSegment.js +4 -6
- package/dist/transformations/numberToText/helpers.d.ts +10 -0
- package/dist/transformations/numberToText/helpers.js +31 -0
- package/dist/transformations/numberToText/implementation_EN.d.ts +10 -0
- package/dist/transformations/numberToText/implementation_EN.js +45 -0
- package/dist/transformations/numberToText/implementation_PL.d.ts +10 -0
- package/dist/transformations/numberToText/implementation_PL.js +79 -0
- package/dist/transformations/numberToText/main.d.ts +19 -0
- package/dist/transformations/numberToText/main.js +67 -0
- package/dist/transformations/numberToText/types.d.ts +3 -0
- package/dist/transformations/numberToText/types.js +82 -0
- package/dist/transformations/pascalCase.d.ts +25 -0
- package/dist/transformations/pascalCase.js +25 -0
- package/dist/transformations/removeDuplicates.d.ts +21 -0
- package/dist/transformations/removeDuplicates.js +25 -4
- package/dist/transformations/removeSpecialChars.d.ts +22 -0
- package/dist/transformations/removeSpecialChars.js +26 -4
- package/dist/transformations/removeWords.d.ts +27 -0
- package/dist/transformations/removeWords.js +31 -4
- package/dist/transformations/reverseWordsInString .d.ts +9 -0
- package/dist/transformations/reverseWordsInString .js +49 -0
- package/dist/transformations/snakeCase.d.ts +26 -0
- package/dist/transformations/snakeCase.js +26 -0
- package/dist/transformations/splitChunks.d.ts +8 -0
- package/dist/transformations/splitChunks.js +24 -0
- package/dist/transformations/stringCombinations.d.ts +28 -0
- package/dist/transformations/stringCombinations.js +44 -0
- package/dist/transformations/stringPermutations.d.ts +31 -0
- package/dist/transformations/stringPermutations.js +53 -0
- package/dist/transformations/titleCase.d.ts +25 -0
- package/dist/transformations/titleCase.js +25 -0
- package/dist/transformations/toSlug.d.ts +24 -0
- package/dist/transformations/toSlug.js +28 -4
- package/dist/transformations/truncateText.d.ts +25 -0
- package/dist/transformations/truncateText.js +28 -3
- package/dist/validations/index.d.ts +27 -0
- package/dist/validations/index.js +38 -2
- package/dist/validations/isAlphaNumeric.d.ts +11 -0
- package/dist/validations/isAlphaNumeric.js +22 -0
- package/dist/validations/isAlphabetic.d.ts +9 -0
- package/dist/validations/isAlphabetic.js +21 -0
- package/dist/validations/isAnagram.d.ts +13 -0
- package/dist/validations/isAnagram.js +23 -0
- package/dist/validations/isCoordinates.d.ts +8 -0
- package/dist/validations/isCoordinates.js +19 -0
- package/dist/validations/isDate.d.ts +1 -1
- package/dist/validations/isDate.js +6 -8
- package/dist/validations/isEmail.d.ts +13 -1
- package/dist/validations/isEmail.js +176 -3
- package/dist/validations/isEmpty.d.ts +9 -0
- package/dist/validations/isEmpty.js +9 -0
- package/dist/validations/isHexColor.js +1 -1
- package/dist/validations/isIPv4.d.ts +21 -0
- package/dist/validations/isIPv4.js +22 -2
- package/dist/validations/isLowerCase.d.ts +12 -0
- package/dist/validations/isLowerCase.js +32 -0
- package/dist/validations/isMacAddress.d.ts +27 -0
- package/dist/validations/isMacAddress.js +43 -0
- package/dist/validations/isPalindrome.d.ts +10 -0
- package/dist/validations/isPalindrome.js +21 -0
- package/dist/validations/isPanagram.d.ts +20 -0
- package/dist/validations/isPanagram.js +35 -0
- package/dist/validations/isSlug.d.ts +27 -0
- package/dist/validations/isSlug.js +27 -0
- package/dist/validations/isTypeOf.d.ts +9 -0
- package/dist/validations/isTypeOf.js +30 -0
- package/dist/validations/isURL.d.ts +21 -0
- package/dist/validations/isURL.js +21 -0
- package/dist/validations/isUpperCase.d.ts +12 -0
- package/dist/validations/isUpperCase.js +32 -0
- package/package.json +6 -4
|
@@ -1 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the number of characters in a given string.
|
|
3
|
+
*
|
|
4
|
+
* This function counts all characters in the string, including whitespace,
|
|
5
|
+
* punctuation, and special characters. It throws a `TypeError` if the input is not a string.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} str - The string whose characters will be counted.
|
|
8
|
+
* @returns {number} The number of characters in the input string.
|
|
9
|
+
* @throws {TypeError} If the input is not of type string.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* characterCount("Hello, world!"); // 13
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* characterCount(" "); // 2
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* characterCount(""); // 0
|
|
19
|
+
*/
|
|
1
20
|
export declare function characterCount(str: string): number;
|
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.characterCount = characterCount;
|
|
4
|
+
/**
|
|
5
|
+
* Returns the number of characters in a given string.
|
|
6
|
+
*
|
|
7
|
+
* This function counts all characters in the string, including whitespace,
|
|
8
|
+
* punctuation, and special characters. It throws a `TypeError` if the input is not a string.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} str - The string whose characters will be counted.
|
|
11
|
+
* @returns {number} The number of characters in the input string.
|
|
12
|
+
* @throws {TypeError} If the input is not of type string.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* characterCount("Hello, world!"); // 13
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* characterCount(" "); // 2
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* characterCount(""); // 0
|
|
22
|
+
*/
|
|
4
23
|
function characterCount(str) {
|
|
5
|
-
if (typeof str !==
|
|
6
|
-
throw new TypeError(
|
|
24
|
+
if (typeof str !== 'string') {
|
|
25
|
+
throw new TypeError('Input must be a string');
|
|
7
26
|
}
|
|
8
27
|
return str.length;
|
|
9
28
|
}
|
|
@@ -1 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the frequency of each non-space character in a string.
|
|
3
|
+
*
|
|
4
|
+
* This function returns an object mapping each lowercase character (excluding spaces)
|
|
5
|
+
* to the number of times it appears in the input string. The input is case-insensitive,
|
|
6
|
+
* meaning 'A' and 'a' are treated the same. It throws a `TypeError` if the input is not a string.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} str - The string to analyze.
|
|
9
|
+
* @returns {Record<string, number>} An object where keys are characters and values are their counts.
|
|
10
|
+
* @throws {TypeError} If the input is not a string.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* characterFrequency("Hello World");
|
|
14
|
+
* // Returns: { h: 1, e: 1, l: 3, o: 2, w: 1, r: 1, d: 1 }
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* characterFrequency("AaBb");
|
|
18
|
+
* // Returns: { a: 2, b: 2 }
|
|
19
|
+
*/
|
|
1
20
|
export declare function characterFrequency(str: string): Record<string, number>;
|
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.characterFrequency = characterFrequency;
|
|
4
|
+
/**
|
|
5
|
+
* Calculates the frequency of each non-space character in a string.
|
|
6
|
+
*
|
|
7
|
+
* This function returns an object mapping each lowercase character (excluding spaces)
|
|
8
|
+
* to the number of times it appears in the input string. The input is case-insensitive,
|
|
9
|
+
* meaning 'A' and 'a' are treated the same. It throws a `TypeError` if the input is not a string.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} str - The string to analyze.
|
|
12
|
+
* @returns {Record<string, number>} An object where keys are characters and values are their counts.
|
|
13
|
+
* @throws {TypeError} If the input is not a string.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* characterFrequency("Hello World");
|
|
17
|
+
* // Returns: { h: 1, e: 1, l: 3, o: 2, w: 1, r: 1, d: 1 }
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* characterFrequency("AaBb");
|
|
21
|
+
* // Returns: { a: 2, b: 2 }
|
|
22
|
+
*/
|
|
4
23
|
function characterFrequency(str) {
|
|
5
|
-
if (typeof str !==
|
|
6
|
-
throw new TypeError(
|
|
24
|
+
if (typeof str !== 'string') {
|
|
25
|
+
throw new TypeError('Input must be a string');
|
|
7
26
|
}
|
|
8
27
|
const frequency = {};
|
|
9
28
|
for (const char of str.toLowerCase()) {
|
|
10
|
-
if (char !==
|
|
29
|
+
if (char !== ' ') {
|
|
11
30
|
// Exclude spaces for cleaner analysis
|
|
12
31
|
frequency[char] = (frequency[char] || 0) + 1;
|
|
13
32
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds occurrences of multiple patterns within a given text using Rabin–Karp algorithm.
|
|
3
|
+
*
|
|
4
|
+
* - Accepts an array of patterns.
|
|
5
|
+
* - Returns all matches of each pattern along with starting indices.
|
|
6
|
+
* - Handles hash collisions by verifying actual substrings.
|
|
7
|
+
* - Is case sensitive
|
|
8
|
+
*
|
|
9
|
+
* @param {string} text - The text to search within.
|
|
10
|
+
* @param {string[]} patterns - The array of patterns to search for.
|
|
11
|
+
* @returns {Record<string, number[]>} An object mapping each pattern to an array of match indices.
|
|
12
|
+
* @throws {TypeError} If input types are invalid.
|
|
13
|
+
*/
|
|
14
|
+
export declare function checkMultiplePatterns(text: string, patterns: string[]): Record<string, number[]>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Finds occurrences of multiple patterns within a given text using Rabin–Karp algorithm.
|
|
4
|
+
*
|
|
5
|
+
* - Accepts an array of patterns.
|
|
6
|
+
* - Returns all matches of each pattern along with starting indices.
|
|
7
|
+
* - Handles hash collisions by verifying actual substrings.
|
|
8
|
+
* - Is case sensitive
|
|
9
|
+
*
|
|
10
|
+
* @param {string} text - The text to search within.
|
|
11
|
+
* @param {string[]} patterns - The array of patterns to search for.
|
|
12
|
+
* @returns {Record<string, number[]>} An object mapping each pattern to an array of match indices.
|
|
13
|
+
* @throws {TypeError} If input types are invalid.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.checkMultiplePatterns = checkMultiplePatterns;
|
|
17
|
+
function checkMultiplePatterns(text, patterns) {
|
|
18
|
+
if (typeof text !== 'string') {
|
|
19
|
+
throw new TypeError('Text must be a string');
|
|
20
|
+
}
|
|
21
|
+
if (!Array.isArray(patterns) || !patterns.every(p => typeof p === 'string')) {
|
|
22
|
+
throw new TypeError('Patterns must be an array of strings');
|
|
23
|
+
}
|
|
24
|
+
const result = {};
|
|
25
|
+
if (text.length === 0 || patterns.length === 0) {
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
const prime = 101; // A prime base for hashing
|
|
29
|
+
const getHash = (str, m) => {
|
|
30
|
+
let h = 0;
|
|
31
|
+
for (let i = 0; i < m; i++) {
|
|
32
|
+
h = (h * 256 + str.charCodeAt(i)) % prime;
|
|
33
|
+
}
|
|
34
|
+
return h;
|
|
35
|
+
};
|
|
36
|
+
const recomputeHash = (oldHash, dropped, added, m) => {
|
|
37
|
+
let h = (oldHash - dropped.charCodeAt(0) * Math.pow(256, m - 1)) % prime;
|
|
38
|
+
h = (h * 256 + added.charCodeAt(0)) % prime;
|
|
39
|
+
if (h < 0)
|
|
40
|
+
h += prime;
|
|
41
|
+
return h;
|
|
42
|
+
};
|
|
43
|
+
for (const pattern of patterns) {
|
|
44
|
+
const m = pattern.length;
|
|
45
|
+
result[pattern] = [];
|
|
46
|
+
if (m === 0 || m > text.length)
|
|
47
|
+
continue;
|
|
48
|
+
const patternHash = getHash(pattern, m);
|
|
49
|
+
let windowHash = getHash(text, m);
|
|
50
|
+
for (let i = 0; i <= text.length - m; i++) {
|
|
51
|
+
if (patternHash === windowHash) {
|
|
52
|
+
// Verify to avoid collision false positives
|
|
53
|
+
if (text.slice(i, i + m) === pattern) {
|
|
54
|
+
result[pattern].push(i);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (i < text.length - m) {
|
|
58
|
+
windowHash = recomputeHash(windowHash, text[i], text[i + m], m);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether the second string is a subsequence of the first string.
|
|
3
|
+
*
|
|
4
|
+
* A subsequence means all characters of the second string appear in the first string
|
|
5
|
+
* in the same relative order, but not necessarily consecutively.
|
|
6
|
+
*
|
|
7
|
+
* Is case sensitive
|
|
8
|
+
*
|
|
9
|
+
* @param {string} str1 - The string to check against.
|
|
10
|
+
* @param {string} str2 - The candidate subsequence.
|
|
11
|
+
* @returns {boolean} True if str2 is a subsequence of str1, otherwise false.
|
|
12
|
+
* @throws {TypeError} If either input is not a string.
|
|
13
|
+
*/
|
|
14
|
+
export declare function checkSubsequence(str1: string, str2: string): boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkSubsequence = checkSubsequence;
|
|
4
|
+
/**
|
|
5
|
+
* Checks whether the second string is a subsequence of the first string.
|
|
6
|
+
*
|
|
7
|
+
* A subsequence means all characters of the second string appear in the first string
|
|
8
|
+
* in the same relative order, but not necessarily consecutively.
|
|
9
|
+
*
|
|
10
|
+
* Is case sensitive
|
|
11
|
+
*
|
|
12
|
+
* @param {string} str1 - The string to check against.
|
|
13
|
+
* @param {string} str2 - The candidate subsequence.
|
|
14
|
+
* @returns {boolean} True if str2 is a subsequence of str1, otherwise false.
|
|
15
|
+
* @throws {TypeError} If either input is not a string.
|
|
16
|
+
*/
|
|
17
|
+
function checkSubsequence(str1, str2) {
|
|
18
|
+
if (typeof str1 !== "string" || typeof str2 !== "string") {
|
|
19
|
+
throw new TypeError("Both inputs must be strings");
|
|
20
|
+
}
|
|
21
|
+
// empty subsequence is always valid
|
|
22
|
+
if (str2 === "")
|
|
23
|
+
return true;
|
|
24
|
+
let i = 0; // pointer for str2 (the subsequence)
|
|
25
|
+
let j = 0; // pointer for str1 (the main string)
|
|
26
|
+
while (i < str2.length && j < str1.length) {
|
|
27
|
+
if (str2[i] === str1[j]) {
|
|
28
|
+
i++;
|
|
29
|
+
}
|
|
30
|
+
j++;
|
|
31
|
+
}
|
|
32
|
+
return i === str2.length;
|
|
33
|
+
}
|
|
@@ -3,4 +3,37 @@ export type ComplexityResult = {
|
|
|
3
3
|
uniqueness: number;
|
|
4
4
|
length: number;
|
|
5
5
|
};
|
|
6
|
+
/**
|
|
7
|
+
* Evaluates the complexity of a given string based on length, character uniqueness,
|
|
8
|
+
* and character type diversity (lowercase, uppercase, numbers, symbols).
|
|
9
|
+
*
|
|
10
|
+
* The returned score ranges from 0 to 1, where a higher score indicates greater complexity.
|
|
11
|
+
* It also returns the raw length of the string and its uniqueness ratio (unique chars / total length).
|
|
12
|
+
*
|
|
13
|
+
* - `uniqueness`: Measures how varied the characters are.
|
|
14
|
+
* - `score`: Combines uniqueness, type diversity, and length into a weighted value.
|
|
15
|
+
* - `length`: The total number of characters in the input.
|
|
16
|
+
*
|
|
17
|
+
* Throws a `TypeError` if the input is not a string.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} str - The input string to evaluate.
|
|
20
|
+
* @returns {ComplexityResult} An object containing `score`, `uniqueness`, and `length`.
|
|
21
|
+
* @throws {TypeError} If the input is not a string.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* complexity("abcABC123!");
|
|
25
|
+
* // {
|
|
26
|
+
* // score: 0.93,
|
|
27
|
+
* // uniqueness: 1.00,
|
|
28
|
+
* // length: 10
|
|
29
|
+
* // }
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* complexity("aaaa");
|
|
33
|
+
* // {
|
|
34
|
+
* // score: 0.25,
|
|
35
|
+
* // uniqueness: 0.25,
|
|
36
|
+
* // length: 4
|
|
37
|
+
* // }
|
|
38
|
+
*/
|
|
6
39
|
export declare function complexity(str: string): ComplexityResult;
|
|
@@ -1,11 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.complexity = complexity;
|
|
4
|
+
/**
|
|
5
|
+
* Evaluates the complexity of a given string based on length, character uniqueness,
|
|
6
|
+
* and character type diversity (lowercase, uppercase, numbers, symbols).
|
|
7
|
+
*
|
|
8
|
+
* The returned score ranges from 0 to 1, where a higher score indicates greater complexity.
|
|
9
|
+
* It also returns the raw length of the string and its uniqueness ratio (unique chars / total length).
|
|
10
|
+
*
|
|
11
|
+
* - `uniqueness`: Measures how varied the characters are.
|
|
12
|
+
* - `score`: Combines uniqueness, type diversity, and length into a weighted value.
|
|
13
|
+
* - `length`: The total number of characters in the input.
|
|
14
|
+
*
|
|
15
|
+
* Throws a `TypeError` if the input is not a string.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} str - The input string to evaluate.
|
|
18
|
+
* @returns {ComplexityResult} An object containing `score`, `uniqueness`, and `length`.
|
|
19
|
+
* @throws {TypeError} If the input is not a string.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* complexity("abcABC123!");
|
|
23
|
+
* // {
|
|
24
|
+
* // score: 0.93,
|
|
25
|
+
* // uniqueness: 1.00,
|
|
26
|
+
* // length: 10
|
|
27
|
+
* // }
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* complexity("aaaa");
|
|
31
|
+
* // {
|
|
32
|
+
* // score: 0.25,
|
|
33
|
+
* // uniqueness: 0.25,
|
|
34
|
+
* // length: 4
|
|
35
|
+
* // }
|
|
36
|
+
*/
|
|
4
37
|
function complexity(str) {
|
|
5
38
|
if (!str)
|
|
6
39
|
return { score: 0, uniqueness: 0, length: 0 };
|
|
7
|
-
if (typeof str !==
|
|
8
|
-
throw new TypeError(
|
|
40
|
+
if (typeof str !== 'string') {
|
|
41
|
+
throw new TypeError('Input must be a string');
|
|
9
42
|
}
|
|
10
43
|
const length = str.length;
|
|
11
44
|
const unique = new Set(str).size;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Counts the number of content words in a given text.
|
|
3
|
+
*
|
|
4
|
+
* Content words are words that carry lexical meaning (nouns, verbs, adjectives, adverbs),
|
|
5
|
+
* excluding function words such as prepositions, pronouns, and articles.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} text - The text to analyze.
|
|
8
|
+
* @returns {number} The count of content words in the text.
|
|
9
|
+
* @throws {TypeError} If the input is not a string.
|
|
10
|
+
*/
|
|
11
|
+
export declare function contentWordCount(text: string): number;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.contentWordCount = contentWordCount;
|
|
4
|
+
const functionWordCount_1 = require("./functionWordCount");
|
|
5
|
+
const wordCount_1 = require("./wordCount");
|
|
6
|
+
/**
|
|
7
|
+
* Counts the number of content words in a given text.
|
|
8
|
+
*
|
|
9
|
+
* Content words are words that carry lexical meaning (nouns, verbs, adjectives, adverbs),
|
|
10
|
+
* excluding function words such as prepositions, pronouns, and articles.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} text - The text to analyze.
|
|
13
|
+
* @returns {number} The count of content words in the text.
|
|
14
|
+
* @throws {TypeError} If the input is not a string.
|
|
15
|
+
*/
|
|
16
|
+
function contentWordCount(text) {
|
|
17
|
+
if (typeof text !== 'string') {
|
|
18
|
+
throw new TypeError('Input must be a string');
|
|
19
|
+
}
|
|
20
|
+
const totalWords = (0, wordCount_1.wordCount)(text);
|
|
21
|
+
const functionWords = (0, functionWordCount_1.functionWordCount)(text);
|
|
22
|
+
return totalWords - functionWords;
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Counts the number of function words in a given text.
|
|
3
|
+
*
|
|
4
|
+
* Function words are common words (e.g., prepositions, pronouns, conjunctions, articles, etc.)
|
|
5
|
+
* that carry grammatical meaning rather than lexical meaning.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} text - The text to analyze.
|
|
8
|
+
* @returns {number} The count of function words in the text.
|
|
9
|
+
* @throws {TypeError} If the input is not a string.
|
|
10
|
+
*/
|
|
11
|
+
export declare function functionWordCount(text: string): number;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.functionWordCount = functionWordCount;
|
|
4
|
+
/**
|
|
5
|
+
* Counts the number of function words in a given text.
|
|
6
|
+
*
|
|
7
|
+
* Function words are common words (e.g., prepositions, pronouns, conjunctions, articles, etc.)
|
|
8
|
+
* that carry grammatical meaning rather than lexical meaning.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} text - The text to analyze.
|
|
11
|
+
* @returns {number} The count of function words in the text.
|
|
12
|
+
* @throws {TypeError} If the input is not a string.
|
|
13
|
+
*/
|
|
14
|
+
function functionWordCount(text) {
|
|
15
|
+
if (typeof text !== 'string') {
|
|
16
|
+
throw new TypeError('Input must be a string');
|
|
17
|
+
}
|
|
18
|
+
const functionWords = new Set([
|
|
19
|
+
'a', 'an', 'the', 'and', 'but', 'or', 'nor', 'so', 'yet',
|
|
20
|
+
'for', 'of', 'in', 'on', 'at', 'by', 'to', 'from', 'with', 'about',
|
|
21
|
+
'as', 'into', 'like', 'through', 'after', 'over', 'between', 'out',
|
|
22
|
+
'against', 'during', 'without', 'before', 'under', 'around', 'among',
|
|
23
|
+
'is', 'am', 'are', 'was', 'were', 'be', 'been', 'being',
|
|
24
|
+
'he', 'she', 'it', 'they', 'we', 'you', 'i', 'me', 'him', 'her',
|
|
25
|
+
'them', 'us', 'my', 'your', 'his', 'their', 'our',
|
|
26
|
+
'this', 'that', 'these', 'those',
|
|
27
|
+
'who', 'whom', 'which', 'what', 'when', 'where', 'why', 'how'
|
|
28
|
+
]);
|
|
29
|
+
// ✅ Normalize text: lowercase + remove punctuation
|
|
30
|
+
const cleanedText = text.toLowerCase().replace(/[^\w\s]/g, '');
|
|
31
|
+
const words = cleanedText.trim().split(/\s+/);
|
|
32
|
+
return words.filter(word => functionWords.has(word)).length;
|
|
33
|
+
}
|
|
@@ -1,15 +1,27 @@
|
|
|
1
|
-
export { characterCount } from
|
|
2
|
-
export { characterFrequency } from
|
|
3
|
-
export { complexity } from
|
|
4
|
-
export { readingDuration } from
|
|
5
|
-
export { wordCount } from
|
|
6
|
-
export { stringSimilarity } from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
export { characterCount } from './characterCount';
|
|
2
|
+
export { characterFrequency } from './characterFrequency';
|
|
3
|
+
export { complexity } from './complexity';
|
|
4
|
+
export { readingDuration } from './readingDuration';
|
|
5
|
+
export { wordCount } from './wordCount';
|
|
6
|
+
export { stringSimilarity } from './stringSimilarity';
|
|
7
|
+
export { patternCount } from './patternCount';
|
|
8
|
+
export { vowelConsonantCount } from './vowelConsonantCount';
|
|
9
|
+
export { checkMultiplePatterns } from './checkMultiplePatterns';
|
|
10
|
+
export { checkSubsequence } from './checkSubsequence';
|
|
11
|
+
export { functionWordCount } from './functionWordCount';
|
|
12
|
+
export { contentWordCount } from './contentWordCount';
|
|
13
|
+
export { checkStringRotations } from './stringRotation';
|
|
14
|
+
import { characterCount } from './characterCount';
|
|
15
|
+
import { characterFrequency } from './characterFrequency';
|
|
16
|
+
import { complexity } from './complexity';
|
|
17
|
+
import { readingDuration } from './readingDuration';
|
|
18
|
+
import { wordCount } from './wordCount';
|
|
19
|
+
import { stringSimilarity } from './stringSimilarity';
|
|
20
|
+
import { patternCount } from './patternCount';
|
|
21
|
+
import { vowelConsonantCount } from './vowelConsonantCount';
|
|
22
|
+
import { checkMultiplePatterns } from './checkMultiplePatterns';
|
|
23
|
+
import { checkSubsequence } from './checkSubsequence';
|
|
24
|
+
import { checkStringRotations } from './stringRotation';
|
|
13
25
|
export declare const analyzing: {
|
|
14
26
|
characterCount: typeof characterCount;
|
|
15
27
|
characterFrequency: typeof characterFrequency;
|
|
@@ -17,4 +29,9 @@ export declare const analyzing: {
|
|
|
17
29
|
readingDuration: typeof readingDuration;
|
|
18
30
|
wordCount: typeof wordCount;
|
|
19
31
|
stringSimilarity: typeof stringSimilarity;
|
|
32
|
+
patternCount: typeof patternCount;
|
|
33
|
+
vowelConsonantCount: typeof vowelConsonantCount;
|
|
34
|
+
checkMultiplePatterns: typeof checkMultiplePatterns;
|
|
35
|
+
checkSubsequence: typeof checkSubsequence;
|
|
36
|
+
checkStringRotations: typeof checkStringRotations;
|
|
20
37
|
};
|
package/dist/analyzing/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.analyzing = exports.stringSimilarity = exports.wordCount = exports.readingDuration = exports.complexity = exports.characterFrequency = exports.characterCount = void 0;
|
|
3
|
+
exports.analyzing = exports.checkStringRotations = exports.contentWordCount = exports.functionWordCount = exports.checkSubsequence = exports.checkMultiplePatterns = exports.vowelConsonantCount = exports.patternCount = exports.stringSimilarity = exports.wordCount = exports.readingDuration = exports.complexity = exports.characterFrequency = exports.characterCount = void 0;
|
|
4
4
|
var characterCount_1 = require("./characterCount");
|
|
5
5
|
Object.defineProperty(exports, "characterCount", { enumerable: true, get: function () { return characterCount_1.characterCount; } });
|
|
6
6
|
var characterFrequency_1 = require("./characterFrequency");
|
|
@@ -13,17 +13,41 @@ var wordCount_1 = require("./wordCount");
|
|
|
13
13
|
Object.defineProperty(exports, "wordCount", { enumerable: true, get: function () { return wordCount_1.wordCount; } });
|
|
14
14
|
var stringSimilarity_1 = require("./stringSimilarity");
|
|
15
15
|
Object.defineProperty(exports, "stringSimilarity", { enumerable: true, get: function () { return stringSimilarity_1.stringSimilarity; } });
|
|
16
|
+
var patternCount_1 = require("./patternCount");
|
|
17
|
+
Object.defineProperty(exports, "patternCount", { enumerable: true, get: function () { return patternCount_1.patternCount; } });
|
|
18
|
+
var vowelConsonantCount_1 = require("./vowelConsonantCount");
|
|
19
|
+
Object.defineProperty(exports, "vowelConsonantCount", { enumerable: true, get: function () { return vowelConsonantCount_1.vowelConsonantCount; } });
|
|
20
|
+
var checkMultiplePatterns_1 = require("./checkMultiplePatterns");
|
|
21
|
+
Object.defineProperty(exports, "checkMultiplePatterns", { enumerable: true, get: function () { return checkMultiplePatterns_1.checkMultiplePatterns; } });
|
|
22
|
+
var checkSubsequence_1 = require("./checkSubsequence");
|
|
23
|
+
Object.defineProperty(exports, "checkSubsequence", { enumerable: true, get: function () { return checkSubsequence_1.checkSubsequence; } });
|
|
24
|
+
var functionWordCount_1 = require("./functionWordCount");
|
|
25
|
+
Object.defineProperty(exports, "functionWordCount", { enumerable: true, get: function () { return functionWordCount_1.functionWordCount; } });
|
|
26
|
+
var contentWordCount_1 = require("./contentWordCount");
|
|
27
|
+
Object.defineProperty(exports, "contentWordCount", { enumerable: true, get: function () { return contentWordCount_1.contentWordCount; } });
|
|
28
|
+
var stringRotation_1 = require("./stringRotation");
|
|
29
|
+
Object.defineProperty(exports, "checkStringRotations", { enumerable: true, get: function () { return stringRotation_1.checkStringRotations; } });
|
|
16
30
|
const characterCount_2 = require("./characterCount");
|
|
17
31
|
const characterFrequency_2 = require("./characterFrequency");
|
|
18
32
|
const complexity_2 = require("./complexity");
|
|
19
33
|
const readingDuration_2 = require("./readingDuration");
|
|
20
34
|
const wordCount_2 = require("./wordCount");
|
|
21
35
|
const stringSimilarity_2 = require("./stringSimilarity");
|
|
36
|
+
const patternCount_2 = require("./patternCount");
|
|
37
|
+
const vowelConsonantCount_2 = require("./vowelConsonantCount");
|
|
38
|
+
const checkMultiplePatterns_2 = require("./checkMultiplePatterns");
|
|
39
|
+
const checkSubsequence_2 = require("./checkSubsequence");
|
|
40
|
+
const stringRotation_2 = require("./stringRotation");
|
|
22
41
|
exports.analyzing = {
|
|
23
42
|
characterCount: characterCount_2.characterCount,
|
|
24
43
|
characterFrequency: characterFrequency_2.characterFrequency,
|
|
25
44
|
complexity: complexity_2.complexity,
|
|
26
45
|
readingDuration: readingDuration_2.readingDuration,
|
|
27
46
|
wordCount: wordCount_2.wordCount,
|
|
28
|
-
stringSimilarity: stringSimilarity_2.stringSimilarity
|
|
47
|
+
stringSimilarity: stringSimilarity_2.stringSimilarity,
|
|
48
|
+
patternCount: patternCount_2.patternCount,
|
|
49
|
+
vowelConsonantCount: vowelConsonantCount_2.vowelConsonantCount,
|
|
50
|
+
checkMultiplePatterns: checkMultiplePatterns_2.checkMultiplePatterns,
|
|
51
|
+
checkSubsequence: checkSubsequence_2.checkSubsequence,
|
|
52
|
+
checkStringRotations: stringRotation_2.checkStringRotations
|
|
29
53
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Counts the number of times a specific pattern occurs in a given text,
|
|
3
|
+
* including overlapping occurrences.
|
|
4
|
+
*
|
|
5
|
+
* Uses the Knuth-Morris-Pratt (KMP) pattern matching algorithm for efficient searching.
|
|
6
|
+
*
|
|
7
|
+
* @param text - The text to search within
|
|
8
|
+
* @param pattern - The pattern to count
|
|
9
|
+
* @returns The number of times the pattern occurs (including overlapping)
|
|
10
|
+
*/
|
|
11
|
+
export declare function patternCount(text: string, pattern: string): number;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.patternCount = patternCount;
|
|
4
|
+
/**
|
|
5
|
+
* Counts the number of times a specific pattern occurs in a given text,
|
|
6
|
+
* including overlapping occurrences.
|
|
7
|
+
*
|
|
8
|
+
* Uses the Knuth-Morris-Pratt (KMP) pattern matching algorithm for efficient searching.
|
|
9
|
+
*
|
|
10
|
+
* @param text - The text to search within
|
|
11
|
+
* @param pattern - The pattern to count
|
|
12
|
+
* @returns The number of times the pattern occurs (including overlapping)
|
|
13
|
+
*/
|
|
14
|
+
function patternCount(text, pattern) {
|
|
15
|
+
if (!pattern)
|
|
16
|
+
return 0; // Return 0 for empty pattern
|
|
17
|
+
const prefixFunction = computePrefixFunction(pattern);
|
|
18
|
+
let count = 0;
|
|
19
|
+
let j = 0; // Index for pattern
|
|
20
|
+
for (let i = 0; i < text.length; i++) {
|
|
21
|
+
while (j > 0 && text[i] !== pattern[j]) {
|
|
22
|
+
j = prefixFunction[j - 1]; // fallback in pattern
|
|
23
|
+
}
|
|
24
|
+
if (text[i] === pattern[j])
|
|
25
|
+
j++;
|
|
26
|
+
if (j === pattern.length) {
|
|
27
|
+
count++;
|
|
28
|
+
j = prefixFunction[j - 1]; // allow overlapping matches
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return count;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Computes the prefix function (partial match table) for KMP algorithm.
|
|
35
|
+
*
|
|
36
|
+
* The prefix function stores the length of the longest proper prefix
|
|
37
|
+
* which is also a suffix for each prefix of the pattern.
|
|
38
|
+
*
|
|
39
|
+
* @param pattern - Pattern string
|
|
40
|
+
* @returns Array of prefix lengths
|
|
41
|
+
*/
|
|
42
|
+
function computePrefixFunction(pattern) {
|
|
43
|
+
const prefixFunction = new Array(pattern.length).fill(0);
|
|
44
|
+
let j = 0;
|
|
45
|
+
for (let i = 1; i < pattern.length; i++) {
|
|
46
|
+
while (j > 0 && pattern[i] !== pattern[j]) {
|
|
47
|
+
j = prefixFunction[j - 1]; // fallback
|
|
48
|
+
}
|
|
49
|
+
if (pattern[i] === pattern[j])
|
|
50
|
+
j++;
|
|
51
|
+
prefixFunction[i] = j;
|
|
52
|
+
}
|
|
53
|
+
return prefixFunction;
|
|
54
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if one string is a rotation of another.
|
|
3
|
+
*
|
|
4
|
+
* A string `str2` is a rotation of `str1` if it can be obtained by shifting
|
|
5
|
+
* the characters of `str1` in a circular fashion.
|
|
6
|
+
*
|
|
7
|
+
* The check is case-sensitive and supports special characters and numbers.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} str1 - The original string.
|
|
10
|
+
* @param {string} str2 - The string to check if it is a rotation of str1.
|
|
11
|
+
* @returns {boolean} True if str2 is a rotation of str1, otherwise false.
|
|
12
|
+
* @throws {TypeError} If either input is not a string.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* checkStringRotations("abcd", "cdab"); // true
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* checkStringRotations("abc", "acb"); // false
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* checkStringRotations("hello", "ohell"); // true
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* checkStringRotations("", ""); // true
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* checkStringRotations("abc", "ab"); // false
|
|
28
|
+
*/
|
|
29
|
+
export declare function checkStringRotations(str1: string, str2: string): boolean;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkStringRotations = checkStringRotations;
|
|
4
|
+
/**
|
|
5
|
+
* Checks if one string is a rotation of another.
|
|
6
|
+
*
|
|
7
|
+
* A string `str2` is a rotation of `str1` if it can be obtained by shifting
|
|
8
|
+
* the characters of `str1` in a circular fashion.
|
|
9
|
+
*
|
|
10
|
+
* The check is case-sensitive and supports special characters and numbers.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} str1 - The original string.
|
|
13
|
+
* @param {string} str2 - The string to check if it is a rotation of str1.
|
|
14
|
+
* @returns {boolean} True if str2 is a rotation of str1, otherwise false.
|
|
15
|
+
* @throws {TypeError} If either input is not a string.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* checkStringRotations("abcd", "cdab"); // true
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* checkStringRotations("abc", "acb"); // false
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* checkStringRotations("hello", "ohell"); // true
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* checkStringRotations("", ""); // true
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* checkStringRotations("abc", "ab"); // false
|
|
31
|
+
*/
|
|
32
|
+
function checkStringRotations(str1, str2) {
|
|
33
|
+
if (typeof str1 !== 'string' || typeof str2 !== 'string') {
|
|
34
|
+
throw new TypeError('Both inputs must be strings');
|
|
35
|
+
}
|
|
36
|
+
// Edge case: both empty strings
|
|
37
|
+
if (str1 === '' && str2 === '')
|
|
38
|
+
return true;
|
|
39
|
+
// If lengths differ, they cannot be rotations
|
|
40
|
+
if (str1.length !== str2.length)
|
|
41
|
+
return false;
|
|
42
|
+
// Concatenate str1 with itself and check if str2 is a substring
|
|
43
|
+
return (str1 + str1).includes(str2);
|
|
44
|
+
}
|