1.0.3 • Published 1 year ago

use-read-time v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

use-read-time

React Hook to estimate read time for a provided text.

NPM JavaScript Style Guide

Install

npm install --save use-read-time

Usage

import { useReadTime } from "use-read-time";

const ExampleMinuteNumber = () => {
  const { readTime } = useReadTime({
    text: "Hello book with all but long paragraphs.",
  });

  console.log("ExampleMinuteNumber :: readTime", readTime); // 1

  return <h1>🤓 🔢</h1>;
};
import { useReadTime } from "use-read-time";

const ExampleReadTimeLabel = () => {
  const { readTimeLabel } = useReadTime({
    text: "Hello book with all but long paragraphs.",
  });

  console.log("ExampleReadTimeLabel :: readTime", readTime); // Around 1 minute.

  return <h1>🤓 🏷️</h1>;
};
import { useReadTime } from "use-read-time";

const ExampleReadTimeInfo = () => {
  const { readTimeLabel } = useReadTime({
    text: "Hello book with all but long paragraphs.",
  });

  console.log("ExampleReadTimeInfo :: readTimeInfo", readTimeInfo); // 1 min read

  return <h1>🤓 🗣</h1>;
};

API

FieldTypeDescriptionRequiredDefault
textStringText to calculate the amount of reading minutes for.yes
speedEnumfast (240 wpm), normal (180 wpm), slow (100 wpm) - indicating the reading speed.no
wpmIntNumber representing the word per minute to calculate the estimate time to read.no180

License

MIT © @ScottAgirs


Credits

Package by @ScottAgirs.

This hook is created using create-react-hook.