stringzy 2.2.1 → 4.0.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/.github/workflows/publish.yml +29 -0
- package/.github/workflows/test-on-pr.yml +23 -0
- package/.prettierignore +4 -0
- package/.prettierrc +7 -0
- package/CONTRIBUTING.md +99 -0
- package/LICENSE +21 -21
- package/README.md +1189 -723
- package/changelog.txt +110 -110
- package/dist/analyzing/characterCount.d.ts +20 -0
- package/dist/analyzing/characterCount.js +28 -0
- package/dist/analyzing/characterFrequency.d.ts +20 -0
- package/dist/analyzing/characterFrequency.js +35 -0
- package/dist/analyzing/complexity.d.ts +39 -0
- package/dist/analyzing/complexity.js +63 -0
- package/dist/analyzing/index.d.ts +26 -0
- package/dist/analyzing/index.js +37 -0
- package/dist/analyzing/patternCount.d.ts +10 -0
- package/dist/analyzing/patternCount.js +52 -0
- package/dist/analyzing/readingDuration.d.ts +10 -0
- package/dist/analyzing/readingDuration.js +17 -0
- package/dist/analyzing/stringSimilarity.d.ts +8 -0
- package/dist/analyzing/stringSimilarity.js +145 -0
- package/dist/analyzing/vowelConsonantCount.d.ts +22 -0
- package/dist/analyzing/vowelConsonantCount.js +38 -0
- package/dist/analyzing/wordCount.d.ts +23 -0
- package/dist/analyzing/wordCount.js +33 -0
- package/dist/formatting/capitalize.d.ts +22 -0
- package/dist/formatting/capitalize.js +33 -0
- package/dist/formatting/index.d.ts +11 -0
- package/dist/formatting/index.js +17 -0
- package/dist/formatting/number.d.ts +24 -0
- package/dist/formatting/number.js +30 -0
- package/dist/formatting/phone.d.ts +25 -0
- package/dist/formatting/phone.js +48 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +30 -0
- package/dist/tests/analyzing/characterCount.test.d.ts +1 -0
- package/dist/tests/analyzing/characterCount.test.js +19 -0
- package/dist/tests/analyzing/characterFrequency.test.d.ts +1 -0
- package/dist/tests/analyzing/characterFrequency.test.js +22 -0
- package/dist/tests/analyzing/complexity.test.d.ts +1 -0
- package/dist/tests/analyzing/complexity.test.js +28 -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.d.ts +1 -0
- package/dist/tests/analyzing/readingDuration.test.js +45 -0
- package/dist/tests/analyzing/stringSimilarity.test.d.ts +1 -0
- package/dist/tests/analyzing/stringSimilarity.test.js +61 -0
- package/dist/tests/analyzing/vowelConsonantCount.test.d.ts +1 -0
- package/dist/tests/analyzing/vowelConsonantCount.test.js +25 -0
- package/dist/tests/analyzing/wordCount.test.d.ts +1 -0
- package/dist/tests/analyzing/wordCount.test.js +22 -0
- package/dist/tests/formatting/capitalize.test.d.ts +1 -0
- package/dist/tests/formatting/capitalize.test.js +22 -0
- package/dist/tests/formatting/number.test.d.ts +1 -0
- package/dist/tests/formatting/number.test.js +19 -0
- package/dist/tests/formatting/phone.test.d.ts +1 -0
- package/dist/tests/formatting/phone.test.js +25 -0
- package/dist/tests/transformations/camelCase.test.d.ts +1 -0
- package/dist/tests/transformations/camelCase.test.js +19 -0
- package/dist/tests/transformations/capitalizeWords.test.d.ts +1 -0
- package/dist/tests/transformations/capitalizeWords.test.js +19 -0
- package/dist/tests/transformations/constantCase.test.d.ts +1 -0
- package/dist/tests/transformations/constantCase.test.js +19 -0
- package/dist/tests/transformations/deburr.test.d.ts +1 -0
- package/dist/tests/transformations/deburr.test.js +27 -0
- package/dist/tests/transformations/escapeHTML.test.d.ts +1 -0
- package/dist/tests/transformations/escapeHTML.test.js +46 -0
- package/dist/tests/transformations/initials.test.d.ts +1 -0
- package/dist/tests/transformations/initials.test.js +25 -0
- package/dist/tests/transformations/kebabCase.test.d.ts +1 -0
- package/dist/tests/transformations/kebabCase.test.js +19 -0
- package/dist/tests/transformations/maskSegment.test.d.ts +1 -0
- package/dist/tests/transformations/maskSegment.test.js +30 -0
- package/dist/tests/transformations/numberToText.test.d.ts +1 -0
- package/dist/tests/transformations/numberToText.test.js +60 -0
- package/dist/tests/transformations/pascalCase.test.d.ts +1 -0
- package/dist/tests/transformations/pascalCase.test.js +19 -0
- package/dist/tests/transformations/removeDuplicates.test.d.ts +1 -0
- package/dist/tests/transformations/removeDuplicates.test.js +19 -0
- package/dist/tests/transformations/removeSpecialChars.test.d.ts +1 -0
- package/dist/tests/transformations/removeSpecialChars.test.js +22 -0
- package/dist/tests/transformations/removeWords.test.d.ts +1 -0
- package/dist/tests/transformations/removeWords.test.js +25 -0
- package/dist/tests/transformations/snakeCase.test.d.ts +1 -0
- package/dist/tests/transformations/snakeCase.test.js +19 -0
- package/dist/tests/transformations/splitChunks.test.d.ts +1 -0
- package/dist/tests/transformations/splitChunks.test.js +31 -0
- package/dist/tests/transformations/titleCase.test.d.ts +1 -0
- package/dist/tests/transformations/titleCase.test.js +19 -0
- package/dist/tests/transformations/toSlug.test.d.ts +1 -0
- package/dist/tests/transformations/toSlug.test.js +22 -0
- package/dist/tests/transformations/truncateText.test.d.ts +1 -0
- package/dist/tests/transformations/truncateText.test.js +31 -0
- package/dist/tests/validations/isCoordinates.test.d.ts +1 -0
- package/dist/tests/validations/isCoordinates.test.js +18 -0
- package/dist/tests/validations/isDate.test.d.ts +1 -0
- package/dist/tests/validations/isDate.test.js +55 -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.d.ts +1 -0
- package/dist/tests/validations/isEmail.test.js +67 -0
- package/dist/tests/validations/isEmpty.test.d.ts +1 -0
- package/dist/tests/validations/isEmpty.test.js +19 -0
- package/dist/tests/validations/isHexColor.test.d.ts +1 -0
- package/dist/tests/validations/isHexColor.test.js +32 -0
- package/dist/tests/validations/isIPv4.test.d.ts +1 -0
- package/dist/tests/validations/isIPv4.test.js +59 -0
- package/dist/tests/validations/isPalindrome.test.d.ts +1 -0
- package/dist/tests/validations/isPalindrome.test.js +39 -0
- package/dist/tests/validations/isSlug.test.d.ts +1 -0
- package/dist/tests/validations/isSlug.test.js +22 -0
- package/dist/tests/validations/isTypeOf.test.d.ts +1 -0
- package/dist/tests/validations/isTypeOf.test.js +28 -0
- package/dist/tests/validations/isURL.test.d.ts +1 -0
- package/dist/tests/validations/isURL.test.js +18 -0
- package/dist/transformations/camelCase.d.ts +25 -0
- package/dist/transformations/camelCase.js +39 -0
- package/dist/transformations/capitalizeWords.d.ts +22 -0
- package/dist/transformations/capitalizeWords.js +30 -0
- package/dist/transformations/constantCase.d.ts +27 -0
- package/dist/transformations/constantCase.js +41 -0
- package/dist/transformations/deburr.d.ts +7 -0
- package/dist/transformations/deburr.js +16 -0
- package/dist/transformations/escapeHTML.d.ts +24 -0
- package/dist/transformations/escapeHTML.js +36 -0
- package/dist/transformations/index.d.ts +52 -0
- package/dist/transformations/index.js +71 -0
- package/dist/transformations/initials.d.ts +28 -0
- package/dist/transformations/initials.js +49 -0
- package/dist/transformations/kebabCase.d.ts +27 -0
- package/dist/transformations/kebabCase.js +41 -0
- package/dist/transformations/maskSegment.d.ts +9 -0
- package/dist/transformations/maskSegment.js +23 -0
- 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 +26 -0
- package/dist/transformations/pascalCase.js +40 -0
- package/dist/transformations/removeDuplicates.d.ts +22 -0
- package/dist/transformations/removeDuplicates.js +34 -0
- package/dist/transformations/removeSpecialChars.d.ts +23 -0
- package/dist/transformations/removeSpecialChars.js +34 -0
- package/dist/transformations/removeWords.d.ts +28 -0
- package/dist/transformations/removeWords.js +50 -0
- package/dist/transformations/snakeCase.d.ts +27 -0
- package/dist/transformations/snakeCase.js +41 -0
- package/dist/transformations/splitChunks.d.ts +8 -0
- package/dist/transformations/splitChunks.js +24 -0
- package/dist/transformations/titleCase.d.ts +26 -0
- package/dist/transformations/titleCase.js +39 -0
- package/dist/transformations/toSlug.d.ts +25 -0
- package/dist/transformations/toSlug.js +37 -0
- package/dist/transformations/truncateText.d.ts +26 -0
- package/dist/transformations/truncateText.js +44 -0
- package/dist/validations/index.d.ts +29 -0
- package/dist/validations/index.js +41 -0
- package/dist/validations/isCoordinates.d.ts +8 -0
- package/dist/validations/isCoordinates.js +19 -0
- package/dist/validations/isDate.d.ts +18 -0
- package/dist/validations/isDate.js +61 -0
- package/dist/validations/isEmail.d.ts +13 -0
- package/dist/validations/isEmail.js +180 -0
- package/dist/validations/isEmpty.d.ts +10 -0
- package/dist/validations/isEmpty.js +15 -0
- package/dist/validations/isHexColor.d.ts +7 -0
- package/dist/validations/isHexColor.js +15 -0
- package/dist/validations/isIPv4.d.ts +22 -0
- package/dist/validations/isIPv4.js +33 -0
- package/dist/validations/isPalindrome.d.ts +10 -0
- package/dist/validations/isPalindrome.js +21 -0
- package/dist/validations/isSlug.d.ts +28 -0
- package/dist/validations/isSlug.js +37 -0
- package/dist/validations/isTypeOf.d.ts +9 -0
- package/dist/validations/isTypeOf.js +30 -0
- package/dist/validations/isURL.d.ts +22 -0
- package/dist/validations/isURL.js +33 -0
- package/package.json +12 -4
- package/analysis.js +0 -21
- package/formatting.js +0 -37
- package/index.js +0 -75
- package/transformations.js +0 -190
- package/validations.js +0 -80
|
@@ -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 patternCount_1 = require("../../analyzing/patternCount");
|
|
9
|
+
(0, node_test_1.describe)('patternCount', () => {
|
|
10
|
+
(0, node_test_1.it)('returns 0 for empty string', () => {
|
|
11
|
+
node_assert_1.default.deepStrictEqual((0, patternCount_1.patternCount)('', 'aa'), 0);
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('returns 0 for empty pattern', () => {
|
|
14
|
+
node_assert_1.default.deepStrictEqual((0, patternCount_1.patternCount)('abc', ''), 0);
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('returns 0 for empty string and empty pattern', () => {
|
|
17
|
+
node_assert_1.default.deepStrictEqual((0, patternCount_1.patternCount)('', ''), 0);
|
|
18
|
+
});
|
|
19
|
+
(0, node_test_1.it)('returns correct count for single character pattern', () => {
|
|
20
|
+
node_assert_1.default.strictEqual((0, patternCount_1.patternCount)('abcabcabc', 'a'), 3);
|
|
21
|
+
});
|
|
22
|
+
(0, node_test_1.it)('returns correct count for multi-character pattern', () => {
|
|
23
|
+
node_assert_1.default.strictEqual((0, patternCount_1.patternCount)('abcabcabc', 'ab'), 3);
|
|
24
|
+
});
|
|
25
|
+
(0, node_test_1.it)('returns correct count for overlapping patterns', () => {
|
|
26
|
+
node_assert_1.default.strictEqual((0, patternCount_1.patternCount)('ababababa', 'aba'), 4);
|
|
27
|
+
});
|
|
28
|
+
(0, node_test_1.it)('returns correct count for non-overlapping patterns', () => {
|
|
29
|
+
node_assert_1.default.strictEqual((0, patternCount_1.patternCount)('abababab', 'ab'), 4);
|
|
30
|
+
});
|
|
31
|
+
(0, node_test_1.it)('returns 0 for pattern not found', () => {
|
|
32
|
+
node_assert_1.default.strictEqual((0, patternCount_1.patternCount)('abcdefg', 'xyz'), 0);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
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 readingDuration_1 = require("../../analyzing/readingDuration");
|
|
9
|
+
(0, node_test_1.describe)('readingDuration', () => {
|
|
10
|
+
const testCases = [
|
|
11
|
+
{ text: '', expectedDuration: 0 }, // Empty string
|
|
12
|
+
{ text: 'This is a short text', expectedDuration: 0 }, // 5 words
|
|
13
|
+
{
|
|
14
|
+
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
|
|
15
|
+
expectedDuration: 0, // 19 words
|
|
16
|
+
},
|
|
17
|
+
{ text: ' This text has extra spaces ', expectedDuration: 0 }, // 6 words
|
|
18
|
+
{ text: 'Word', expectedDuration: 0 }, // 1 word
|
|
19
|
+
{
|
|
20
|
+
text: 'A longer text with exactly twenty-three words to test the calculation properly.',
|
|
21
|
+
expectedDuration: 0, // 23 words
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
text: 'This text contains fifty words. It is designed to test the reading duration function with a larger input. The function should calculate the duration accurately based on the average reading speed.',
|
|
25
|
+
expectedDuration: 0, // 50 words
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
text: Array(9999).fill('Word').join(' '), // Generates a text with 9999 words
|
|
29
|
+
expectedDuration: 43, // 9999 words / 230 words per minute ≈ 43 minutes
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
text: Array(230).fill('Word').join(' '), // Generates a text with 230 words
|
|
33
|
+
expectedDuration: 1, // 230 words / 230 words per minute = 1 minute
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
text: Array(460).fill('Word').join(' '), // Generates a text with 460 words
|
|
37
|
+
expectedDuration: 2, // 460 words / 230 words per minute = 2 minutes
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
testCases.forEach(({ text, expectedDuration }) => {
|
|
41
|
+
(0, node_test_1.it)(`returns ${expectedDuration} for text with ${text.split(' ').length} words`, () => {
|
|
42
|
+
node_assert_1.default.strictEqual((0, readingDuration_1.readingDuration)(text), expectedDuration);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
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 stringSimilarity_1 = require("../../analyzing/stringSimilarity");
|
|
9
|
+
(0, node_test_1.describe)('stringSimilarity', () => {
|
|
10
|
+
(0, node_test_1.describe)('Param error handling', () => {
|
|
11
|
+
(0, node_test_1.it)('should throw if text arguments are not a string', () => {
|
|
12
|
+
node_assert_1.default.throws(() => (0, stringSimilarity_1.stringSimilarity)(123, 'abc'), /Both text arguments must be strings/i);
|
|
13
|
+
node_assert_1.default.throws(() => (0, stringSimilarity_1.stringSimilarity)('abc', null), /Both text arguments must be strings/i);
|
|
14
|
+
});
|
|
15
|
+
(0, node_test_1.it)('should throw if algorithm argument is invalid', () => {
|
|
16
|
+
node_assert_1.default.throws(() => (0, stringSimilarity_1.stringSimilarity)('abc', 'abc', 'invalid'), /Invalid optional algorithm param. Should be 'Levenshtein' or 'Damerau-Levenshtein'/i);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
(0, node_test_1.describe)('Basic similarity cases', () => {
|
|
20
|
+
(0, node_test_1.it)('should return 100% for identical strings', () => {
|
|
21
|
+
node_assert_1.default.strictEqual((0, stringSimilarity_1.stringSimilarity)('abc', 'abc', 'Levenshtein'), 100.0);
|
|
22
|
+
node_assert_1.default.strictEqual((0, stringSimilarity_1.stringSimilarity)('abc', 'abc', 'Damerau-Levenshtein'), 100.0);
|
|
23
|
+
});
|
|
24
|
+
(0, node_test_1.it)('should return 100% for two empty strings', () => {
|
|
25
|
+
node_assert_1.default.strictEqual((0, stringSimilarity_1.stringSimilarity)('', '', 'Levenshtein'), 100.0);
|
|
26
|
+
node_assert_1.default.strictEqual((0, stringSimilarity_1.stringSimilarity)('', '', 'Damerau-Levenshtein'), 100.0);
|
|
27
|
+
});
|
|
28
|
+
(0, node_test_1.it)('should return 0% for empty vs non-empty string', () => {
|
|
29
|
+
node_assert_1.default.strictEqual((0, stringSimilarity_1.stringSimilarity)('abc', '', 'Levenshtein'), 0.0);
|
|
30
|
+
node_assert_1.default.strictEqual((0, stringSimilarity_1.stringSimilarity)('abc', '', 'Damerau-Levenshtein'), 0.0);
|
|
31
|
+
});
|
|
32
|
+
(0, node_test_1.it)('should return 0% for same letters with different case (case-sensitive)', () => {
|
|
33
|
+
node_assert_1.default.strictEqual((0, stringSimilarity_1.stringSimilarity)('ABC', 'abc', 'Levenshtein'), 0.0);
|
|
34
|
+
node_assert_1.default.strictEqual((0, stringSimilarity_1.stringSimilarity)('ABC', 'abc', 'Damerau-Levenshtein'), 0.0);
|
|
35
|
+
});
|
|
36
|
+
(0, node_test_1.it)('should return 0% for completely different strings (abc vs xyz)', () => {
|
|
37
|
+
node_assert_1.default.strictEqual((0, stringSimilarity_1.stringSimilarity)('abc', 'xyz', 'Levenshtein'), 0.0);
|
|
38
|
+
node_assert_1.default.strictEqual((0, stringSimilarity_1.stringSimilarity)('abc', 'xyz', 'Damerau-Levenshtein'), 0.0);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
(0, node_test_1.describe)('Algorithm comparison: Levenshtein vs Damerau-Levenshtein', () => {
|
|
42
|
+
(0, node_test_1.it)('should return 0% for transposition using Levenshtein (ab vs ba)', () => {
|
|
43
|
+
node_assert_1.default.strictEqual((0, stringSimilarity_1.stringSimilarity)('ab', 'ba', 'Levenshtein'), 0.0);
|
|
44
|
+
});
|
|
45
|
+
(0, node_test_1.it)('should return 50% for transposition using Damerau-Levenshtein (ab vs ba)', () => {
|
|
46
|
+
node_assert_1.default.strictEqual((0, stringSimilarity_1.stringSimilarity)('ab', 'ba', 'Damerau-Levenshtein'), 50.0);
|
|
47
|
+
});
|
|
48
|
+
(0, node_test_1.it)('should return 50% for near transposition using Levenshtein (acbd vs abcd)', () => {
|
|
49
|
+
node_assert_1.default.strictEqual((0, stringSimilarity_1.stringSimilarity)('acbd', 'abcd', 'Levenshtein'), 50.0);
|
|
50
|
+
});
|
|
51
|
+
(0, node_test_1.it)('should return 75% for near transposition using Damerau-Levenshtein (acbd vs abcd)', () => {
|
|
52
|
+
node_assert_1.default.strictEqual((0, stringSimilarity_1.stringSimilarity)('acbd', 'abcd', 'Damerau-Levenshtein'), 75.0);
|
|
53
|
+
});
|
|
54
|
+
(0, node_test_1.it)('should return 75% for single insertion using Levenshtein (abc vs abcd)', () => {
|
|
55
|
+
node_assert_1.default.strictEqual((0, stringSimilarity_1.stringSimilarity)('abc', 'abcd', 'Levenshtein'), 75.0);
|
|
56
|
+
});
|
|
57
|
+
(0, node_test_1.it)('should return 75% for single deletion using Levenshtein (abcd vs abc)', () => {
|
|
58
|
+
node_assert_1.default.strictEqual((0, stringSimilarity_1.stringSimilarity)('abcd', 'abc', 'Levenshtein'), 75.0);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
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 vowelConsonantCount_1 = require("../../analyzing/vowelConsonantCount");
|
|
9
|
+
(0, node_test_1.describe)('vowelConsonantCount', () => {
|
|
10
|
+
(0, node_test_1.it)('returns 0s for empty string', () => {
|
|
11
|
+
node_assert_1.default.deepStrictEqual((0, vowelConsonantCount_1.vowelConsonantCount)(''), { vowels: 0, consonants: 0 });
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('counts lowercase vowels and consonants', () => {
|
|
14
|
+
node_assert_1.default.deepStrictEqual((0, vowelConsonantCount_1.vowelConsonantCount)('hello'), { vowels: 2, consonants: 3 });
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('counts uppercase vowels and consonants', () => {
|
|
17
|
+
node_assert_1.default.deepStrictEqual((0, vowelConsonantCount_1.vowelConsonantCount)('HELLO'), { vowels: 2, consonants: 3 });
|
|
18
|
+
});
|
|
19
|
+
(0, node_test_1.it)('counts vowels and consonants ignoring special characters and whitespaces', () => {
|
|
20
|
+
node_assert_1.default.deepStrictEqual((0, vowelConsonantCount_1.vowelConsonantCount)('Hello, World!'), { vowels: 3, consonants: 7 });
|
|
21
|
+
});
|
|
22
|
+
(0, node_test_1.it)('throws if input is not a string', () => {
|
|
23
|
+
node_assert_1.default.throws(() => (0, vowelConsonantCount_1.vowelConsonantCount)(123), /Input must be a string/);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
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 wordCount_1 = require("../../analyzing/wordCount");
|
|
9
|
+
(0, node_test_1.describe)('wordCount', () => {
|
|
10
|
+
(0, node_test_1.it)('counts words in a string', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, wordCount_1.wordCount)('hello world'), 2);
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('returns 0 for empty string', () => {
|
|
14
|
+
node_assert_1.default.strictEqual((0, wordCount_1.wordCount)(''), 0);
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('returns 0 for whitespace string', () => {
|
|
17
|
+
node_assert_1.default.strictEqual((0, wordCount_1.wordCount)(' '), 0);
|
|
18
|
+
});
|
|
19
|
+
(0, node_test_1.it)('throws if input is not a string', () => {
|
|
20
|
+
node_assert_1.default.throws(() => (0, wordCount_1.wordCount)(123), /Input must be a string/);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
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 capitalize_1 = require("../../formatting/capitalize");
|
|
9
|
+
(0, node_test_1.describe)('capitalize', () => {
|
|
10
|
+
(0, node_test_1.it)('capitalizes each word', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, capitalize_1.capitalize)('hello world'), 'Hello World');
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('handles single word', () => {
|
|
14
|
+
node_assert_1.default.strictEqual((0, capitalize_1.capitalize)('foo'), 'Foo');
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('handles empty string', () => {
|
|
17
|
+
node_assert_1.default.strictEqual((0, capitalize_1.capitalize)(''), '');
|
|
18
|
+
});
|
|
19
|
+
(0, node_test_1.it)('throws if input is not a string', () => {
|
|
20
|
+
node_assert_1.default.throws(() => (0, capitalize_1.capitalize)(123), /Input must be a string/);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
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 number_1 = require("../../formatting/number");
|
|
9
|
+
(0, node_test_1.describe)('formatNumber', () => {
|
|
10
|
+
(0, node_test_1.it)('formats number with default separator', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, number_1.formatNumber)(1234567), '1,234,567');
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('formats string number with dot separator', () => {
|
|
14
|
+
node_assert_1.default.strictEqual((0, number_1.formatNumber)('1234567', '.'), '1.234.567');
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('returns single digit as is', () => {
|
|
17
|
+
node_assert_1.default.strictEqual((0, number_1.formatNumber)(7), '7');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
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 phone_1 = require("../../formatting/phone");
|
|
9
|
+
(0, node_test_1.describe)('formatPhone', () => {
|
|
10
|
+
(0, node_test_1.it)('formats US phone', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, phone_1.formatPhone)('1234567890', 'us'), '(123) 456-7890');
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('formats international phone', () => {
|
|
14
|
+
node_assert_1.default.strictEqual((0, phone_1.formatPhone)('911234567890', 'international'), '+91 (123) 456-7890');
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('formats IN phone (10 digits)', () => {
|
|
17
|
+
node_assert_1.default.strictEqual((0, phone_1.formatPhone)('9876543210', 'in'), '+91-98765-43210');
|
|
18
|
+
});
|
|
19
|
+
(0, node_test_1.it)('formats IN phone (12 digits, starts with 91)', () => {
|
|
20
|
+
node_assert_1.default.strictEqual((0, phone_1.formatPhone)('919876543210', 'in'), '+91-98765-43210');
|
|
21
|
+
});
|
|
22
|
+
(0, node_test_1.it)('returns input if format does not match', () => {
|
|
23
|
+
node_assert_1.default.strictEqual((0, phone_1.formatPhone)('123', 'us'), '123');
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
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 camelCase_1 = require("../../transformations/camelCase");
|
|
9
|
+
(0, node_test_1.describe)('camelCase', () => {
|
|
10
|
+
(0, node_test_1.it)('converts text to camelCase', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, camelCase_1.camelCase)('hello world'), 'helloWorld');
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('handles empty string', () => {
|
|
14
|
+
node_assert_1.default.strictEqual((0, camelCase_1.camelCase)(''), '');
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('returns empty string for null', () => {
|
|
17
|
+
node_assert_1.default.strictEqual((0, camelCase_1.camelCase)(null), '');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
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 capitalizeWords_1 = require("../../transformations/capitalizeWords");
|
|
9
|
+
(0, node_test_1.describe)('capitalizeWords', () => {
|
|
10
|
+
(0, node_test_1.it)('capitalizes each word', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, capitalizeWords_1.capitalizeWords)('hello world'), 'Hello World');
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('handles empty string', () => {
|
|
14
|
+
node_assert_1.default.strictEqual((0, capitalizeWords_1.capitalizeWords)(''), '');
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('throws if input is not a string', () => {
|
|
17
|
+
node_assert_1.default.throws(() => (0, capitalizeWords_1.capitalizeWords)(123), /Invalid argument/);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
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 constantCase_1 = require("../../transformations/constantCase");
|
|
9
|
+
(0, node_test_1.describe)('constantCase', () => {
|
|
10
|
+
(0, node_test_1.it)('converts text to CONSTANT_CASE', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, constantCase_1.constantCase)('hello world'), 'HELLO_WORLD');
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('handles camelCase', () => {
|
|
14
|
+
node_assert_1.default.strictEqual((0, constantCase_1.constantCase)('helloWorld'), 'HELLO_WORLD');
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('returns empty string for null', () => {
|
|
17
|
+
node_assert_1.default.strictEqual((0, constantCase_1.constantCase)(null), '');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
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 deburr_1 = require("../../transformations/deburr");
|
|
9
|
+
(0, node_test_1.describe)('deburr', () => {
|
|
10
|
+
(0, node_test_1.it)('removes accents and diacritics', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, deburr_1.deburr)('déjà vu'), 'deja vu');
|
|
12
|
+
node_assert_1.default.strictEqual((0, deburr_1.deburr)('Élève'), 'Eleve');
|
|
13
|
+
node_assert_1.default.strictEqual((0, deburr_1.deburr)('São Paulo'), 'Sao Paulo');
|
|
14
|
+
node_assert_1.default.strictEqual((0, deburr_1.deburr)('über cool'), 'uber cool');
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('returns the original string if no accents present', () => {
|
|
17
|
+
node_assert_1.default.strictEqual((0, deburr_1.deburr)('hello world'), 'hello world');
|
|
18
|
+
});
|
|
19
|
+
(0, node_test_1.it)('returns empty string if input is empty', () => {
|
|
20
|
+
node_assert_1.default.strictEqual((0, deburr_1.deburr)(''), '');
|
|
21
|
+
});
|
|
22
|
+
(0, node_test_1.it)('throws an error if input is not a string', () => {
|
|
23
|
+
node_assert_1.default.throws(() => (0, deburr_1.deburr)(123), /Input must be a string/);
|
|
24
|
+
node_assert_1.default.throws(() => (0, deburr_1.deburr)(null), /Input must be a string/);
|
|
25
|
+
node_assert_1.default.throws(() => (0, deburr_1.deburr)(undefined), /Input must be a string/);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
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 escapeHTML_1 = require("../../transformations/escapeHTML");
|
|
9
|
+
(0, node_test_1.describe)('escapeHtml', () => {
|
|
10
|
+
(0, node_test_1.it)('escapes ampersand', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, escapeHTML_1.escapeHtml)('Tom & Jerry'), 'Tom & Jerry');
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('escapes less than', () => {
|
|
14
|
+
node_assert_1.default.strictEqual((0, escapeHTML_1.escapeHtml)('5 < 10'), '5 < 10');
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('escapes greater than', () => {
|
|
17
|
+
node_assert_1.default.strictEqual((0, escapeHTML_1.escapeHtml)('10 > 5'), '10 > 5');
|
|
18
|
+
});
|
|
19
|
+
(0, node_test_1.it)('escapes double quotes', () => {
|
|
20
|
+
node_assert_1.default.strictEqual((0, escapeHTML_1.escapeHtml)('Say "Hello"'), 'Say "Hello"');
|
|
21
|
+
});
|
|
22
|
+
(0, node_test_1.it)('escapes single quotes', () => {
|
|
23
|
+
node_assert_1.default.strictEqual((0, escapeHTML_1.escapeHtml)("It's working"), 'It's working');
|
|
24
|
+
});
|
|
25
|
+
(0, node_test_1.it)('escapes all special characters together', () => {
|
|
26
|
+
node_assert_1.default.strictEqual((0, escapeHTML_1.escapeHtml)(`&<>"'`), '&<>"'');
|
|
27
|
+
});
|
|
28
|
+
(0, node_test_1.it)('escapes script tag', () => {
|
|
29
|
+
node_assert_1.default.strictEqual((0, escapeHTML_1.escapeHtml)('<script>alert("XSS")</script>'), '<script>alert("XSS")</script>');
|
|
30
|
+
});
|
|
31
|
+
(0, node_test_1.it)('escapes HTML with attributes', () => {
|
|
32
|
+
node_assert_1.default.strictEqual((0, escapeHTML_1.escapeHtml)('<div class="test">content</div>'), '<div class="test">content</div>');
|
|
33
|
+
});
|
|
34
|
+
(0, node_test_1.it)('handles empty string', () => {
|
|
35
|
+
node_assert_1.default.strictEqual((0, escapeHTML_1.escapeHtml)(''), '');
|
|
36
|
+
});
|
|
37
|
+
(0, node_test_1.it)('handles string with no special characters', () => {
|
|
38
|
+
node_assert_1.default.strictEqual((0, escapeHTML_1.escapeHtml)('Hello World'), 'Hello World');
|
|
39
|
+
});
|
|
40
|
+
(0, node_test_1.it)('escapes repeated characters', () => {
|
|
41
|
+
node_assert_1.default.strictEqual((0, escapeHTML_1.escapeHtml)('<<>>'), '<<>>');
|
|
42
|
+
});
|
|
43
|
+
(0, node_test_1.it)('preserves whitespace', () => {
|
|
44
|
+
node_assert_1.default.strictEqual((0, escapeHTML_1.escapeHtml)(' < > '), ' < > ');
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
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 initials_1 = require("../../transformations/initials");
|
|
9
|
+
(0, node_test_1.describe)('initials', () => {
|
|
10
|
+
(0, node_test_1.it)('returns initials for each word', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, initials_1.initials)('hello world'), 'hw');
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('limits initials if limit is set', () => {
|
|
14
|
+
node_assert_1.default.strictEqual((0, initials_1.initials)('foo bar baz', 2), 'fb');
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('returns empty string for empty input', () => {
|
|
17
|
+
node_assert_1.default.strictEqual((0, initials_1.initials)('', 2), '');
|
|
18
|
+
});
|
|
19
|
+
(0, node_test_1.it)('throws if input is not a string', () => {
|
|
20
|
+
node_assert_1.default.throws(() => (0, initials_1.initials)(123), /Input must be a string/);
|
|
21
|
+
});
|
|
22
|
+
(0, node_test_1.it)('throws if limit is negative', () => {
|
|
23
|
+
node_assert_1.default.throws(() => (0, initials_1.initials)('foo bar', -1), /Limit must be a non-negative number/);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
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 kebabCase_1 = require("../../transformations/kebabCase");
|
|
9
|
+
(0, node_test_1.describe)('kebabCase', () => {
|
|
10
|
+
(0, node_test_1.it)('converts text to kebab-case', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, kebabCase_1.kebabCase)('hello world'), 'hello-world');
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('handles camelCase', () => {
|
|
14
|
+
node_assert_1.default.strictEqual((0, kebabCase_1.kebabCase)('helloWorld'), 'hello-world');
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('returns empty string for null', () => {
|
|
17
|
+
node_assert_1.default.strictEqual((0, kebabCase_1.kebabCase)(null), '');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -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 maskSegment_1 = require("../../transformations/maskSegment");
|
|
9
|
+
(0, node_test_1.describe)('maskSegment', () => {
|
|
10
|
+
(0, node_test_1.it)('masks the string correctly', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, maskSegment_1.maskSegment)('1234567890', 2, 6), '12****7890');
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('masks full string if entire range is selected', () => {
|
|
14
|
+
node_assert_1.default.strictEqual((0, maskSegment_1.maskSegment)('secret', 0, 6), '******');
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('supports custom mask character', () => {
|
|
17
|
+
node_assert_1.default.strictEqual((0, maskSegment_1.maskSegment)('abcdef', 1, 4, '#'), 'a###ef');
|
|
18
|
+
});
|
|
19
|
+
(0, node_test_1.it)('throws on invalid range', () => {
|
|
20
|
+
node_assert_1.default.throws(() => (0, maskSegment_1.maskSegment)('abc', 2, 1));
|
|
21
|
+
node_assert_1.default.throws(() => (0, maskSegment_1.maskSegment)('abc', -1, 2));
|
|
22
|
+
node_assert_1.default.throws(() => (0, maskSegment_1.maskSegment)('abc', 0, 4));
|
|
23
|
+
});
|
|
24
|
+
(0, node_test_1.it)('throws if maskChar is more than one character', () => {
|
|
25
|
+
node_assert_1.default.throws(() => (0, maskSegment_1.maskSegment)('abc', 0, 2, '**'));
|
|
26
|
+
});
|
|
27
|
+
(0, node_test_1.it)('handles empty string', () => {
|
|
28
|
+
node_assert_1.default.throws(() => (0, maskSegment_1.maskSegment)('', 0, 1));
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
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 transformations_1 = require("../../transformations");
|
|
9
|
+
(0, node_test_1.describe)("numberToText", () => {
|
|
10
|
+
(0, node_test_1.describe)("Param error handling", () => {
|
|
11
|
+
node_assert_1.default.throws(() => (0, transformations_1.numberToText)("aaaa"), /Num param should be number/i);
|
|
12
|
+
node_assert_1.default.throws(() => (0, transformations_1.numberToText)(1000000000001), RangeError);
|
|
13
|
+
node_assert_1.default.throws(() => (0, transformations_1.numberToText)(-1000000000001), RangeError);
|
|
14
|
+
const validLanguages = ['en', 'pl'];
|
|
15
|
+
const errorMessage = `Language must be one of: ${validLanguages.join(', ')}`;
|
|
16
|
+
node_assert_1.default.throws(() => (0, transformations_1.numberToText)(123, "invalid"), new RegExp(errorMessage, "i"));
|
|
17
|
+
});
|
|
18
|
+
(0, node_test_1.describe)("Conversion cases - en", () => {
|
|
19
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(0), "zero");
|
|
20
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1), "one");
|
|
21
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(5), "five");
|
|
22
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(10), "ten");
|
|
23
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(15), "fifteen");
|
|
24
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(21), "twenty-one");
|
|
25
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(99), "ninety-nine");
|
|
26
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(100), "one hundred");
|
|
27
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(101), "one hundred one");
|
|
28
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(215), "two hundred fifteen");
|
|
29
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1000), "one thousand");
|
|
30
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(2023), "two thousand twenty-three");
|
|
31
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1000000), "one million");
|
|
32
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1200000), "one million two hundred thousand");
|
|
33
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1000000000), "one billion");
|
|
34
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1000000000000), "one trillion");
|
|
35
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(-1), "minus one");
|
|
36
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(-215), "minus two hundred fifteen");
|
|
37
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(-1000000), "minus one million");
|
|
38
|
+
});
|
|
39
|
+
(0, node_test_1.describe)("Conversion cases - pl", () => {
|
|
40
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(0, 'pl'), "zero");
|
|
41
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1, 'pl'), "jeden");
|
|
42
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(5, 'pl'), "pięć");
|
|
43
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(10, 'pl'), "dziesięć");
|
|
44
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(15, 'pl'), "piętnaście");
|
|
45
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(21, 'pl'), "dwadzieścia jeden");
|
|
46
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(99, 'pl'), "dziewięćdziesiąt dziewięć");
|
|
47
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(100, 'pl'), "sto");
|
|
48
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(101, 'pl'), "sto jeden");
|
|
49
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(215, 'pl'), "dwieście piętnaście");
|
|
50
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1000, 'pl'), "tysiąc");
|
|
51
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(2023, 'pl'), "dwa tysiące dwadzieścia trzy");
|
|
52
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1000000, 'pl'), "milion");
|
|
53
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1200000, 'pl'), "milion dwieście tysięcy");
|
|
54
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1000000000, 'pl'), "miliard");
|
|
55
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(1000000000000, 'pl'), "bilion");
|
|
56
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(-1, 'pl'), "minus jeden");
|
|
57
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(-215, 'pl'), "minus dwieście piętnaście");
|
|
58
|
+
node_assert_1.default.strictEqual((0, transformations_1.numberToText)(-1000000, 'pl'), "minus milion");
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
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 pascalCase_1 = require("../../transformations/pascalCase");
|
|
9
|
+
(0, node_test_1.describe)('pascalCase', () => {
|
|
10
|
+
(0, node_test_1.it)('converts text to PascalCase', () => {
|
|
11
|
+
node_assert_1.default.strictEqual((0, pascalCase_1.pascalCase)('hello world'), 'HelloWorld');
|
|
12
|
+
});
|
|
13
|
+
(0, node_test_1.it)('handles empty string', () => {
|
|
14
|
+
node_assert_1.default.strictEqual((0, pascalCase_1.pascalCase)(''), '');
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.it)('returns empty string for null', () => {
|
|
17
|
+
node_assert_1.default.strictEqual((0, pascalCase_1.pascalCase)(null), '');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|