Skip to content

Commit

Permalink
Increase words per minute
Browse files Browse the repository at this point in the history
  • Loading branch information
mellevanderlinde committed Nov 10, 2024
1 parent 0bcaa3e commit 668932f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions packages/reading-time/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ const sentence = "This is an example sentence. ";
it("should return the expected reading time", () => {
expect(getReadingTime(" ")).toBe(0);
expect(getReadingTime(sentence)).toBe(1);
expect(getReadingTime(sentence.repeat(80))).toBe(2);
expect(getReadingTime(sentence.repeat(81))).toBe(3);
expect(getReadingTime(sentence.repeat(1000))).toBe(25);
expect(getReadingTime(sentence.repeat(1001))).toBe(26);
expect(getReadingTime(sentence.repeat(100))).toBe(2);
expect(getReadingTime(sentence.repeat(101))).toBe(3);
});

it("should throw an error if content is not provided", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/reading-time/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function getReadingTime(content: string): number {
if (!content) throw new Error("Content is required");
const wordsPerMinute = 200;
const wordsPerMinute = 250;
const content_ = content.replace(/\n/g, " ");
const words = content_.split(" ").filter((word) => word !== "");
return Math.ceil(words.length / wordsPerMinute);
Expand Down

0 comments on commit 668932f

Please sign in to comment.