2022-02-24 16:24:49 +00:00
|
|
|
function countWords(str: string): number {
|
2022-03-29 10:13:46 +00:00
|
|
|
const matches = str.match(/[\w\d\'-]+/gi);
|
2022-02-24 16:24:49 +00:00
|
|
|
return matches ? matches.length : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function readingTime(wordCount: number): number {
|
|
|
|
// 225 is average word reading speed for adults
|
|
|
|
return Math.ceil(wordCount / 225);
|
|
|
|
}
|