get-reading-time 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -66,7 +66,7 @@ try {
66
66
  ```
67
67
  ### Example Output
68
68
  ```json
69
- json{
69
+ {
70
70
  "readingTime": {
71
71
  "minutes": 0.05,
72
72
  "seconds": 5.23
package/dist/index.d.mts CHANGED
@@ -7,6 +7,7 @@ interface TextAnalysisResult {
7
7
  characterCount: number;
8
8
  sentenceCount: number;
9
9
  linkCount: number;
10
+ links: string[];
10
11
  readabilityScore: number;
11
12
  sentiment: string;
12
13
  keywords: string[];
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ interface TextAnalysisResult {
7
7
  characterCount: number;
8
8
  sentenceCount: number;
9
9
  linkCount: number;
10
+ links: string[];
10
11
  readabilityScore: number;
11
12
  sentiment: string;
12
13
  keywords: string[];
package/dist/index.js CHANGED
@@ -44,7 +44,7 @@ function analyzeText(text, wordsPerMinute = DEFAULT_READING_SPEED) {
44
44
  const characterCount = calculateCharacterCount(cleanText);
45
45
  const sentenceCount = calculateSentenceCount(cleanText);
46
46
  const { minutes, seconds } = calculateReadingTime(wordCount, wordsPerMinute);
47
- const linkCount = countLinks(cleanText);
47
+ const links = countLinks(cleanText);
48
48
  const readabilityScore = calculateReadabilityScore(cleanText);
49
49
  const sentiment = analyzeSentiment(cleanText);
50
50
  const keywords = extractKeywords(cleanText);
@@ -53,7 +53,10 @@ function analyzeText(text, wordsPerMinute = DEFAULT_READING_SPEED) {
53
53
  wordCount,
54
54
  characterCount,
55
55
  sentenceCount,
56
- linkCount,
56
+ linkCount: links.length,
57
+ // Link count remains for backward compatibility
58
+ links,
59
+ // Add all links in the result
57
60
  readabilityScore,
58
61
  sentiment,
59
62
  keywords
@@ -81,7 +84,7 @@ function calculateReadingTime(wordCount, wordsPerMinute) {
81
84
  function countLinks(text) {
82
85
  const linkRegex = /https?:\/\/[^\s]+/g;
83
86
  const matches = text.match(linkRegex);
84
- return matches ? matches.length : 0;
87
+ return matches || [];
85
88
  }
86
89
  function calculateReadabilityScore(text) {
87
90
  const wordCount = calculateWordCount(text);
package/dist/index.mjs CHANGED
@@ -10,7 +10,7 @@ function analyzeText(text, wordsPerMinute = DEFAULT_READING_SPEED) {
10
10
  const characterCount = calculateCharacterCount(cleanText);
11
11
  const sentenceCount = calculateSentenceCount(cleanText);
12
12
  const { minutes, seconds } = calculateReadingTime(wordCount, wordsPerMinute);
13
- const linkCount = countLinks(cleanText);
13
+ const links = countLinks(cleanText);
14
14
  const readabilityScore = calculateReadabilityScore(cleanText);
15
15
  const sentiment = analyzeSentiment(cleanText);
16
16
  const keywords = extractKeywords(cleanText);
@@ -19,7 +19,10 @@ function analyzeText(text, wordsPerMinute = DEFAULT_READING_SPEED) {
19
19
  wordCount,
20
20
  characterCount,
21
21
  sentenceCount,
22
- linkCount,
22
+ linkCount: links.length,
23
+ // Link count remains for backward compatibility
24
+ links,
25
+ // Add all links in the result
23
26
  readabilityScore,
24
27
  sentiment,
25
28
  keywords
@@ -47,7 +50,7 @@ function calculateReadingTime(wordCount, wordsPerMinute) {
47
50
  function countLinks(text) {
48
51
  const linkRegex = /https?:\/\/[^\s]+/g;
49
52
  const matches = text.match(linkRegex);
50
- return matches ? matches.length : 0;
53
+ return matches || [];
51
54
  }
52
55
  function calculateReadabilityScore(text) {
53
56
  const wordCount = calculateWordCount(text);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "get-reading-time",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "main": "/dist/index.js",
5
5
  "module": "/dist/index.mjs",
6
6
  "types": "/dist/index.d.ts",