aboutsummaryrefslogtreecommitdiff
path: root/src/tools/text-statistics/text-statistics.vue
blob: 335a5e1dbc457966b8597ab0a1726ea7c459197f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<template>
  <n-card>
    <n-input
      v-model:value="text"
      type="textarea"
      placeholder="Your text..."
      rows="5"
    />
    <br>
    <br>
    <n-space justify="space-around">
      <n-statistic
        label="Character count"
        :value="text.length"
      />
      <n-statistic
        label="Word count"
        :value="text.split(/\s+/).length"
      />
      <n-statistic
        label="Line count"
        :value="text.split(/\r\n|\r|\n/).length"
      />
      <n-statistic
        label="Byte size"
        :value="formatBytes(getStringSizeInBytes(text))"
      />
    </n-space>
  </n-card>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { formatBytes } from '@/utils/convert'
import { getStringSizeInBytes } from './text-statistics.service'

const text = ref('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Commodo risus faucibus varius volutpat habitasse suspendisse justo inceptos primis mi. Fusce molestie lorem bibendum habitasse litora adipiscing turpis egestas quis nec. Non id conubia vulputate etiam iaculis vitae venenatis hac fusce condimentum. Adipiscing pellentesque venenatis ornare pulvinar tempus hac montes velit erat convallis.')
</script>