mirror of
https://github.com/sharevb/it-tools.git
synced 2026-12-02 09:42:10 +03:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6cb108ae4 | ||
|
|
1cf54a84a4 | ||
|
|
af1013da36 | ||
|
|
2d87aaf484 |
No files matched your search
Vendored
+8
-2
@@ -132,15 +132,22 @@ declare module '@vue/runtime-core' {
|
|||||||
NCode: typeof import('naive-ui')['NCode']
|
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']
|
|
||||||
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
||||||
|
NForm: typeof import('naive-ui')['NForm']
|
||||||
|
NFormItem: typeof import('naive-ui')['NFormItem']
|
||||||
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']
|
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||||
|
NSpace: typeof import('naive-ui')['NSpace']
|
||||||
|
NSpin: typeof import('naive-ui')['NSpin']
|
||||||
|
NStatistic: typeof import('naive-ui')['NStatistic']
|
||||||
|
NSlider: typeof import('naive-ui')['NSlider']
|
||||||
|
NSwitch: typeof import('naive-ui')['NSwitch']
|
||||||
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']
|
||||||
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
|
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
|
||||||
@@ -148,7 +155,6 @@ declare module '@vue/runtime-core' {
|
|||||||
PdfSignatureDetails: typeof import('./src/tools/pdf-signature-checker/components/pdf-signature-details.vue')['default']
|
PdfSignatureDetails: typeof import('./src/tools/pdf-signature-checker/components/pdf-signature-details.vue')['default']
|
||||||
PercentageCalculator: typeof import('./src/tools/percentage-calculator/percentage-calculator.vue')['default']
|
PercentageCalculator: typeof import('./src/tools/percentage-calculator/percentage-calculator.vue')['default']
|
||||||
PhoneParserAndFormatter: typeof import('./src/tools/phone-parser-and-formatter/phone-parser-and-formatter.vue')['default']
|
PhoneParserAndFormatter: typeof import('./src/tools/phone-parser-and-formatter/phone-parser-and-formatter.vue')['default']
|
||||||
PunycodeConverter: typeof import('./src/tools/punycode-converter/punycode-converter.vue')['default']
|
|
||||||
QrCodeGenerator: typeof import('./src/tools/qr-code-generator/qr-code-generator.vue')['default']
|
QrCodeGenerator: typeof import('./src/tools/qr-code-generator/qr-code-generator.vue')['default']
|
||||||
RandomPortGenerator: typeof import('./src/tools/random-port-generator/random-port-generator.vue')['default']
|
RandomPortGenerator: typeof import('./src/tools/random-port-generator/random-port-generator.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']
|
||||||
|
|||||||
@@ -42,7 +42,6 @@
|
|||||||
"@tiptap/starter-kit": "2.1.6",
|
"@tiptap/starter-kit": "2.1.6",
|
||||||
"@tiptap/vue-3": "2.0.3",
|
"@tiptap/vue-3": "2.0.3",
|
||||||
"@types/figlet": "^1.5.8",
|
"@types/figlet": "^1.5.8",
|
||||||
"@types/punycode": "^2.1.4",
|
|
||||||
"@vicons/material": "^0.12.0",
|
"@vicons/material": "^0.12.0",
|
||||||
"@vicons/tabler": "^0.12.0",
|
"@vicons/tabler": "^0.12.0",
|
||||||
"@vueuse/core": "^10.3.0",
|
"@vueuse/core": "^10.3.0",
|
||||||
@@ -82,7 +81,6 @@
|
|||||||
"pdf-signature-reader": "^1.4.2",
|
"pdf-signature-reader": "^1.4.2",
|
||||||
"pinia": "^2.0.34",
|
"pinia": "^2.0.34",
|
||||||
"plausible-tracker": "^0.3.8",
|
"plausible-tracker": "^0.3.8",
|
||||||
"punycode": "^2.3.1",
|
|
||||||
"qrcode": "^1.5.1",
|
"qrcode": "^1.5.1",
|
||||||
"sql-formatter": "^13.0.0",
|
"sql-formatter": "^13.0.0",
|
||||||
"ua-parser-js": "^1.0.35",
|
"ua-parser-js": "^1.0.35",
|
||||||
|
|||||||
Generated
+16
-20
@@ -26,9 +26,6 @@ dependencies:
|
|||||||
'@types/figlet':
|
'@types/figlet':
|
||||||
specifier: ^1.5.8
|
specifier: ^1.5.8
|
||||||
version: 1.5.8
|
version: 1.5.8
|
||||||
'@types/punycode':
|
|
||||||
specifier: ^2.1.4
|
|
||||||
version: 2.1.4
|
|
||||||
'@vicons/material':
|
'@vicons/material':
|
||||||
specifier: ^0.12.0
|
specifier: ^0.12.0
|
||||||
version: 0.12.0
|
version: 0.12.0
|
||||||
@@ -146,9 +143,6 @@ dependencies:
|
|||||||
plausible-tracker:
|
plausible-tracker:
|
||||||
specifier: ^0.3.8
|
specifier: ^0.3.8
|
||||||
version: 0.3.8
|
version: 0.3.8
|
||||||
punycode:
|
|
||||||
specifier: ^2.3.1
|
|
||||||
version: 2.3.1
|
|
||||||
qrcode:
|
qrcode:
|
||||||
specifier: ^1.5.1
|
specifier: ^1.5.1
|
||||||
version: 1.5.1
|
version: 1.5.1
|
||||||
@@ -3038,10 +3032,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-ZREFYlpUmPQJ0esjxoG1fMvB2HNaD3z+mjqdSosZvd3RalncI9NEur73P8ZJz4YQdL64CmV1w0RuqoRUlhQRBw==}
|
resolution: {integrity: sha512-ZREFYlpUmPQJ0esjxoG1fMvB2HNaD3z+mjqdSosZvd3RalncI9NEur73P8ZJz4YQdL64CmV1w0RuqoRUlhQRBw==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@types/punycode@2.1.4:
|
|
||||||
resolution: {integrity: sha512-trzh6NzBnq8yw5e35f8xe8VTYjqM3NE7bohBtvDVf/dtUer3zYTLK1Ka3DG3p7bdtoaOHZucma6FfVKlQ134pQ==}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/@types/qrcode@1.5.0:
|
/@types/qrcode@1.5.0:
|
||||||
resolution: {integrity: sha512-x5ilHXRxUPIMfjtM+1vf/GPTRWZ81nqscursm5gMznJeK9M0YnZ1c3bEvRLQ0zSSgedLx1J6MGL231ObQGGhaA==}
|
resolution: {integrity: sha512-x5ilHXRxUPIMfjtM+1vf/GPTRWZ81nqscursm5gMznJeK9M0YnZ1c3bEvRLQ0zSSgedLx1J6MGL231ObQGGhaA==}
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -3370,7 +3360,7 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@unhead/dom': 0.5.1
|
'@unhead/dom': 0.5.1
|
||||||
'@unhead/schema': 0.5.1
|
'@unhead/schema': 0.5.1
|
||||||
'@vueuse/shared': 11.0.3(vue@3.3.4)
|
'@vueuse/shared': 10.11.1(vue@3.3.4)
|
||||||
unhead: 0.5.1
|
unhead: 0.5.1
|
||||||
vue: 3.3.4
|
vue: 3.3.4
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
@@ -4003,19 +3993,19 @@ packages:
|
|||||||
- vue
|
- vue
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@vueuse/shared@10.3.0(vue@3.3.4):
|
/@vueuse/shared@10.11.1(vue@3.3.4):
|
||||||
resolution: {integrity: sha512-kGqCTEuFPMK4+fNWy6dUOiYmxGcUbtznMwBZLC1PubidF4VZY05B+Oht7Jh7/6x4VOWGpvu3R37WHi81cKpiqg==}
|
resolution: {integrity: sha512-LHpC8711VFZlDaYUXEBbFBCQ7GS3dVU9mjOhhMhXP6txTV4EhYQg/KGnQuvt/sPAtoUKq7VVUnL6mVtFoL42sA==}
|
||||||
dependencies:
|
dependencies:
|
||||||
vue-demi: 0.14.5(vue@3.3.4)
|
vue-demi: 0.14.10(vue@3.3.4)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- '@vue/composition-api'
|
- '@vue/composition-api'
|
||||||
- vue
|
- vue
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@vueuse/shared@11.0.3(vue@3.3.4):
|
/@vueuse/shared@10.3.0(vue@3.3.4):
|
||||||
resolution: {integrity: sha512-0rY2m6HS5t27n/Vp5cTDsKTlNnimCqsbh/fmT2LgE+aaU42EMfXo8+bNX91W9I7DDmxfuACXMmrd7d79JxkqWA==}
|
resolution: {integrity: sha512-kGqCTEuFPMK4+fNWy6dUOiYmxGcUbtznMwBZLC1PubidF4VZY05B+Oht7Jh7/6x4VOWGpvu3R37WHi81cKpiqg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
vue-demi: 0.14.10(vue@3.3.4)
|
vue-demi: 0.14.5(vue@3.3.4)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- '@vue/composition-api'
|
- '@vue/composition-api'
|
||||||
- vue
|
- vue
|
||||||
@@ -7692,9 +7682,15 @@ packages:
|
|||||||
resolution: {integrity: sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==}
|
resolution: {integrity: sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/punycode@2.3.0:
|
||||||
|
resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==}
|
||||||
|
engines: {node: '>=6'}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/punycode@2.3.1:
|
/punycode@2.3.1:
|
||||||
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
|
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/qrcode@1.5.1:
|
/qrcode@1.5.1:
|
||||||
resolution: {integrity: sha512-nS8NJ1Z3md8uTjKtP+SGGhfqmTCs5flU/xR623oI0JX+Wepz9R8UrRVCTBTJm3qGw3rH6jJ6MUHjkDx15cxSSg==}
|
resolution: {integrity: sha512-nS8NJ1Z3md8uTjKtP+SGGhfqmTCs5flU/xR623oI0JX+Wepz9R8UrRVCTBTJm3qGw3rH6jJ6MUHjkDx15cxSSg==}
|
||||||
@@ -8484,7 +8480,7 @@ packages:
|
|||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
dependencies:
|
dependencies:
|
||||||
psl: 1.9.0
|
psl: 1.9.0
|
||||||
punycode: 2.3.1
|
punycode: 2.3.0
|
||||||
universalify: 0.2.0
|
universalify: 0.2.0
|
||||||
url-parse: 1.5.10
|
url-parse: 1.5.10
|
||||||
dev: true
|
dev: true
|
||||||
@@ -8499,7 +8495,7 @@ packages:
|
|||||||
resolution: {integrity: sha512-2lv/66T7e5yNyhAAC4NaKe5nVavzuGJQVVtRYLyQ2OI8tsJ61PMLlelehb0wi2Hx6+hT/OJUWZcw8MjlSRnxvw==}
|
resolution: {integrity: sha512-2lv/66T7e5yNyhAAC4NaKe5nVavzuGJQVVtRYLyQ2OI8tsJ61PMLlelehb0wi2Hx6+hT/OJUWZcw8MjlSRnxvw==}
|
||||||
engines: {node: '>=14'}
|
engines: {node: '>=14'}
|
||||||
dependencies:
|
dependencies:
|
||||||
punycode: 2.3.1
|
punycode: 2.3.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/treemate@0.3.11:
|
/treemate@0.3.11:
|
||||||
@@ -8939,7 +8935,7 @@ packages:
|
|||||||
/uri-js@4.4.1:
|
/uri-js@4.4.1:
|
||||||
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
|
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
punycode: 2.3.1
|
punycode: 2.3.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/url-parse@1.5.10:
|
/url-parse@1.5.10:
|
||||||
|
|||||||
+1
-11
@@ -2,7 +2,6 @@ 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 emailNormalizer } from './email-normalizer';
|
import { tool as emailNormalizer } from './email-normalizer';
|
||||||
import { tool as punycodeConverter } from './punycode-converter';
|
|
||||||
|
|
||||||
import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
||||||
|
|
||||||
@@ -159,16 +158,7 @@ export const toolsByCategory: ToolCategory[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Network',
|
name: 'Network',
|
||||||
components: [
|
components: [ipv4SubnetCalculator, ipv4AddressConverter, ipv4RangeExpander, macAddressLookup, macAddressGenerator, ipv6UlaGenerator],
|
||||||
ipv4SubnetCalculator,
|
|
||||||
ipv4AddressConverter,
|
|
||||||
// ipv6AddressConverter,
|
|
||||||
ipv4RangeExpander,
|
|
||||||
macAddressLookup,
|
|
||||||
macAddressGenerator,
|
|
||||||
ipv6UlaGenerator,
|
|
||||||
punycodeConverter,
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Math',
|
name: 'Math',
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
import { World } from '@vicons/tabler';
|
|
||||||
import { defineTool } from '../tool';
|
|
||||||
|
|
||||||
export const tool = defineTool({
|
|
||||||
name: 'Punycode Converter',
|
|
||||||
path: '/punycode-converter',
|
|
||||||
description: 'Convert international unicode domain names or emails from/to ASCII Punycode version',
|
|
||||||
keywords: ['punycode', 'converter', 'rfc3492', 'bootstring', 'domain', 'dns'],
|
|
||||||
component: () => import('./punycode-converter.vue'),
|
|
||||||
icon: World,
|
|
||||||
createdAt: new Date('2024-08-15'),
|
|
||||||
});
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { toASCII, toUnicode } from 'punycode/';
|
|
||||||
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
|
||||||
|
|
||||||
const punycodeInput = ref('');
|
|
||||||
const intlOutput = computed(
|
|
||||||
() => {
|
|
||||||
try {
|
|
||||||
return toUnicode(punycodeInput.value?.trim());
|
|
||||||
}
|
|
||||||
catch (e: any) {
|
|
||||||
return e.toString();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
const intlInput = ref('');
|
|
||||||
const punycodeOutput = computed(
|
|
||||||
() => {
|
|
||||||
try {
|
|
||||||
return toASCII(intlInput.value?.trim());
|
|
||||||
}
|
|
||||||
catch (e: any) {
|
|
||||||
return e.toString();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div max-w-600>
|
|
||||||
<c-card title="Punycode to International">
|
|
||||||
<c-input-text
|
|
||||||
v-model:value="punycodeInput"
|
|
||||||
placeholder="Put your punycode domain name or email to decode..."
|
|
||||||
label="Punycode Domain name/Email"
|
|
||||||
raw-text
|
|
||||||
/>
|
|
||||||
|
|
||||||
<n-divider />
|
|
||||||
|
|
||||||
<TextareaCopyable
|
|
||||||
label="Decoded Domain name/Email"
|
|
||||||
:value="intlOutput"
|
|
||||||
readonly
|
|
||||||
/>
|
|
||||||
</c-card>
|
|
||||||
|
|
||||||
<c-card title="International to Punycode" mt-5>
|
|
||||||
<c-input-text
|
|
||||||
v-model:value="intlInput"
|
|
||||||
placeholder="Put your international domain or email name here..."
|
|
||||||
label="Domain name or email to encode"
|
|
||||||
raw-text
|
|
||||||
/>
|
|
||||||
|
|
||||||
<n-divider />
|
|
||||||
|
|
||||||
<TextareaCopyable
|
|
||||||
label="Punycode Domain name/Email"
|
|
||||||
:value="punycodeOutput"
|
|
||||||
readonly
|
|
||||||
/>
|
|
||||||
</c-card>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
import { getStringSizeInBytes } from './text-statistics.service';
|
import { getStringSizeInBytes, textStatistics } from './text-statistics.service';
|
||||||
|
|
||||||
describe('text-statistics', () => {
|
describe('text-statistics', () => {
|
||||||
describe('getStringSizeInBytes', () => {
|
describe('getStringSizeInBytes', () => {
|
||||||
@@ -11,4 +11,155 @@ describe('text-statistics', () => {
|
|||||||
expect(getStringSizeInBytes('aaaaaaaaaa')).toEqual(10);
|
expect(getStringSizeInBytes('aaaaaaaaaa')).toEqual(10);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('textStatistics', () => {
|
||||||
|
it('should return text statistics', () => {
|
||||||
|
expect(textStatistics('a')).to.deep.eq({
|
||||||
|
chars: 1,
|
||||||
|
chars_digits: 0,
|
||||||
|
chars_lower: 1,
|
||||||
|
chars_no_spaces: 1,
|
||||||
|
chars_puncts: 0,
|
||||||
|
chars_spaces: 0,
|
||||||
|
chars_upper: 0,
|
||||||
|
lines: 1,
|
||||||
|
sentences: 1,
|
||||||
|
words: 1,
|
||||||
|
words_no_puncs: 1,
|
||||||
|
read_time: 0.3,
|
||||||
|
words_uniques: 1,
|
||||||
|
words_uniques_ci: 1,
|
||||||
|
});
|
||||||
|
expect(textStatistics('A')).to.deep.eq({
|
||||||
|
chars: 1,
|
||||||
|
chars_digits: 0,
|
||||||
|
chars_lower: 0,
|
||||||
|
chars_no_spaces: 1,
|
||||||
|
chars_puncts: 0,
|
||||||
|
chars_spaces: 0,
|
||||||
|
chars_upper: 1,
|
||||||
|
lines: 1,
|
||||||
|
sentences: 1,
|
||||||
|
words: 1,
|
||||||
|
words_no_puncs: 1,
|
||||||
|
read_time: 0.3,
|
||||||
|
words_uniques: 1,
|
||||||
|
words_uniques_ci: 1,
|
||||||
|
});
|
||||||
|
expect(textStatistics('a a')).to.deep.eq({
|
||||||
|
chars: 3,
|
||||||
|
chars_digits: 0,
|
||||||
|
chars_lower: 2,
|
||||||
|
chars_no_spaces: 2,
|
||||||
|
chars_puncts: 0,
|
||||||
|
chars_spaces: 1,
|
||||||
|
chars_upper: 0,
|
||||||
|
lines: 1,
|
||||||
|
sentences: 1,
|
||||||
|
words: 2,
|
||||||
|
words_no_puncs: 2,
|
||||||
|
read_time: 0.6,
|
||||||
|
words_uniques: 1,
|
||||||
|
words_uniques_ci: 1,
|
||||||
|
});
|
||||||
|
expect(textStatistics('A a ; 1')).to.deep.eq({
|
||||||
|
chars: 7,
|
||||||
|
chars_digits: 1,
|
||||||
|
chars_lower: 1,
|
||||||
|
chars_no_spaces: 4,
|
||||||
|
chars_puncts: 1,
|
||||||
|
chars_spaces: 3,
|
||||||
|
chars_upper: 1,
|
||||||
|
lines: 1,
|
||||||
|
sentences: 1,
|
||||||
|
words: 4,
|
||||||
|
words_no_puncs: 3,
|
||||||
|
read_time: 0.8999999999999999,
|
||||||
|
words_uniques: 3,
|
||||||
|
words_uniques_ci: 2,
|
||||||
|
});
|
||||||
|
expect(textStatistics('Some sentence! Une autre phrase ? « et avec des chiffres 1234 ! »')).to.deep.eq({
|
||||||
|
chars: 65,
|
||||||
|
chars_digits: 4,
|
||||||
|
chars_lower: 41,
|
||||||
|
chars_no_spaces: 52,
|
||||||
|
chars_puncts: 5,
|
||||||
|
chars_spaces: 13,
|
||||||
|
chars_upper: 2,
|
||||||
|
lines: 1,
|
||||||
|
sentences: 3,
|
||||||
|
words: 14,
|
||||||
|
words_no_puncs: 10,
|
||||||
|
read_time: 3,
|
||||||
|
words_uniques: 10,
|
||||||
|
words_uniques_ci: 10,
|
||||||
|
});
|
||||||
|
expect(textStatistics(`Some sentence! Une autre phrase ?
|
||||||
|
« et avec des chiffres 1234 ! »`)).to.deep.eq({
|
||||||
|
chars: 72,
|
||||||
|
chars_digits: 4,
|
||||||
|
chars_lower: 41,
|
||||||
|
chars_no_spaces: 52,
|
||||||
|
chars_puncts: 5,
|
||||||
|
chars_spaces: 20,
|
||||||
|
chars_upper: 2,
|
||||||
|
lines: 2,
|
||||||
|
sentences: 3,
|
||||||
|
words: 14,
|
||||||
|
words_no_puncs: 10,
|
||||||
|
read_time: 3,
|
||||||
|
words_uniques: 10,
|
||||||
|
words_uniques_ci: 10,
|
||||||
|
});
|
||||||
|
expect(textStatistics('12 35')).to.deep.eq({
|
||||||
|
chars: 5,
|
||||||
|
chars_digits: 4,
|
||||||
|
chars_lower: 0,
|
||||||
|
chars_no_spaces: 4,
|
||||||
|
chars_puncts: 0,
|
||||||
|
chars_spaces: 1,
|
||||||
|
chars_upper: 0,
|
||||||
|
lines: 1,
|
||||||
|
sentences: 1,
|
||||||
|
words: 2,
|
||||||
|
words_no_puncs: 2,
|
||||||
|
read_time: 0.6,
|
||||||
|
words_uniques: 2,
|
||||||
|
words_uniques_ci: 2,
|
||||||
|
});
|
||||||
|
expect(textStatistics(' 1 2 3. Other ')).to.deep.eq({
|
||||||
|
chars: 14,
|
||||||
|
chars_digits: 3,
|
||||||
|
chars_lower: 4,
|
||||||
|
chars_no_spaces: 9,
|
||||||
|
chars_puncts: 1,
|
||||||
|
chars_spaces: 5,
|
||||||
|
chars_upper: 1,
|
||||||
|
lines: 1,
|
||||||
|
sentences: 2,
|
||||||
|
words: 4,
|
||||||
|
words_no_puncs: 4,
|
||||||
|
read_time: 1.2,
|
||||||
|
words_uniques: 4,
|
||||||
|
words_uniques_ci: 4,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(textStatistics('Az az er')).to.deep.eq({
|
||||||
|
chars: 8,
|
||||||
|
chars_digits: 0,
|
||||||
|
chars_lower: 5,
|
||||||
|
chars_no_spaces: 6,
|
||||||
|
chars_puncts: 0,
|
||||||
|
chars_spaces: 2,
|
||||||
|
chars_upper: 1,
|
||||||
|
lines: 1,
|
||||||
|
read_time: 0.8999999999999999,
|
||||||
|
sentences: 1,
|
||||||
|
words: 3,
|
||||||
|
words_no_puncs: 3,
|
||||||
|
words_uniques: 3,
|
||||||
|
words_uniques_ci: 2,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@@ -1,3 +1,24 @@
|
|||||||
export function getStringSizeInBytes(text: string) {
|
export function getStringSizeInBytes(text: string) {
|
||||||
return new TextEncoder().encode(text).buffer.byteLength;
|
return new TextEncoder().encode(text).buffer.byteLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function textStatistics(text: string) {
|
||||||
|
const words_no_puncts = text.replace(/\p{P}/ug, '').trim().split(/\s+/);
|
||||||
|
const read_word_per_minutes = 200;
|
||||||
|
return {
|
||||||
|
chars: text.length,
|
||||||
|
chars_no_spaces: text.replace(/\s+/ug, '').length,
|
||||||
|
chars_upper: text.replace(/[^\p{Lu}]/ug, '').length,
|
||||||
|
chars_lower: text.replace(/[^\p{Ll}]/ug, '').length,
|
||||||
|
chars_digits: text.replace(/\D+/ug, '').length,
|
||||||
|
chars_puncts: text.replace(/[^\p{P}]/ug, '').length,
|
||||||
|
chars_spaces: text.replace(/\S/ug, '').length,
|
||||||
|
words: text.trim().split(/\s+/).length,
|
||||||
|
read_time: words_no_puncts.length / read_word_per_minutes * 60,
|
||||||
|
words_no_puncs: words_no_puncts.length,
|
||||||
|
words_uniques: (new Set(words_no_puncts)).size,
|
||||||
|
words_uniques_ci: (new Set(words_no_puncts.map(s => s.toLowerCase()))).size,
|
||||||
|
sentences: (`${text} `).split(/\w\s*[\.!\?][\s\p{P}]*\s/u).filter(s => s && s?.length > 0).length,
|
||||||
|
lines: text.split(/\r\n|\r|\n/).length,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,19 +1,42 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getStringSizeInBytes } from './text-statistics.service';
|
import { formatMsDuration } from '../eta-calculator/eta-calculator.service';
|
||||||
|
import { getStringSizeInBytes, textStatistics } from './text-statistics.service';
|
||||||
import { formatBytes } from '@/utils/convert';
|
import { formatBytes } from '@/utils/convert';
|
||||||
|
|
||||||
const text = ref('');
|
const text = ref('');
|
||||||
|
const stats = computed(() => textStatistics(text.value));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<c-card>
|
<c-card>
|
||||||
<c-input-text v-model:value="text" multiline placeholder="Your text..." rows="5" />
|
<c-input-text v-model:value="text" multiline placeholder="Your text..." rows="5" />
|
||||||
|
|
||||||
<div mt-5 flex>
|
<n-space mt-3>
|
||||||
<n-statistic label="Character count" :value="text.length" flex-1 />
|
<n-statistic label="Character count" :value="stats.chars" />
|
||||||
<n-statistic label="Word count" :value="text === '' ? 0 : text.split(/\s+/).length" flex-1 />
|
<n-statistic label="Word count" :value="stats.words" />
|
||||||
<n-statistic label="Line count" :value="text === '' ? 0 : text.split(/\r\n|\r|\n/).length" flex-1 />
|
<n-statistic label="Sentences count" :value="stats.sentences" />
|
||||||
<n-statistic label="Byte size" :value="formatBytes(getStringSizeInBytes(text))" flex-1 />
|
<n-statistic label="Line count" :value="stats.lines" />
|
||||||
</div>
|
<n-statistic label="Byte size" :value="formatBytes(getStringSizeInBytes(text))" />
|
||||||
|
</n-space>
|
||||||
|
|
||||||
|
<n-divider />
|
||||||
|
|
||||||
|
<n-space mt-3>
|
||||||
|
<n-statistic label="Unique Word count" :value="stats.words_uniques" />
|
||||||
|
<n-statistic label="Unique Word count (case insensitive)" :value="stats.words_uniques_ci" />
|
||||||
|
<n-statistic label="Read Time" :value="formatMsDuration(stats.read_time * 1000)" />
|
||||||
|
</n-space>
|
||||||
|
|
||||||
|
<n-divider />
|
||||||
|
|
||||||
|
<n-space>
|
||||||
|
<n-statistic label="Chars (no spaces)" :value="stats.chars_no_spaces" />
|
||||||
|
<n-statistic label="Uppercase chars" :value="stats.chars_upper" />
|
||||||
|
<n-statistic label="Lowercase chars" :value="stats.chars_lower" />
|
||||||
|
<n-statistic label="Digit chars" :value="stats.chars_digits" />
|
||||||
|
<n-statistic label="Punctuations" :value="stats.chars_puncts" />
|
||||||
|
<n-statistic label="Spaces chars" :value="stats.chars_spaces" />
|
||||||
|
<n-statistic label="Word count (no punct)" :value="stats.words_no_puncs" />
|
||||||
|
</n-space>
|
||||||
</c-card>
|
</c-card>
|
||||||
</template>
|
</template>
|
||||||
Reference in new issue
Block a user