Merge 01c28f4f57 into 0b1b98f93e
				
					
				
			This commit is contained in:
		
						commit
						6471dc830e
					
				
							
								
								
									
										12
									
								
								components.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								components.d.ts
									
									
									
									
										vendored
									
									
								
							| @ -91,6 +91,7 @@ declare module '@vue/runtime-core' { | |||||||
|     IbanValidatorAndParser: typeof import('./src/tools/iban-validator-and-parser/iban-validator-and-parser.vue')['default'] |     IbanValidatorAndParser: typeof import('./src/tools/iban-validator-and-parser/iban-validator-and-parser.vue')['default'] | ||||||
|     'IconMdi:brushVariant': typeof import('~icons/mdi/brush-variant')['default'] |     'IconMdi:brushVariant': typeof import('~icons/mdi/brush-variant')['default'] | ||||||
|     'IconMdi:kettleSteamOutline': typeof import('~icons/mdi/kettle-steam-outline')['default'] |     'IconMdi:kettleSteamOutline': typeof import('~icons/mdi/kettle-steam-outline')['default'] | ||||||
|  |     IconMdiArrowDown: typeof import('~icons/mdi/arrow-down')['default'] | ||||||
|     IconMdiChevronDown: typeof import('~icons/mdi/chevron-down')['default'] |     IconMdiChevronDown: typeof import('~icons/mdi/chevron-down')['default'] | ||||||
|     IconMdiChevronRight: typeof import('~icons/mdi/chevron-right')['default'] |     IconMdiChevronRight: typeof import('~icons/mdi/chevron-right')['default'] | ||||||
|     IconMdiClose: typeof import('~icons/mdi/close')['default'] |     IconMdiClose: typeof import('~icons/mdi/close')['default'] | ||||||
| @ -131,17 +132,27 @@ declare module '@vue/runtime-core' { | |||||||
|     MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default'] |     MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default'] | ||||||
|     NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default'] |     NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default'] | ||||||
|     NCheckbox: typeof import('naive-ui')['NCheckbox'] |     NCheckbox: typeof import('naive-ui')['NCheckbox'] | ||||||
|  |     NCode: typeof import('naive-ui')['NCode'] | ||||||
|     NCollapseTransition: typeof import('naive-ui')['NCollapseTransition'] |     NCollapseTransition: typeof import('naive-ui')['NCollapseTransition'] | ||||||
|     NConfigProvider: typeof import('naive-ui')['NConfigProvider'] |     NConfigProvider: typeof import('naive-ui')['NConfigProvider'] | ||||||
|     NDivider: typeof import('naive-ui')['NDivider'] |     NDivider: typeof import('naive-ui')['NDivider'] | ||||||
|     NEllipsis: typeof import('naive-ui')['NEllipsis'] |     NEllipsis: typeof import('naive-ui')['NEllipsis'] | ||||||
|  |     NForm: typeof import('naive-ui')['NForm'] | ||||||
|  |     NFormItem: typeof import('naive-ui')['NFormItem'] | ||||||
|  |     NGi: typeof import('naive-ui')['NGi'] | ||||||
|  |     NGrid: typeof import('naive-ui')['NGrid'] | ||||||
|     NH1: typeof import('naive-ui')['NH1'] |     NH1: typeof import('naive-ui')['NH1'] | ||||||
|     NH3: typeof import('naive-ui')['NH3'] |     NH3: typeof import('naive-ui')['NH3'] | ||||||
|     NIcon: typeof import('naive-ui')['NIcon'] |     NIcon: typeof import('naive-ui')['NIcon'] | ||||||
|  |     NInputNumber: typeof import('naive-ui')['NInputNumber'] | ||||||
|     NLayout: typeof import('naive-ui')['NLayout'] |     NLayout: typeof import('naive-ui')['NLayout'] | ||||||
|     NLayoutSider: typeof import('naive-ui')['NLayoutSider'] |     NLayoutSider: typeof import('naive-ui')['NLayoutSider'] | ||||||
|     NMenu: typeof import('naive-ui')['NMenu'] |     NMenu: typeof import('naive-ui')['NMenu'] | ||||||
|  |     NScrollbar: typeof import('naive-ui')['NScrollbar'] | ||||||
|  |     NSlider: typeof import('naive-ui')['NSlider'] | ||||||
|     NSpace: typeof import('naive-ui')['NSpace'] |     NSpace: typeof import('naive-ui')['NSpace'] | ||||||
|  |     NSpin: typeof import('naive-ui')['NSpin'] | ||||||
|  |     NSwitch: typeof import('naive-ui')['NSwitch'] | ||||||
|     NTable: typeof import('naive-ui')['NTable'] |     NTable: typeof import('naive-ui')['NTable'] | ||||||
|     NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default'] |     NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default'] | ||||||
|     OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default'] |     OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default'] | ||||||
| @ -155,6 +166,7 @@ declare module '@vue/runtime-core' { | |||||||
|     RegexMemo: typeof import('./src/tools/regex-memo/regex-memo.vue')['default'] |     RegexMemo: typeof import('./src/tools/regex-memo/regex-memo.vue')['default'] | ||||||
|     'RegexMemo.content': typeof import('./src/tools/regex-memo/regex-memo.content.md')['default'] |     'RegexMemo.content': typeof import('./src/tools/regex-memo/regex-memo.content.md')['default'] | ||||||
|     RegexTester: typeof import('./src/tools/regex-tester/regex-tester.vue')['default'] |     RegexTester: typeof import('./src/tools/regex-tester/regex-tester.vue')['default'] | ||||||
|  |     RemoveDuplicateTextRows: typeof import('./src/tools/remove-duplicate-text-rows/remove-duplicate-text-rows.vue')['default'] | ||||||
|     ResultRow: typeof import('./src/tools/ipv4-range-expander/result-row.vue')['default'] |     ResultRow: typeof import('./src/tools/ipv4-range-expander/result-row.vue')['default'] | ||||||
|     RomanNumeralConverter: typeof import('./src/tools/roman-numeral-converter/roman-numeral-converter.vue')['default'] |     RomanNumeralConverter: typeof import('./src/tools/roman-numeral-converter/roman-numeral-converter.vue')['default'] | ||||||
|     RouterLink: typeof import('vue-router')['RouterLink'] |     RouterLink: typeof import('vue-router')['RouterLink'] | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| import { tool as base64FileConverter } from './base64-file-converter'; | import { tool as base64FileConverter } from './base64-file-converter'; | ||||||
| import { tool as base64StringConverter } from './base64-string-converter'; | import { tool as base64StringConverter } from './base64-string-converter'; | ||||||
| import { tool as basicAuthGenerator } from './basic-auth-generator'; | import { tool as basicAuthGenerator } from './basic-auth-generator'; | ||||||
|  | import { tool as removeDuplicateTextRows } from './remove-duplicate-text-rows'; | ||||||
| import { tool as emailNormalizer } from './email-normalizer'; | import { tool as emailNormalizer } from './email-normalizer'; | ||||||
| 
 | 
 | ||||||
| import { tool as asciiTextDrawer } from './ascii-text-drawer'; | import { tool as asciiTextDrawer } from './ascii-text-drawer'; | ||||||
| @ -184,6 +185,7 @@ export const toolsByCategory: ToolCategory[] = [ | |||||||
|       textDiff, |       textDiff, | ||||||
|       numeronymGenerator, |       numeronymGenerator, | ||||||
|       asciiTextDrawer, |       asciiTextDrawer, | ||||||
|  |       removeDuplicateTextRows, | ||||||
|     ], |     ], | ||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|  | |||||||
							
								
								
									
										12
									
								
								src/tools/remove-duplicate-text-rows/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/tools/remove-duplicate-text-rows/index.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | |||||||
