
Security News
PolinRider: North Korea-Linked Supply Chain Campaign Expands Across Open Source Ecosystems
PolinRider expands across npm, Packagist, Go modules, and Chrome extensions, using hidden loaders to target developer environments.
code-tracker
Advanced tools
Focus-Mode is a lightweight JavaScript library that helps track the amount of code developers write in a project. It allows you to monitor the lines of code in individual files and provides an overall count of lines of code for the entire project.
Focus-Mode is a lightweight JavaScript library that helps track the amount of code developers write in a project. It allows you to monitor the lines of code in individual files and provides an overall count of lines of code for the entire project.
You can install the Focusing library via NPM or Yarn:
npm install focusing-library --save
or
yarn add focusing-library
To track the lines of code in a file, you can use the trackCodeUsage function. For example:
import { trackCodeUsage } from 'focusing-library';
const file = 'example.js';
const linesOfCode = 50;
trackCodeUsage(file, linesOfCode);
If you need to update the number of lines of code in a file, use the updateCodeUsage function:
import { updateCodeUsage } from 'focusing-library';
const file = 'example.js';
const newLinesOfCode = 75;
updateCodeUsage(file, newLinesOfCode);
To stop tracking a file and remove it from the metrics, you can use the removeCodeUsage function:
import { removeCodeUsage } from 'focusing-library';
const file = 'example.js';
removeCodeUsage(file);
You can retrieve the overall lines of code and a dictionary of tracked files using the getCodeMetrics function:
import { getCodeMetrics } from 'focusing-library';
const metrics = getCodeMetrics();
console.log(metrics.totalLinesOfCode); // Output: Total lines of code in the project
console.log(metrics.files); // Output: Dictionary of tracked files and their respective lines of code
Here's a basic example of how you might use the Focusing library in a project:
import { trackCodeUsage, getCodeMetrics } from 'focusing-library';
const files = [
{ name: 'index.js', linesOfCode: 120 },
{ name: 'utils.js', linesOfCode: 50 },
// Add more files as needed
];
// Track code usage for each file
files.forEach(({ name, linesOfCode }) => {
trackCodeUsage(name, linesOfCode);
});
// Get code metrics
const metrics = getCodeMetrics();
console.log(metrics.totalLinesOfCode); // Output: Total lines of code in the project
console.log(metrics.files); // Output: Dictionary of tracked files and their respective lines of code
This project is licensed under the MIT License.
Contributions are welcome! If you find a bug or want to suggest an enhancement, please create an issue or submit a pull request.
FAQs
Unknown package
The npm package code-tracker receives a total of 20 weekly downloads. As such, code-tracker popularity was classified as not popular.
We found that code-tracker 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.

Security News
PolinRider expands across npm, Packagist, Go modules, and Chrome extensions, using hidden loaders to target developer environments.

Security News
Open source attacks are accelerating as AI coding agents pull in dependencies faster, with less human review.

Research
/Security News
Malicious Chrome and Firefox extensions posed as free VPNs while stealing clipboard data through later extension updates.