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

focusing

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

focusing - npm Package Compare versions

Comparing version
1.1.0
to
1.1.1
+3
-3
package.json
{
"name": "focusing",
"version": "1.1.0",
"version": "1.1.1",
"description": "Focusing tracks your focus and helps you stay on task.",

@@ -19,3 +19,3 @@ "main": "dist/index.js",

"author": "Vantol Bennett",
"license": "ISC",
"license": "MIT",
"repository": {

@@ -33,3 +33,3 @@ "type": "git",

"files": [
"build/**/*"
"dist/**/*"
],

@@ -36,0 +36,0 @@ "dependencies": {

---
# Focus
# Focusing

@@ -78,2 +78,15 @@ 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.

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

@@ -80,0 +93,0 @@ wordTracker.stopTracking();

export { focusing } from "./lib/focus-api";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.focusing = void 0;
var focus_api_1 = require("./lib/focus-api");
Object.defineProperty(exports, "focusing", { enumerable: true, get: function () { return focus_api_1.focusing; } });
import { setWordGoal, setTimeGoal } from '../utils/goalSetting';
import { startTracking, endTracking, getTrackingTime } from "../utils/timeTracking";
import { WordTracking } from "../plugins/wordTracking";
export declare const focusing: {
setWordGoal: typeof setWordGoal;
setTimeGoal: typeof setTimeGoal;
startTracking: typeof startTracking;
endTracking: typeof endTracking;
getTrackingTime: typeof getTrackingTime;
wordTracker: WordTracking;
WordTracking: typeof WordTracking;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.focusing = void 0;
const goalSetting_1 = require("../utils/goalSetting");
const timeTracking_1 = require("../utils/timeTracking");
const wordTracking_1 = require("../plugins/wordTracking");
const wordTracker = wordTracking_1.WordTracking.getInstance();
exports.focusing = {
setWordGoal: goalSetting_1.setWordGoal,
setTimeGoal: goalSetting_1.setTimeGoal,
startTracking: timeTracking_1.startTracking,
endTracking: timeTracking_1.endTracking,
getTrackingTime: timeTracking_1.getTrackingTime,
wordTracker,
WordTracking: wordTracking_1.WordTracking
};
interface WordTrackingEvent {
data: string;
context: {
data: number;
};
}
export declare class WordTracking {
private static instance;
private readonly wordRegex;
constructor();
static getInstance(): WordTracking;
countWords(text: string): number;
updateWordCount(event: WordTrackingEvent, wordCount: number): void;
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WordTracking = void 0;
class WordTracking {
constructor() {
this.wordRegex = /\b\w+/gi;
}
static getInstance() {
if (!WordTracking.instance) {
WordTracking.instance = new WordTracking();
}
return WordTracking.instance;
}
countWords(text) {
const matches = text.match(this.wordRegex);
return matches ? matches.length : 0;
}
// @ts-ignore
updateWordCount(event, wordCount) {
// @ts-ignore
const wordCount = this.countWords(event.data);
// @ts-ignore
event.context.data = wordCount;
}
}
exports.WordTracking = WordTracking;
export declare function setWordGoal(goal: number): void;
export declare function setTimeGoal(goal: number): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setTimeGoal = exports.setWordGoal = void 0;
let wordGoal = 0;
let timeGoal = 0;
function setWordGoal(goal) {
wordGoal = goal;
}
exports.setWordGoal = setWordGoal;
function setTimeGoal(goal) {
timeGoal = goal;
}
exports.setTimeGoal = setTimeGoal;
export declare function startTracking(): void;
export declare function endTracking(): void;
export declare function getTrackingTime(): number;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTrackingTime = exports.endTracking = exports.startTracking = void 0;
// @ts-ignore
let startTime, endTime;
function startTracking() {
startTime = new Date();
}
exports.startTracking = startTracking;
function endTracking() {
endTime = new Date();
}
exports.endTracking = endTracking;
function getTrackingTime() {
// @ts-ignore
const timeDiff = endTime.getTime() - startTime.getTime();
return timeDiff / 1000;
}
exports.getTrackingTime = getTrackingTime;