stringzy 4.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/README.md +445 -34
- 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/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 +11 -0
- package/dist/analyzing/index.js +18 -2
- package/dist/analyzing/patternCount.d.ts +6 -5
- package/dist/analyzing/patternCount.js +19 -17
- package/dist/analyzing/stringRotation.d.ts +29 -0
- package/dist/analyzing/stringRotation.js +44 -0
- package/dist/index.d.ts +13 -0
- 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/stringRotation.test.d.ts +1 -0
- package/dist/tests/analyzing/stringRotation.test.js +42 -0
- package/dist/tests/transformations/reverseString.test.d.ts +1 -0
- package/dist/tests/transformations/reverseString.test.js +41 -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/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/isPanagram.test.d.ts +1 -0
- package/dist/tests/validations/isPanagram.test.js +39 -0
- package/dist/tests/validations/isUpperCase.test.d.ts +1 -0
- package/dist/tests/validations/isUpperCase.test.js +50 -0
- package/dist/transformations/index.d.ts +9 -0
- package/dist/transformations/index.js +14 -2
- package/dist/transformations/reverseWordsInString .d.ts +9 -0
- package/dist/transformations/reverseWordsInString .js +49 -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/validations/index.d.ts +21 -0
- package/dist/validations/index.js +30 -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/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/isPanagram.d.ts +20 -0
- package/dist/validations/isPanagram.js +35 -0
- package/dist/validations/isUpperCase.d.ts +12 -0
- package/dist/validations/isUpperCase.js +32 -0
- package/package.json +3 -3
|
@@ -0,0 +1,41 @@
|
|
|
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 reverseWordsInString_1 = require("../../transformations/reverseWordsInString ");
|
|
9
|
+
(0, node_test_1.describe)('reverseWordsInString', () => {
|
|
10
|
+
(0, node_test_1.it)('reverses words while preserving multiple spaces between them', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)('Hello world from stringzy'), 'stringzy from world Hello');
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('preserves the exact leading and trailing spaces', () => {
|
|
14
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)(' leading and trailing '), ' trailing and leading ');
|
|
15
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)('leading and trailing '), 'trailing and leading ');
|
|
16
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)(' leading and trailing'), ' trailing and leading');
|
|
17
|
+
});
|
|
18
|
+
(0, node_test_1.it)('handles a complex mix of spacing correctly', () => {
|
|
19
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)(' first second third '), ' third second first ');
|
|
20
|
+
});
|
|
21
|
+
(0, node_test_1.it)('handles a single word with or without spaces', () => {
|
|
22
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)('singleword'), 'singleword');
|
|
23
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)(' singleword '), ' singleword ');
|
|
24
|
+
});
|
|
25
|
+
(0, node_test_1.it)('returns the original string if it contains only whitespace', () => {
|
|
26
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)(' '), ' ');
|
|
27
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)('\t \n'), '\t \n');
|
|
28
|
+
});
|
|
29
|
+
(0, node_test_1.it)('returns an empty string for an empty input', () => {
|
|
30
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)(''), '');
|
|
31
|
+
});
|
|
32
|
+
(0, node_test_1.it)('handles words with numbers and special characters correctly', () => {
|
|
33
|
+
node_assert_1.default.strictEqual((0, reverseWordsInString_1.reverseWordsInString)('word1! word2@#$'), 'word2@#$ word1!');
|
|
34
|
+
});
|
|
35
|
+
(0, node_test_1.it)('throws a TypeError if the input is not a string', () => {
|
|
36
|
+
node_assert_1.default.throws(() => (0, reverseWordsInString_1.reverseWordsInString)(12345), /Input must be a string/);
|
|
37
|
+
node_assert_1.default.throws(() => (0, reverseWordsInString_1.reverseWordsInString)(null), /Input must be a string/);
|
|
38
|
+
node_assert_1.default.throws(() => (0, reverseWordsInString_1.reverseWordsInString)(undefined), /Input must be a string/);
|
|
39
|
+
node_assert_1.default.throws(() => (0, reverseWordsInString_1.reverseWordsInString)({}), /Input must be a string/);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
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 stringCombinations_1 = require("../../transformations/stringCombinations");
|
|
9
|
+
(0, node_test_1.describe)('stringCombinations', () => {
|
|
10
|
+
(0, node_test_1.it)('returns correct combinations for 2 characters', () => {
|
|
11
|
+
const expected = ['', 'a', 'b', 'ab'];
|
|
12
|
+
node_assert_1.default.deepStrictEqual((0, stringCombinations_1.stringCombinations)('ab').sort(), expected.sort());
|
|
13
|
+
});
|
|
14
|
+
(0, node_test_1.it)('returns correct combinations for 3 unique characters', () => {
|
|
15
|
+
const expected = ['', 'a', 'b', 'c', 'ab', 'ac', 'bc', 'abc'];
|
|
16
|
+
node_assert_1.default.deepStrictEqual((0, stringCombinations_1.stringCombinations)('abc').sort(), expected.sort());
|
|
17
|
+
});
|
|
18
|
+
(0, node_test_1.it)('handles repeated characters correctly', () => {
|
|
19
|
+
const expected = ['', 'a', 'b', 'aa', 'ab', 'aab'];
|
|
20
|
+
node_assert_1.default.deepStrictEqual((0, stringCombinations_1.stringCombinations)('aab').sort(), expected.sort());
|
|
21
|
+
});
|
|
22
|
+
(0, node_test_1.it)('returns only empty string for empty input', () => {
|
|
23
|
+
node_assert_1.default.deepStrictEqual((0, stringCombinations_1.stringCombinations)(''), ['']);
|
|
24
|
+
});
|
|
25
|
+
(0, node_test_1.it)('handles single character input', () => {
|
|
26
|
+
node_assert_1.default.deepStrictEqual((0, stringCombinations_1.stringCombinations)('a'), ['', 'a']);
|
|
27
|
+
});
|
|
28
|
+
(0, node_test_1.it)('is case-sensitive', () => {
|
|
29
|
+
const expected = ['', 'A', 'b', 'Ab'];
|
|
30
|
+
node_assert_1.default.deepStrictEqual((0, stringCombinations_1.stringCombinations)('Ab').sort(), expected.sort());
|
|
31
|
+
});
|
|
32
|
+
(0, node_test_1.it)('handles special characters correctly', () => {
|
|
33
|
+
const expected = ['', '!', '@', '!@'];
|
|
34
|
+
node_assert_1.default.deepStrictEqual((0, stringCombinations_1.stringCombinations)('!@').sort(), expected.sort());
|
|
35
|
+
});
|
|
36
|
+
(0, node_test_1.it)('throws an error if input is not a string', () => {
|
|
37
|
+
node_assert_1.default.throws(() => (0, stringCombinations_1.stringCombinations)(123), /Input must be a string/);
|
|
38
|
+
node_assert_1.default.throws(() => (0, stringCombinations_1.stringCombinations)(null), /Input must be a string/);
|
|
39
|
+
node_assert_1.default.throws(() => (0, stringCombinations_1.stringCombinations)(undefined), /Input must be a string/);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
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 stringPermutations_1 = require("../../transformations/stringPermutations");
|
|
9
|
+
(0, node_test_1.describe)('stringPermutations', () => {
|
|
10
|
+
(0, node_test_1.it)('returns correct permutations for small strings', () => {
|
|
11
|
+
node_assert_1.default.deepStrictEqual((0, stringPermutations_1.stringPermutations)('ab').sort(), ['ab', 'ba'].sort());
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('returns all permutations for 3 unique characters', () => {
|
|
14
|
+
const expected = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'];
|
|
15
|
+
node_assert_1.default.deepStrictEqual((0, stringPermutations_1.stringPermutations)('abc').sort(), expected.sort());
|
|
16
|
+
});
|
|
17
|
+
(0, node_test_1.it)('handles repeated characters correctly', () => {
|
|
18
|
+
const expected = ['aab', 'aba', 'baa'];
|
|
19
|
+
node_assert_1.default.deepStrictEqual((0, stringPermutations_1.stringPermutations)('aab').sort(), expected.sort());
|
|
20
|
+
});
|
|
21
|
+
(0, node_test_1.it)('handles single character input', () => {
|
|
22
|
+
node_assert_1.default.deepStrictEqual((0, stringPermutations_1.stringPermutations)('a'), ['a']);
|
|
23
|
+
});
|
|
24
|
+
(0, node_test_1.it)('handles empty string input', () => {
|
|
25
|
+
node_assert_1.default.deepStrictEqual((0, stringPermutations_1.stringPermutations)(''), ['']);
|
|
26
|
+
});
|
|
27
|
+
(0, node_test_1.it)('is case-sensitive', () => {
|
|
28
|
+
const expected = ['Ab', 'bA'];
|
|
29
|
+
node_assert_1.default.deepStrictEqual((0, stringPermutations_1.stringPermutations)('Ab').sort(), expected.sort());
|
|
30
|
+
});
|
|
31
|
+
(0, node_test_1.it)('handles special characters', () => {
|
|
32
|
+
const expected = ['!@', '@!'];
|
|
33
|
+
node_assert_1.default.deepStrictEqual((0, stringPermutations_1.stringPermutations)('!@').sort(), expected.sort());
|
|
34
|
+
});
|
|
35
|
+
(0, node_test_1.it)('throws an error if input is not a string', () => {
|
|
36
|
+
node_assert_1.default.throws(() => (0, stringPermutations_1.stringPermutations)(123), /Input must be a string/);
|
|
37
|
+
node_assert_1.default.throws(() => (0, stringPermutations_1.stringPermutations)(null), /Input must be a string/);
|
|
38
|
+
node_assert_1.default.throws(() => (0, stringPermutations_1.stringPermutations)(undefined), /Input must be a string/);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
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 isAlphaNumeric_1 = require("../../validations/isAlphaNumeric");
|
|
9
|
+
(0, node_test_1.describe)('isAlphaNumeric', () => {
|
|
10
|
+
(0, node_test_1.it)('returns true for alphanumeric strings', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, isAlphaNumeric_1.isAlphaNumeric)('abc123'), true);
|
|
12
|
+
node_assert_1.default.strictEqual((0, isAlphaNumeric_1.isAlphaNumeric)('A1B2C3'), true);
|
|
13
|
+
node_assert_1.default.strictEqual((0, isAlphaNumeric_1.isAlphaNumeric)('123'), true);
|
|
14
|
+
node_assert_1.default.strictEqual((0, isAlphaNumeric_1.isAlphaNumeric)('abc'), true);
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('returns false for strings with special characters or spaces', () => {
|
|
17
|
+
node_assert_1.default.strictEqual((0, isAlphaNumeric_1.isAlphaNumeric)('abc!123'), false);
|
|
18
|
+
node_assert_1.default.strictEqual((0, isAlphaNumeric_1.isAlphaNumeric)('hello world'), false);
|
|
19
|
+
node_assert_1.default.strictEqual((0, isAlphaNumeric_1.isAlphaNumeric)('test@'), false);
|
|
20
|
+
});
|
|
21
|
+
(0, node_test_1.it)('returns false for empty string', () => {
|
|
22
|
+
node_assert_1.default.strictEqual((0, isAlphaNumeric_1.isAlphaNumeric)(''), false);
|
|
23
|
+
});
|
|
24
|
+
(0, node_test_1.it)('throws an error if input is not a string', () => {
|
|
25
|
+
node_assert_1.default.throws(() => (0, isAlphaNumeric_1.isAlphaNumeric)(123), /Input must be a string/);
|
|
26
|
+
node_assert_1.default.throws(() => (0, isAlphaNumeric_1.isAlphaNumeric)(null), /Input must be a string/);
|
|
27
|
+
node_assert_1.default.throws(() => (0, isAlphaNumeric_1.isAlphaNumeric)(undefined), /Input must be a string/);
|
|
28
|
+
node_assert_1.default.throws(() => (0, isAlphaNumeric_1.isAlphaNumeric)({}), /Input must be a string/);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
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 isAlphabetic_1 = require("../../validations/isAlphabetic");
|
|
9
|
+
(0, node_test_1.describe)('isAlphabetic', () => {
|
|
10
|
+
(0, node_test_1.it)('returns true for purely alphabetic strings', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)('hello'), true);
|
|
12
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)('World'), true);
|
|
13
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)('TestCase'), true);
|
|
14
|
+
});
|
|
15
|
+
(0, node_test_1.it)('returns false for strings with numbers', () => {
|
|
16
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)('hello123'), false);
|
|
17
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)('Test1'), false);
|
|
18
|
+
});
|
|
19
|
+
(0, node_test_1.it)('returns false for strings with special characters or spaces', () => {
|
|
20
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)('hello!'), false);
|
|
21
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)('hello world'), false);
|
|
22
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)('Hi-There'), false);
|
|
23
|
+
});
|
|
24
|
+
(0, node_test_1.it)('returns false for empty strings', () => {
|
|
25
|
+
node_assert_1.default.strictEqual((0, isAlphabetic_1.isAlphabetic)(''), false);
|
|
26
|
+
});
|
|
27
|
+
(0, node_test_1.it)('throws an error if input is not a string', () => {
|
|
28
|
+
node_assert_1.default.throws(() => (0, isAlphabetic_1.isAlphabetic)(123), /Input must be a string/);
|
|
29
|
+
node_assert_1.default.throws(() => (0, isAlphabetic_1.isAlphabetic)(null), /Input must be a string/);
|
|
30
|
+
node_assert_1.default.throws(() => (0, isAlphabetic_1.isAlphabetic)(undefined), /Input must be a string/);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
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 isAnagram_1 = require("../../validations/isAnagram");
|
|
9
|
+
(0, node_test_1.describe)('isAnagram', () => {
|
|
10
|
+
(0, node_test_1.it)('returns true for valid anagrams (simple lowercase words)', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('listen', 'silent'), true);
|
|
12
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('evil', 'vile'), true);
|
|
13
|
+
});
|
|
14
|
+
(0, node_test_1.it)('returns true for case-insensitive matches', () => {
|
|
15
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('Listen', 'Silent'), true);
|
|
16
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('Debit Card', 'Bad Credit'), true);
|
|
17
|
+
});
|
|
18
|
+
(0, node_test_1.it)('returns true when ignoring spaces and punctuation', () => {
|
|
19
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('Astronomer', 'Moon starer'), true);
|
|
20
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('The eyes!!', 'They see'), true);
|
|
21
|
+
});
|
|
22
|
+
(0, node_test_1.it)('returns false for non-anagrams', () => {
|
|
23
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('hello', 'world'), false);
|
|
24
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('abc', 'abcd'), false);
|
|
25
|
+
});
|
|
26
|
+
(0, node_test_1.it)('returns true for single character anagrams', () => {
|
|
27
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('a', 'a'), true);
|
|
28
|
+
});
|
|
29
|
+
(0, node_test_1.it)('returns false for different single characters', () => {
|
|
30
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('a', 'b'), false);
|
|
31
|
+
});
|
|
32
|
+
(0, node_test_1.it)('returns true for empty strings (both empty)', () => {
|
|
33
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('', ''), true);
|
|
34
|
+
});
|
|
35
|
+
(0, node_test_1.it)('returns false when only one string is empty', () => {
|
|
36
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('', 'a'), false);
|
|
37
|
+
node_assert_1.default.strictEqual((0, isAnagram_1.isAnagram)('a', ''), false);
|
|
38
|
+
});
|
|
39
|
+
(0, node_test_1.it)('throws an error if inputs are not strings', () => {
|
|
40
|
+
node_assert_1.default.throws(() => (0, isAnagram_1.isAnagram)(123, 'abc'), /Both inputs must be strings/);
|
|
41
|
+
node_assert_1.default.throws(() => (0, isAnagram_1.isAnagram)(null, 'abc'), /Both inputs must be strings/);
|
|
42
|
+
node_assert_1.default.throws(() => (0, isAnagram_1.isAnagram)(undefined, 'abc'), /Both inputs must be strings/);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
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 strict_1 = __importDefault(require("node:assert/strict"));
|
|
8
|
+
const isLowerCase_1 = require("../../validations/isLowerCase");
|
|
9
|
+
(0, node_test_1.describe)('isLowerCase', () => {
|
|
10
|
+
(0, node_test_1.it)('returns true for all lowercase alphabetic strings', () => {
|
|
11
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)('hello'), true);
|
|
12
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)('world'), true);
|
|
13
|
+
});
|
|
14
|
+
(0, node_test_1.it)('returns true for strings with lowercase letters, spaces, digits, or special characters', () => {
|
|
15
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)('hello world!'), true);
|
|
16
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)('abc123'), true);
|
|
17
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)('lower_case-only!!'), true);
|
|
18
|
+
});
|
|
19
|
+
(0, node_test_1.it)('returns false if any uppercase alphabetic character is present', () => {
|
|
20
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)('Hello'), false);
|
|
21
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)('worldWide'), false);
|
|
22
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)('123ABC'), false);
|
|
23
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)('@@Good@@'), false);
|
|
24
|
+
});
|
|
25
|
+
(0, node_test_1.it)('returns false for an empty string', () => {
|
|
26
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)(''), false);
|
|
27
|
+
});
|
|
28
|
+
(0, node_test_1.it)('returns true for strings with only non-alphabetic characters (digits/symbols/spaces)', () => {
|
|
29
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)('12345'), false); // no letters
|
|
30
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)('!@#$%^&*()'), false);
|
|
31
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)(' '), false); // spaces only
|
|
32
|
+
});
|
|
33
|
+
(0, node_test_1.it)('returns true for single lowercase letters', () => {
|
|
34
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)('a'), true);
|
|
35
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)('z'), true);
|
|
36
|
+
});
|
|
37
|
+
(0, node_test_1.it)('returns false for single uppercase letters', () => {
|
|
38
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)('A'), false);
|
|
39
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)('Z'), false);
|
|
40
|
+
});
|
|
41
|
+
(0, node_test_1.it)('handles mixed alphanumeric correctly', () => {
|
|
42
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)('abc123xyz'), true);
|
|
43
|
+
strict_1.default.strictEqual((0, isLowerCase_1.isLowerCase)('abcXYZ123'), false);
|
|
44
|
+
});
|
|
45
|
+
(0, node_test_1.it)('throws an error if input is not a string', () => {
|
|
46
|
+
strict_1.default.throws(() => (0, isLowerCase_1.isLowerCase)(123), /Input must be a string/);
|
|
47
|
+
strict_1.default.throws(() => (0, isLowerCase_1.isLowerCase)(null), /Input must be a string/);
|
|
48
|
+
strict_1.default.throws(() => (0, isLowerCase_1.isLowerCase)(undefined), /Input must be a string/);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
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 isMacAddress_1 = require("../../validations/isMacAddress");
|
|
9
|
+
(0, node_test_1.describe)('isMacAddress', () => {
|
|
10
|
+
(0, node_test_1.it)('returns true for valid MAC addresses with colons', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('00:1A:2B:3C:4D:5E'), true);
|
|
12
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('aa:bb:cc:dd:ee:ff'), true);
|
|
13
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('FF:FF:FF:FF:FF:FF'), true);
|
|
14
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('01:23:45:67:89:AB'), true);
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('returns true for valid MAC addresses with hyphens', () => {
|
|
17
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('00-1A-2B-3C-4D-5E'), true);
|
|
18
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('aa-bb-cc-dd-ee-ff'), true);
|
|
19
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('FF-FF-FF-FF-FF-FF'), true);
|
|
20
|
+
});
|
|
21
|
+
(0, node_test_1.it)('returns false for MAC addresses with mixed separators', () => {
|
|
22
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('00:1A-2B:3C-4D:5E'), false);
|
|
23
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('AA-BB:CC-DD:EE-FF'), false);
|
|
24
|
+
});
|
|
25
|
+
(0, node_test_1.it)('returns false for MAC addresses with invalid hex digits', () => {
|
|
26
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('00:1G:2B:3C:4D:5E'), false);
|
|
27
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('ZZ:ZZ:ZZ:ZZ:ZZ:ZZ'), false);
|
|
28
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('GG-GG-GG-GG-GG-GG'), false);
|
|
29
|
+
});
|
|
30
|
+
(0, node_test_1.it)('returns false for MAC addresses with wrong length', () => {
|
|
31
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('00:1A:2B:3C:4D'), false); // only 5 pairs
|
|
32
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('00:1A:2B:3C:4D:5E:7F'), false); // 7 pairs
|
|
33
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('001A:2B:3C:4D:5E'), false); // first group too long
|
|
34
|
+
});
|
|
35
|
+
(0, node_test_1.it)('returns false for MAC addresses with leading/trailing spaces', () => {
|
|
36
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)(' 00:1A:2B:3C:4D:5E'), false);
|
|
37
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('00:1A:2B:3C:4D:5E '), false);
|
|
38
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)(' 00:1A:2B:3C:4D:5E '), false);
|
|
39
|
+
});
|
|
40
|
+
(0, node_test_1.it)('returns false for MAC addresses with spaces inside', () => {
|
|
41
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('00:1A:2B:3C:4D :5E'), false);
|
|
42
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('00 :1A:2B:3C:4D:5E'), false);
|
|
43
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('00:1A:2B:3C: 4D:5E'), false);
|
|
44
|
+
});
|
|
45
|
+
(0, node_test_1.it)('returns false for missing separators', () => {
|
|
46
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('001A2B3C4D5E'), false);
|
|
47
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('00:1A2B:3C4D:5E'), false);
|
|
48
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('00-1A2B-3C4D-5E'), false);
|
|
49
|
+
});
|
|
50
|
+
(0, node_test_1.it)('returns false for extra separators', () => {
|
|
51
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('00::1A:2B:3C:4D:5E'), false);
|
|
52
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('00-1A--2B-3C-4D-5E'), false);
|
|
53
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('00:1A:2B:3C:4D:5E:'), false);
|
|
54
|
+
});
|
|
55
|
+
(0, node_test_1.it)('returns false for empty strings and malformed inputs', () => {
|
|
56
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)(''), false);
|
|
57
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('::::::'), false);
|
|
58
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('--:--:--:--:--:--'), false);
|
|
59
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('00:1A:2B:3C:4D:5E:'), false);
|
|
60
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)(':00:1A:2B:3C:4D:5E'), false);
|
|
61
|
+
});
|
|
62
|
+
(0, node_test_1.it)('returns false for non-hex characters and invalid formats', () => {
|
|
63
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('00:1A:2B:3C:4D:GH'), false);
|
|
64
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('hello-world-mac'), false);
|
|
65
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('mac:address:test'), false);
|
|
66
|
+
});
|
|
67
|
+
(0, node_test_1.it)('accepts both uppercase and lowercase consistently', () => {
|
|
68
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('aa:bb:cc:dd:ee:ff'), true);
|
|
69
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('AA:BB:CC:DD:EE:FF'), true);
|
|
70
|
+
node_assert_1.default.strictEqual((0, isMacAddress_1.isMacAddress)('Aa:Bb:Cc:Dd:Ee:Ff'), true);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
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 isPanagram_1 = require("../../validations/isPanagram");
|
|
9
|
+
(0, node_test_1.describe)('isPanagram', () => {
|
|
10
|
+
(0, node_test_1.it)('returns true for a classic pangram sentence', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, isPanagram_1.isPanagram)('The quick brown fox jumps over the lazy dog.'), true);
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('returns true for the alphabet with hyphens or separators', () => {
|
|
14
|
+
node_assert_1.default.strictEqual((0, isPanagram_1.isPanagram)('A-B-C-D-E-F-G-H-I-J-K-L-M-N-O-P-Q-R-S-T-U-V-W-X-Y-Z'), true);
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('returns true for alphabet without separators', () => {
|
|
17
|
+
node_assert_1.default.strictEqual((0, isPanagram_1.isPanagram)('Abcdefghijklmnopqrstuvwxyz'), true);
|
|
18
|
+
});
|
|
19
|
+
(0, node_test_1.it)('returns true for alphabet in mixed case', () => {
|
|
20
|
+
node_assert_1.default.strictEqual((0, isPanagram_1.isPanagram)('AbCdEfGhIjKlMnOpQrStUvWxYz'), true);
|
|
21
|
+
});
|
|
22
|
+
(0, node_test_1.it)('returns false for non-pangram sentences', () => {
|
|
23
|
+
node_assert_1.default.strictEqual((0, isPanagram_1.isPanagram)('This is not a pangram.'), false);
|
|
24
|
+
node_assert_1.default.strictEqual((0, isPanagram_1.isPanagram)('Hello world'), false);
|
|
25
|
+
node_assert_1.default.strictEqual((0, isPanagram_1.isPanagram)('Quick fox'), false);
|
|
26
|
+
});
|
|
27
|
+
(0, node_test_1.it)('returns false for empty strings', () => {
|
|
28
|
+
node_assert_1.default.strictEqual((0, isPanagram_1.isPanagram)(''), false);
|
|
29
|
+
});
|
|
30
|
+
(0, node_test_1.it)('ignores numbers and punctuation', () => {
|
|
31
|
+
node_assert_1.default.strictEqual((0, isPanagram_1.isPanagram)('The quick brown fox jumps over the lazy dog! 12345'), true);
|
|
32
|
+
node_assert_1.default.strictEqual((0, isPanagram_1.isPanagram)('1234567890 !!! ???'), false);
|
|
33
|
+
});
|
|
34
|
+
(0, node_test_1.it)('throws an error if input is not a string', () => {
|
|
35
|
+
node_assert_1.default.throws(() => (0, isPanagram_1.isPanagram)(123), /Input must be a string/);
|
|
36
|
+
node_assert_1.default.throws(() => (0, isPanagram_1.isPanagram)(null), /Input must be a string/);
|
|
37
|
+
node_assert_1.default.throws(() => (0, isPanagram_1.isPanagram)(undefined), /Input must be a string/);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
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 strict_1 = __importDefault(require("node:assert/strict"));
|
|
8
|
+
const isUpperCase_1 = require("../../validations/isUpperCase");
|
|
9
|
+
(0, node_test_1.describe)('isUpperCase', () => {
|
|
10
|
+
(0, node_test_1.it)('returns true for all uppercase alphabetic strings', () => {
|
|
11
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)('HELLO'), true);
|
|
12
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)('WORLD'), true);
|
|
13
|
+
});
|
|
14
|
+
(0, node_test_1.it)('returns true for strings with uppercase letters, spaces, digits, or special characters', () => {
|
|
15
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)('HELLO WORLD!'), true);
|
|
16
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)('ABC123'), true);
|
|
17
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)('UPPER_CASE-ONLY!!'), true);
|
|
18
|
+
});
|
|
19
|
+
(0, node_test_1.it)('returns false if any lowercase alphabetic character is present', () => {
|
|
20
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)('Hello'), false);
|
|
21
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)('WORLDwide'), false);
|
|
22
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)('123abc'), false);
|
|
23
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)('@@good@@'), false);
|
|
24
|
+
});
|
|
25
|
+
(0, node_test_1.it)('returns false for an empty string', () => {
|
|
26
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)(''), false);
|
|
27
|
+
});
|
|
28
|
+
(0, node_test_1.it)('returns false for strings with only non-alphabetic characters (digits/symbols/spaces)', () => {
|
|
29
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)('12345'), false); // no letters
|
|
30
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)('!@#$%^&*()'), false);
|
|
31
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)(' '), false); // spaces only
|
|
32
|
+
});
|
|
33
|
+
(0, node_test_1.it)('returns true for single uppercase letters', () => {
|
|
34
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)('A'), true);
|
|
35
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)('Z'), true);
|
|
36
|
+
});
|
|
37
|
+
(0, node_test_1.it)('returns false for single lowercase letters', () => {
|
|
38
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)('a'), false);
|
|
39
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)('z'), false);
|
|
40
|
+
});
|
|
41
|
+
(0, node_test_1.it)('handles mixed alphanumeric correctly', () => {
|
|
42
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)('ABC123XYZ'), true);
|
|
43
|
+
strict_1.default.strictEqual((0, isUpperCase_1.isUpperCase)('ABCxyz123'), false);
|
|
44
|
+
});
|
|
45
|
+
(0, node_test_1.it)('throws an error if input is not a string', () => {
|
|
46
|
+
strict_1.default.throws(() => (0, isUpperCase_1.isUpperCase)(123), /Input must be a string/);
|
|
47
|
+
strict_1.default.throws(() => (0, isUpperCase_1.isUpperCase)(null), /Input must be a string/);
|
|
48
|
+
strict_1.default.throws(() => (0, isUpperCase_1.isUpperCase)(undefined), /Input must be a string/);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -14,6 +14,9 @@ export { truncateText } from './truncateText';
|
|
|
14
14
|
export { escapeHtml } from './escapeHTML';
|
|
15
15
|
export { maskSegment } from './maskSegment';
|
|
16
16
|
export { numberToText } from './numberToText/main';
|
|
17
|
+
export { reverseWordsInString } from './reverseWordsInString ';
|
|
18
|
+
export { stringPermutations } from './stringPermutations';
|
|
19
|
+
export { stringCombinations } from './stringCombinations';
|
|
17
20
|
import { camelCase } from './camelCase';
|
|
18
21
|
import { capitalizeWords } from './capitalizeWords';
|
|
19
22
|
import { constantCase } from './constantCase';
|
|
@@ -31,6 +34,9 @@ import { escapeHtml } from './escapeHTML';
|
|
|
31
34
|
import { maskSegment } from './maskSegment';
|
|
32
35
|
import { deburr } from './deburr';
|
|
33
36
|
import { numberToText } from './numberToText/main';
|
|
37
|
+
import { reverseWordsInString } from './reverseWordsInString ';
|
|
38
|
+
import { stringPermutations } from './stringPermutations';
|
|
39
|
+
import { stringCombinations } from './stringCombinations';
|
|
34
40
|
export declare const transformations: {
|
|
35
41
|
camelCase: typeof camelCase;
|
|
36
42
|
capitalizeWords: typeof capitalizeWords;
|
|
@@ -49,4 +55,7 @@ export declare const transformations: {
|
|
|
49
55
|
maskSegment: typeof maskSegment;
|
|
50
56
|
deburr: typeof deburr;
|
|
51
57
|
numberToText: typeof numberToText;
|
|
58
|
+
reverseWordsInString: typeof reverseWordsInString;
|
|
59
|
+
stringPermutations: typeof stringPermutations;
|
|
60
|
+
stringCombinations: typeof stringCombinations;
|
|
52
61
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformations = exports.numberToText = exports.maskSegment = exports.escapeHtml = exports.truncateText = exports.toSlug = exports.titleCase = exports.snakeCase = exports.removeWords = exports.removeSpecialChars = exports.removeDuplicates = exports.pascalCase = exports.kebabCase = exports.initials = exports.constantCase = exports.capitalizeWords = exports.camelCase = void 0;
|
|
3
|
+
exports.transformations = exports.stringCombinations = exports.stringPermutations = exports.reverseWordsInString = exports.numberToText = exports.maskSegment = exports.escapeHtml = exports.truncateText = exports.toSlug = exports.titleCase = exports.snakeCase = exports.removeWords = exports.removeSpecialChars = exports.removeDuplicates = exports.pascalCase = exports.kebabCase = exports.initials = exports.constantCase = exports.capitalizeWords = exports.camelCase = void 0;
|
|
4
4
|
var camelCase_1 = require("./camelCase");
|
|
5
5
|
Object.defineProperty(exports, "camelCase", { enumerable: true, get: function () { return camelCase_1.camelCase; } });
|
|
6
6
|
var capitalizeWords_1 = require("./capitalizeWords");
|
|
@@ -33,6 +33,12 @@ var maskSegment_1 = require("./maskSegment");
|
|
|
33
33
|
Object.defineProperty(exports, "maskSegment", { enumerable: true, get: function () { return maskSegment_1.maskSegment; } });
|
|
34
34
|
var main_1 = require("./numberToText/main");
|
|
35
35
|
Object.defineProperty(exports, "numberToText", { enumerable: true, get: function () { return main_1.numberToText; } });
|
|
36
|
+
var reverseWordsInString_1 = require("./reverseWordsInString ");
|
|
37
|
+
Object.defineProperty(exports, "reverseWordsInString", { enumerable: true, get: function () { return reverseWordsInString_1.reverseWordsInString; } });
|
|
38
|
+
var stringPermutations_1 = require("./stringPermutations");
|
|
39
|
+
Object.defineProperty(exports, "stringPermutations", { enumerable: true, get: function () { return stringPermutations_1.stringPermutations; } });
|
|
40
|
+
var stringCombinations_1 = require("./stringCombinations");
|
|
41
|
+
Object.defineProperty(exports, "stringCombinations", { enumerable: true, get: function () { return stringCombinations_1.stringCombinations; } });
|
|
36
42
|
const camelCase_2 = require("./camelCase");
|
|
37
43
|
const capitalizeWords_2 = require("./capitalizeWords");
|
|
38
44
|
const constantCase_2 = require("./constantCase");
|
|
@@ -50,6 +56,9 @@ const escapeHTML_2 = require("./escapeHTML");
|
|
|
50
56
|
const maskSegment_2 = require("./maskSegment");
|
|
51
57
|
const deburr_1 = require("./deburr");
|
|
52
58
|
const main_2 = require("./numberToText/main");
|
|
59
|
+
const reverseWordsInString_2 = require("./reverseWordsInString ");
|
|
60
|
+
const stringPermutations_2 = require("./stringPermutations");
|
|
61
|
+
const stringCombinations_2 = require("./stringCombinations");
|
|
53
62
|
exports.transformations = {
|
|
54
63
|
camelCase: camelCase_2.camelCase,
|
|
55
64
|
capitalizeWords: capitalizeWords_2.capitalizeWords,
|
|
@@ -67,5 +76,8 @@ exports.transformations = {
|
|
|
67
76
|
escapeHtml: escapeHTML_2.escapeHtml,
|
|
68
77
|
maskSegment: maskSegment_2.maskSegment,
|
|
69
78
|
deburr: deburr_1.deburr,
|
|
70
|
-
numberToText: main_2.numberToText
|
|
79
|
+
numberToText: main_2.numberToText,
|
|
80
|
+
reverseWordsInString: reverseWordsInString_2.reverseWordsInString,
|
|
81
|
+
stringPermutations: stringPermutations_2.stringPermutations,
|
|
82
|
+
stringCombinations: stringCombinations_2.stringCombinations
|
|
71
83
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reverses the order of words in a given string while preserving the
|
|
3
|
+
* exact spacing (including multiple spaces) between them.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} str - The input string whose words are to be reversed.
|
|
6
|
+
* @returns {string} The string with the order of words reversed and all original spacing intact.
|
|
7
|
+
* @throws {TypeError} If the input is not a string.
|
|
8
|
+
*/
|
|
9
|
+
export declare function reverseWordsInString(str: string): string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reverseWordsInString = reverseWordsInString;
|
|
4
|
+
/**
|
|
5
|
+
* Reverses the order of words in a given string while preserving the
|
|
6
|
+
* exact spacing (including multiple spaces) between them.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} str - The input string whose words are to be reversed.
|
|
9
|
+
* @returns {string} The string with the order of words reversed and all original spacing intact.
|
|
10
|
+
* @throws {TypeError} If the input is not a string.
|
|
11
|
+
*/
|
|
12
|
+
function reverseWordsInString(str) {
|
|
13
|
+
if (typeof str !== 'string') {
|
|
14
|
+
throw new TypeError('Input must be a string');
|
|
15
|
+
}
|
|
16
|
+
// 1. Extract all blocks of non-whitespace characters (the words).
|
|
17
|
+
const words = str.match(/\S+/g) || [];
|
|
18
|
+
// 2. If there are no words (e.g., empty or whitespace-only string), return the original string.
|
|
19
|
+
if (words.length === 0) {
|
|
20
|
+
return str;
|
|
21
|
+
}
|
|
22
|
+
// 3. Extract all blocks of whitespace.
|
|
23
|
+
const spaces = str.match(/\s+/g) || [];
|
|
24
|
+
// 4. Reverse ONLY the array of words.
|
|
25
|
+
const reversedWords = words.reverse();
|
|
26
|
+
// 5. Stitch the reversed words and original spaces back together.
|
|
27
|
+
let result = '';
|
|
28
|
+
const startsWithSpace = /^\s/.test(str);
|
|
29
|
+
if (startsWithSpace) {
|
|
30
|
+
// If the string starts with a space, the pattern is: space, word, space, word...
|
|
31
|
+
for (let i = 0; i < reversedWords.length; i++) {
|
|
32
|
+
result += spaces[i] + reversedWords[i];
|
|
33
|
+
}
|
|
34
|
+
// Append any final trailing space block.
|
|
35
|
+
if (spaces.length > reversedWords.length) {
|
|
36
|
+
result += spaces[spaces.length - 1];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// If the string starts with a word, the pattern is: word, space, word, space...
|
|
41
|
+
for (let i = 0; i < reversedWords.length; i++) {
|
|
42
|
+
result += reversedWords[i];
|
|
43
|
+
if (spaces[i]) {
|
|
44
|
+
result += spaces[i];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|