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

focusing

v1.1.8

Published

Focusing tracks your focus and helps you stay on task.

Downloads

7

Readme


Focusing

Focusing Library is a JavaScript library that helps track the number of words typed by the user and set target goals for word count or time spent on a task. It also provides basic user profile information based on the user's computer.

Features

  • Word count tracking: Track the number of words typed by the user in a text input.
  • Time tracking: Measure the time spent on a task using a timer.
  • Goal setting: Set target goals for word count or time spent on a task.
  • User profile: Access basic user profile information based on the user's computer.

Installation

You can install Your Focusing Library via npm:

npm install focusing

Usage

Word Count Tracking

To track the number of words typed by the user, you can use the countWords function. It takes the text as input and returns the word count:

import { countWords } from 'focusing';

const inputText = "This is an example sentence with some words.";
const wordCount = countWords(inputText);
console.log("Word count:", wordCount); // Output: Word count: 9

Time Tracking

To measure the time spent on a task, you can use the startTimer and stopTimer functions. The getElapsedTime function returns the time duration in seconds:

import { startTimer, stopTimer, getElapsedTime } from 'focusing';

startTimer();

// Perform the task...

stopTimer();

const elapsedTime = getElapsedTime();
console.log("Time spent:", elapsedTime, "seconds");
import { WordTracking } from 'focusing';

// Initialize the WordTracking instance with custom word boundary characters
const wordBoundaryChars = [' ', '-', '_'];
const wordTracker = WordTracking.getInstance(wordBoundaryChars);

// Start tracking user input
wordTracker.startTracking();

// Wait for a few seconds (or as the user types)

// Get the current word count using the default counting mode ('all')
const allWordsCount = wordTracker.getWordCount();
console.log(allWordsCount); // Output: The number of all words typed by the user

// Get the current word count using the 'unique' counting mode
const uniqueWordsCount = wordTracker.getWordCount(CountingMode.UniqueWords);
console.log(uniqueWordsCount); // Output: The number of unique words typed by the user

// Get the current word count using the 'specific' counting mode
const specificWordOccurrencesCount = wordTracker.getWordCount(CountingMode.SpecificWordOccurrences);
console.log(specificWordOccurrencesCount); // Output: The total occurrences of specific words typed by the user

// Subscribe to word count change events
const wordCountListener = (count: number) => {
  console.log('Word count changed:', count);
};

wordTracker.subscribe(wordCountListener);

// Wait for a few seconds (or as the user types)

// Unsubscribe from word count change events (if necessary)
wordTracker.unsubscribe(wordCountListener);


// Stop tracking user input (if necessary)
wordTracker.stopTracking();

Goal Setting

You can set target goals for word count or time spent on a task using the setWordGoal and setTimeGoal functions:

import { setWordGoal, setTimeGoal } from 'focusing';

setWordGoal(500); // Set a goal of typing 500 words
setTimeGoal(1800); // Set a goal of spending 1800 seconds (30 minutes) on the task

User Profile

To access basic user profile information, you can use the getUserProfile function:

import { getUserProfile } from 'focusing';

const userProfile = getUserProfile();
console.log("User Profile:", userProfile);

Contributing

Contributions are welcome! If you have any bug fixes, new features, or improvements to the library, please submit a pull request.

Before contributing, please read our Contributing Guidelines.

License

Focusing Library is open-source software licensed under the MIT License.