
Research
/Security News
Miasma Mini Shai-Hulud Hits ImmobiliareLabs npm Packages
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.
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.
You can install Your Focusing Library via npm:
npm install focusing
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
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();
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
To access basic user profile information, you can use the getUserProfile function:
import { getUserProfile } from 'focusing';
const userProfile = getUserProfile();
console.log("User Profile:", userProfile);
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.
Focusing Library is open-source software licensed under the MIT License.
FAQs
Focusing tracks your focus and helps you stay on task.
The npm package focusing receives a total of 2 weekly downloads. As such, focusing popularity was classified as not popular.
We found that focusing demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.

Security News
/Research
Mini Shai-Hulud expands into the Go ecosystem after hitting LeoPlatform npm packages and targeting GitHub Actions workflows.