diff --git a/README.md b/README.md index 2ed26d5..d01a3ec 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@ - [Usage](#2-usage) - [CasingMaster](#1-CasingMaster): Convert strings to various cases, like Camel Case, Snake Case, and more. - [ConversionMaster](#2-ConversionMaster): Convert strings between different types, such as hexadecimal, integers, or float. - - [CompressionMaster](#3-compressionmaster): Compress and decompress strings. - [EmojiMaster](#4-emojimaster): Manipulate, find, or replace emojis in strings. - [EntropyMaster](#5-entropymaster): Calculate the entropy of a string for cryptographic analysis. - [FrequencyMaster](#6-frequencymaster): Analyze the frequency of characters or words in strings. @@ -88,19 +87,7 @@ console.log(ConversionMaster.toHex('Hello')); // '48656c6c6f' console.log(ConversionMaster.fromHex('48656c6c6f')); // 'Hello' ``` -### 3. CompressionMaster -The CompressionMaster class handles string compression and decompression. -```ts -import { CompressionMaster } from 'string-master'; - -const compressed = CompressionMaster.compress('Hello, world!'); -console.log(compressed); // Compressed string (e.g., "〶惶̀Ў㦀☄∀") - -const decompressed = CompressionMaster.decompress(compressed); -console.log(decompressed); // 'Hello, world!' -``` - -### 4. EmojiMaster +### 3. EmojiMaster The EmojiMaster class helps find, replace, or manipulate emojis in strings. ```ts import { EmojiMaster } from 'string-master'; @@ -115,7 +102,7 @@ const modifiedTextWithEmojis = EmojiMaster.replaceWordsWithEmojis('I am very hap console.log(modifiedTextWithEmojis); // 'I am very 😊 and a bit 😢.' ``` -### 5. EntropyMaster +### 4. EntropyMaster The EntropyMaster class calculates the entropy of a string, useful for cryptography or information theory. ```ts import { EntropyMaster } from 'string-master'; @@ -124,7 +111,7 @@ console.log(EntropyMaster.calculateEntropy('password123')); // 3.27 console.log(EntropyMaster.getStrength('password123')); // 'Moderate' ``` -### 6. FrequencyMaster +### 5. FrequencyMaster The FrequencyMaster class analyzes the frequency of characters or words in a string. ```ts import { FrequencyMaster } from 'string-master'; @@ -137,7 +124,7 @@ console.log(FrequencyMaster.findMostFrequentWords(text, 1)); // [{ word: "hello" console.log(FrequencyMaster.findLeastFrequentWords(text, 1)); // [{ word: "world", count: 1 }] console.log(FrequencyMaster.getTopNCharacters(text, 2)); // [{ character: "l", count: 5 }, { character: "o", count: 3 }] ``` -### 7. InflectionMaster +### 6. InflectionMaster The InflectionMaster class handles pluralization and singularization of words. Examples: @@ -190,7 +177,7 @@ const inflectHat2 = InflectionMaster.inflect('Hat', 2); console.log(inflectHat2); // 'Hats' ``` -### 8. InitialsMaster +### 7. InitialsMaster The InitialsMaster class extracts initials from a string. Examples: @@ -265,7 +252,7 @@ console.log(customAcronym); // 'I' ``` -### 9. ManipulationMaster +### 8. ManipulationMaster The ManipulationMaster class provides methods to perform various manipulations on strings, like reversing or shuffling. Examples: @@ -336,7 +323,7 @@ const ordinalizeResult = ManipulationMaster.ordinalize('the 1 pitch and 22 jumps console.log(ordinalizeResult); // 'the 1st pitch and 22nd jumps' ``` -### 10. MaskingMaster +### 9. MaskingMaster The MaskingMaster class masks parts of a string, such as credit card numbers or emails. Examples: @@ -359,7 +346,7 @@ console.log(maskedSSN); // '***-**-6789' const maskedString = MaskingMaster.maskString('SensitiveData', 2, 2); console.log(maskedString); // 'Se********ta' ``` -### 11. ObfuscationMaster +### 10. ObfuscationMaster The ObfuscationMaster class obfuscates and deobfuscates strings for privacy or security purposes. Examples: @@ -383,7 +370,7 @@ console.log(obfuscatedXOR); // .''$k$9'/ const original = ObfuscationMaster.deobfuscateXOR(obfuscatedXOR, 'K'); console.log(original); // "Hello World" ``` -### 12. SanitizationMaster +### 11. SanitizationMaster The SanitizationMaster class provides methods to sanitize strings, removing unwanted characters or formatting. Examples: @@ -404,7 +391,7 @@ const sanitizedString = SanitizationMaster.sanitizeForDisplay('
Hello\u0001W console.log(sanitizedString); // "<div>HelloWorld</div>" ``` -### 13. SearchMaster +### 12. SearchMaster The SearchMaster class provides methods for searching within strings, including fuzzy search and proximity search. Examples: @@ -445,7 +432,7 @@ const highlighted = SearchMaster.highlight('Hello, world!', 'world'); console.log(highlighted); // 'Hello, world!' ``` -### 14. SimilarityMaster +### 13. SimilarityMaster The SimilarityMaster class calculates the similarity between two strings using various algorithms like Jaccard, Levenshtein, and Jaro-Winkler. Examples: @@ -490,7 +477,7 @@ console.log(comparison.bestMatch); // { target: 'apples', rating: 0.8 } console.log(comparison.bestMatchIndex); // 0 ``` -### 15. SlugMaster +### 14. SlugMaster The SlugMaster class converts strings to URL-friendly slugs. Examples: @@ -515,7 +502,7 @@ const slugWithRules = SlugMaster.slugify('Rock and Roll'); console.log(slugWithRules); // "rock-n-roll" ``` -### 16. TemplateMaster +### 15. TemplateMaster The TemplateMaster class allows for simple templating and string interpolation. Examples: @@ -541,7 +528,7 @@ const result4 = templateFunc({ name: 'John' }); console.log(result4); // "Hello, John!" ``` -### 17. TrimmingMaster +### 16. TrimmingMaster The TrimmingMaster class provides various methods for trimming whitespace or characters from strings. Examples: @@ -562,7 +549,7 @@ const result3 = TrimmingMaster.collapseWhitespace('Hello World! '); console.log(result3); // 'Hello World!' ``` -### 18. ValidationMaster +### 17. ValidationMaster The ValidationMaster class validates strings against different rules, such as email or URL formats. Examples: diff --git a/package-lock.json b/package-lock.json index 4d268cc..8326c9e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "npm-pkg-boilerplate", + "name": "string-master", "version": "1.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "npm-pkg-boilerplate", + "name": "string-master", "version": "1.0.1", "license": "MIT", "devDependencies": { @@ -23,7 +23,6 @@ "globals": "^15.9.0", "husky": "^9.1.5", "jest": "^29.7.0", - "lz-string": "^1.5.0", "prettier": "3.3.3", "semantic-release": "^24.1.0", "ts-jest": "^29.2.5", @@ -6349,15 +6348,6 @@ "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", "dev": true }, - "node_modules/lz-string": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", - "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", - "dev": true, - "bin": { - "lz-string": "bin/bin.js" - } - }, "node_modules/make-dir": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", diff --git a/package.json b/package.json index 2c2dbf3..8656981 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,6 @@ "ts-jest": "^29.2.5", "ts-node": "^10.9.2", "typescript": "^5.5.4", - "typescript-eslint": "^8.4.0", - "lz-string": "^1.5.0" + "typescript-eslint": "^8.4.0" } } diff --git a/src/compression-master.ts b/src/compression-master.ts deleted file mode 100644 index b18c0a1..0000000 --- a/src/compression-master.ts +++ /dev/null @@ -1,29 +0,0 @@ -import * as LZString from 'lz-string'; -/** - * CompressionMaster class provides methods for compressing and decompressing strings. - */ -export class CompressionMaster { - /** - * Compresses a string using LZ-string compression algorithm. - * @param input - The string to compress. - * @returns The compressed string. - * @example - * const compressed = CompressionMaster.compress('Hello, world!'); - * console.log(compressed); // Compressed string - */ - static compress(input: string): string { - return LZString.compress(input); - } - - /** - * Decompresses a string using LZ-string compression algorithm. - * @param input - The compressed string to decompress. - * @returns The decompressed string. - * @example - * const decompressed = CompressionMaster.decompress(compressedString); - * console.log(decompressed); // 'Hello, world!' - */ - static decompress(input: string): string { - return LZString.decompress(input); - } -} diff --git a/src/index.ts b/src/index.ts index 753772b..87962d6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,4 @@ export { CasingMaster } from './case-master'; -export { CompressionMaster } from './compression-master'; export { ConversionMaster } from './conversion-master'; export { EmojiMaster } from './emoji-master'; export { EntropyMaster } from './entropy-master'; diff --git a/src/masking-master.ts b/src/masking-master.ts index 55fcb42..5811ed6 100644 --- a/src/masking-master.ts +++ b/src/masking-master.ts @@ -38,35 +38,6 @@ export class MaskingMaster { * const maskedSSN = MaskingMaster.maskSSN('123-45-6789'); * console.log(maskedSSN); // Output: '***-**-6789' */ - // static maskSSN(input: string): string { - // const length = input.length; - // const visibleLength = 4; - - // if (length <= visibleLength) { - // // If the length is less than or equal to the visible length, no masking is needed. - // return input; - // } - - // // Mask all characters except the last `visibleLength` characters. - // const maskedPart = '*'.repeat(length - visibleLength); - - // // Determine the number of characters in the masked part that should be preserved - // let result = ''; - - // for (let i = 0; i < length; i++) { - // if (i < maskedPart.length) { - // if (input[i] === '-' || input[i] === ' ') { - // result += input[i]; // Preserve delimiters - // } else { - // result += '*'; // Mask other characters - // } - // } else { - // result += input[i]; // Add visible part - // } - // } - - // return result; - // } static maskSSN(input: string): string { const length = input.length; const visibleLength = 4; diff --git a/test/compression-master.spec.ts b/test/compression-master.spec.ts deleted file mode 100644 index 2507b69..0000000 --- a/test/compression-master.spec.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { CompressionMaster } from '../src/compression-master'; - -describe('CompressionMaster', () => { - test('should compress and decompress strings correctly', () => { - const originalString = 'Hello, world!'; - const compressed = CompressionMaster.compress(originalString); - const decompressed = CompressionMaster.decompress(compressed); - - expect(decompressed).toBe(originalString); - }); - - test('should handle empty strings', () => { - const originalString = ''; - const compressed = CompressionMaster.compress(originalString); - const decompressed = CompressionMaster.decompress(compressed); - - expect(decompressed).toBe(originalString); - }); - - test('should handle strings with special characters', () => { - const originalString = 'Special characters: !@#$%^&*()_+[]{}|;:",.<>?/'; - const compressed = CompressionMaster.compress(originalString); - const decompressed = CompressionMaster.decompress(compressed); - - expect(decompressed).toBe(originalString); - }); - - test('should handle large strings', () => { - const originalString = 'A'.repeat(10000); // Large string of 10,000 characters - const compressed = CompressionMaster.compress(originalString); - const decompressed = CompressionMaster.decompress(compressed); - - expect(decompressed).toBe(originalString); - }); -}); diff --git a/test/index.spec.ts b/test/index.spec.ts index c1198cd..c9a61d6 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -1,6 +1,5 @@ import { CasingMaster, - CompressionMaster, ConversionMaster, EmojiMaster, EntropyMaster, @@ -24,12 +23,6 @@ describe('CasingMaster', () => { }); }); -describe('CompressionMaster', () => { - it('should be defined', () => { - expect(CompressionMaster).toBeDefined(); - }); -}); - describe('ConversionMaster', () => { it('should be defined', () => { expect(ConversionMaster).toBeDefined();