npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

typing-metrics

v2.0.1

Published

A package to calculate typing metrics

Downloads

22

Readme

Typing Metrics

An NPM package to calculate typing metrics such as words per minute (WPM), accuracy, correct words, incorrect words, minimum string distance error rate (MSD), and keystrokes per character (KSPC).

Installation

npm install typing-metrics

Usage

const TypingMetrics = require('typing-metrics');

/*
 * Create an instance of TypingMetrics
 */
const typingMetrics = new TypingMetrics();

/*
 * The calculateMetrics method takes three arguments:
 * 1. text: The original text that the user is supposed to type.
 * 2. typedText: The text that the user actually typed.
 * 3. timeInSeconds: The time it took the user to type the text, in seconds.
 */
const metrics = typingMetrics.calculateMetrics('hello world', 'helli world', 60);

/*
 * The calculateMetrics method returns an object with the following structure:
 * {
 *   wordsPerMinute: <number>, // The typing speed of the user in words per minute
 *   accuracy: <number>, // The percentage of characters that were typed correctly
 *   msdErrorRate: <number>, // The minimum string distance error rate, which is a measure of the typing errors
 *   kspc: <number> // The average number of keystrokes per character
 * }
 */

// You can destructure the returned object to get these metrics:
const { wordsPerMinute, accuracy, msdErrorRate, kspc } = metrics;

console.log(`Words per minute: ${wordsPerMinute}`);
console.log(`Accuracy: ${accuracy}%`);
console.log(`MSD error rate: ${msdErrorRate}`);
console.log(`KSPC: ${kspc}`);

Algorithm

Minimum String Distance Error Rate (MSD)

The MSD error rate is calculated using the Levenshtein distance algorithm. The Levenshtein distance between two strings is the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one string into the other.

In this package, the Levenshtein distance is normalized by the length of the original text to calculate the MSD error rate.

Keystrokes Per Character (KSPC)

The KSPC is calculated by dividing the total number of keystrokes made by the user by the total number of characters in the original text. This gives the average number of keystrokes per character. The total number of keystrokes includes all keystrokes made by the user, including typing characters, backspaces, and retypes.

Words Per Minute (WPM)

The WPM is calculated by counting the number of words in the typed text (a word is defined as five characters including spaces and punctuation), dividing by the time taken to type the text in seconds, and then multiplying by 60 to convert to minutes.

Accuracy

The accuracy is calculated as (1 - MSD error rate) * 100, which gives the percentage of characters that were typed correctly.

References

Error Analysis

Todo

  • [X] Improve KSPC logic
  • [ ] Research more around how to find accuracy metric
  • [ ] Check if WPM formula can be improved
  • [X] Add tests
  • [ ] Give different words different weights: basic words like "it", "the", "a" etc. should be given less weigh than difficult words like "childhood" etc.. (BRAINSTORM more)

License

This project is licensed under the MIT License.