mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-22 05:51:44 +03:00
1 parent
ac08813407
commit
e6cbe0884d
1 file changed
+2
-2
@@ -3,7 +3,7 @@ export function getStringSizeInBytes(text: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function textStatistics(text: string) {
|
export function textStatistics(text: string) {
|
||||||
const words_no_puncts = text.replace(/\p{P}/ug, '').trim().split(/\s+/);
|
const words_no_puncts = text.replace(/\p{P}/ug, '').trim().split(/\s+/).filter(Boolean);
|
||||||
const read_word_per_minutes = 200;
|
const read_word_per_minutes = 200;
|
||||||
return {
|
return {
|
||||||
chars: text.length,
|
chars: text.length,
|
||||||
@@ -13,7 +13,7 @@ export function textStatistics(text: string) {
|
|||||||
chars_digits: text.replace(/\D+/ug, '').length,
|
chars_digits: text.replace(/\D+/ug, '').length,
|
||||||
chars_puncts: text.replace(/[^\p{P}]/ug, '').length,
|
chars_puncts: text.replace(/[^\p{P}]/ug, '').length,
|
||||||
chars_spaces: text.replace(/\S/ug, '').length,
|
chars_spaces: text.replace(/\S/ug, '').length,
|
||||||
words: text.trim().split(/\s+/).length,
|
words: text.trim().split(/\s+/).filter(Boolean).length,
|
||||||
read_time: words_no_puncts.length / read_word_per_minutes * 60,
|
read_time: words_no_puncts.length / read_word_per_minutes * 60,
|
||||||
words_no_puncs: words_no_puncts.length,
|
words_no_puncs: words_no_puncts.length,
|
||||||
words_uniques: (new Set(words_no_puncts)).size,
|
words_uniques: (new Set(words_no_puncts)).size,
|
||||||
|
|||||||
Reference in new issue
Block a user