CodeTracker API Documentation
CodeTracker provides a simple and effective way to track lines of code across different files. Here you'll find detailed information about the available classes, methods, and functions within the library.
CodeTracker Class
trackFile
Track a new file.
Parameters
file(string): The name of the file to track.
Example
trackFileCodeUsage('example.ts');updateFile
Update an existing tracked file.
Parameters
file(string): The name of the file to update.
Example
updateCodeUsage('example.ts');removeFile
Remove a tracked file.
Parameters
file(string): The name of the file to remove.
Example
removeCodeUsage('example.ts');getTotalLinesOfCode
Get the total number of lines of code across all tracked files.
Returns
- (number): The total lines of code.
Example
const total = codeTracker.getTotalLinesOfCode();getFiles
Get details of all tracked files.
Returns
- (object): An object containing file names as keys and lines of code as values.
Example
const files = codeTracker.getFiles();Utility Functions
trackCodeUsage
Convenience function to track a file.
Parameters
file(string): The name of the file to track.linesOfCode(number): The number of lines of code in the file.
Example
trackCodeUsage('example.ts');updateCodeUsage
Convenience function to update a tracked file.
Parameters
file(string): The name of the file to update.newLinesOfCode(number): The new number of lines of code in the file.
Example
updateCodeUsage('example.ts');removeCodeUsage
Convenience function to remove a tracked file.
Parameters
file(string): The name of the file to remove.
Example
removeCodeUsage('example.ts');getCodeMetrics
Convenience function to get code metrics.
Returns
- (object): An object containing total lines of code and details of all tracked files.
Example
const metrics = getCodeMetrics();