1
0
silverbullet/plugs/core/word_count_command.ts
2022-04-01 17:07:08 +02:00

10 lines
269 B
TypeScript

function countWords(str: string): number {
const matches = str.match(/[\w\d\'-]+/gi);
return matches ? matches.length : 0;
}
function readingTime(wordCount: number): number {
// 225 is average word reading speed for adults
return Math.ceil(wordCount / 225);
}