|  | import { Copy } from '@vicons/tabler'; | ||||||
|  | import { defineTool } from '../tool'; | ||||||
|  | 
 | ||||||
|  | export const tool = defineTool({ | ||||||
|  |   name: 'Remove duplicate text', | ||||||
|  |   path: '/remove-duplicate-text', | ||||||
|  |   description: 'Remove duplicate rows from a list of text rows.', | ||||||
|  |   keywords: ['remove', 'duplicate', 'text', 'rows', 'delete', 'unique', 'distinct'], | ||||||
|  |   component: () => import('./remove-duplicate-text-rows.vue'), | ||||||
|  |   icon: Copy, | ||||||
|  |   createdAt: new Date('2024-10-01'), | ||||||
|  | }); | ||||||
| @ -0,0 +1,106 @@ | |||||||
|  | <script setup lang="ts"> | ||||||
|  | enum Sort { | ||||||
|  |   OriginalOrder = 'original', | ||||||
|  |   InOrder = 'inorder', | ||||||
|  |   ReverseOrder = 'reverse', | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | const input = ref(''); | ||||||
|  | const output = ref(''); | ||||||
|  | const duplicates = ref(''); | ||||||
|  | const is_case_sense = ref(false); | ||||||
|  | const is_trim_spaces = ref(false); | ||||||
|  | const sorting = ref(Sort.OriginalOrder); | ||||||
|  | 
 | ||||||
|  | const sortingOptions = [ | ||||||
|  |   { label: 'Original', value: Sort.OriginalOrder }, | ||||||
|  |   { label: 'In Order', value: Sort.InOrder }, | ||||||
|  |   { label: 'Reverse', value: Sort.ReverseOrder }, | ||||||
|  | ]; | ||||||
|  | 
 | ||||||
|  | watchEffect(() => { | ||||||
|  |   const lines = input.value.split('\n'); | ||||||
|  |   const duplicatesMap = new Map<string, number>(); | ||||||
|  |   const uniquesMap = new Map<string, number>(); | ||||||
|  | 
 | ||||||
|  |   for (let line of lines) { | ||||||
|  |     if (is_trim_spaces.value) { | ||||||
|  |       line = line.trim(); | ||||||
|  |     } | ||||||
|  |     if (is_case_sense.value) { | ||||||
|  |       line = line.toLowerCase(); | ||||||
|  |     } | ||||||
|  |     if (duplicatesMap.has(line)) { | ||||||
|  |       duplicatesMap.set(line, duplicatesMap.get(line)! + 1); | ||||||
|  |     } | ||||||
|  |     else { | ||||||
|  |       duplicatesMap.set(line, 1); | ||||||
|  |       uniquesMap.set(line, 1); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   const sortedLines = [...uniquesMap.keys()].sort((a, b) => { | ||||||
|  |     switch (sorting.value) { | ||||||
|  |       case Sort.InOrder: | ||||||
|  |         return a.localeCompare(b); | ||||||
|  |       case Sort.ReverseOrder: | ||||||
|  |         return b.localeCompare(a); | ||||||
|  |       default: | ||||||
|  |         return 0; | ||||||
|  |     } | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   output.value = sortedLines.join('\n'); | ||||||
|  |   duplicates.value = [...duplicatesMap.entries()] | ||||||
|  |     .filter(([_, count]) => count > 1) | ||||||
|  |     .sort((a, b) => b[1] - a[1]) | ||||||
|  |     .map(([line, count]) => `${line} (${count})`) | ||||||
|  |     .join('\n'); | ||||||
|  | }); | ||||||
|  | </script> | ||||||
|  | 
 | ||||||
|  | <template> | ||||||
|  |   <c-card style="max-width: 600px"> | ||||||
|  |     <c-input-text | ||||||
|  |       v-model:value="input" | ||||||
|  |       label="Your text:" | ||||||
|  |       placeholder="Seperate rows by a break" | ||||||
|  |       raw-text | ||||||
|  |       multiline | ||||||
|  |       rows="10" | ||||||
|  |     /> | ||||||
|  | 
 | ||||||
|  |     <n-divider /> | ||||||
|  | 
 | ||||||
|  |     <n-form flex style="flex-direction: column; gap: 6px" label-placement="left"> | ||||||
|  |       <n-form-item flex label="Case Sensitive"> | ||||||
|  |         <n-switch v-model:value="is_case_sense" /> | ||||||
|  |       </n-form-item> | ||||||
|  | 
 | ||||||
|  |       <n-form-item flex label="Trim Spaces"> | ||||||
|  |         <n-switch v-model:value="is_trim_spaces" /> | ||||||
|  |       </n-form-item> | ||||||
|  | 
 | ||||||
|  |       <n-form-item flex label="Sorting"> | ||||||
|  |         <c-buttons-select v-model:value="sorting" :options="sortingOptions" /> | ||||||
|  |       </n-form-item> | ||||||
|  |     </n-form> | ||||||
|  | 
 | ||||||
|  |     <n-divider /> | ||||||
|  | 
 | ||||||
|  |     <n-form-item label="Unique text:"> | ||||||
|  |       <TextareaCopyable | ||||||
|  |         :value="output" | ||||||
|  |         mb-1 mt-1 | ||||||
|  |         copy-placement="outside" | ||||||
|  |       /> | ||||||
|  |     </n-form-item> | ||||||
|  |     <n-form-item label="Duplicates:"> | ||||||
|  |       <TextareaCopyable | ||||||
|  |         :value="duplicates" | ||||||
|  |         mb-1 mt-1 | ||||||
|  |         copy-placement="outside" | ||||||
|  |       /> | ||||||
|  |     </n-form-item> | ||||||
|  |   </c-card> | ||||||
|  | </template> | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user