🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

code-tracker

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code-tracker

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.

Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
22
2100%
Maintainers
1
Weekly downloads
 
Created
Source

Focusing Library

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.

Installation

You can install the Focusing library via NPM or Yarn:

npm install focusing-library --save

or

yarn add focusing-library

Usage

Tracking Code Usage

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);

Updating Code Usage

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);

Removing Code Usage

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);

Getting Code Metrics

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

Example

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

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! If you find a bug or want to suggest an enhancement, please create an issue or submit a pull request.

FAQs

Package last updated on 10 Aug 2023

Did you know?

Socket

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.

Install

Related posts