npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fitmefy

v1.0.7

Published

A Node.js package for fitness calculations including BMI, stress estimation, workout planning, VO2 Max, body fat percentage, hydration needs, calorie needs, heart rate zones, macronutrients, and one-rep max estimation.

Downloads

2

Readme

Fitness Utilities

A Node.js package for fitness calculations including BMI, stress estimation, workout planning, VO2 Max, body fat percentage, hydration needs, calorie needs, heart rate zones, macronutrients, and one-rep max estimation.

Features

  • BMI Calculation: Calculates Body Mass Index.
  • Stress Estimator: Estimates stress levels.
  • Workout Plan Generator: Generates a workout plan.
  • VO2 Max Estimation: Estimates VO2 Max.
  • Body Fat Percentage: Calculates body fat percentage.
  • Hydration Needs: Determines daily hydration needs.
  • Calorie Calculation: Calculates daily calorie needs.
  • Heart Rate Zones: Calculates heart rate zones.
  • Macronutrients Calculation: Calculates daily macronutrient needs.
  • One-Rep Max Estimation: Estimates one-rep max.

Installation

Install dependencies with npm:

npm install inquirer clipboardy

import inquirer from 'inquirer';
import clipboardy from 'clipboardy';
import { calculateBMI, stressEstimator, workoutPlanGenerator, vo2MaxEstimation, bodyFatPercentage, hydrationNeeds, calorieCalculator, heartRateZones, macrosCalculation, oneRepMax } from "fitmefy";

const questions = [
    {
        type: 'list',
        name: 'functionName',
        message: 'Enter the function name:',
        choices: [
            'calculateBMI',
            'stressEstimator',
            'workoutPlanGenerator',
            'vo2MaxEstimation',
            'bodyFatPercentage',
            'hydrationNeeds',
            'calorieCalculator',
            'heartRateZones',
            'macrosCalculation',
            'oneRepMax'
        ]
    }
];

const promptUser = () => {
    inquirer.prompt(questions).then(answers => {
        const { functionName } = answers;

        switch (functionName) {
            case "calculateBMI":
                inquirer.prompt([
                    { type: 'input', name: 'weight', message: 'Enter weight (kg):', validate: input => !isNaN(input) },
                    { type: 'input', name: 'height', message: 'Enter height (cm):', validate: input => !isNaN(input) }
                ]).then(({ weight, height }) => {
                    const result = calculateBMI(parseFloat(weight), parseFloat(height));
                    clipboardy.writeSync(result.toString());
                    console.log(`Result: ${result}`);
                    console.log('Result copied to clipboard!');
                });
                break;
            case "stressEstimator":
                inquirer.prompt([
                    { type: 'input', name: 'level', message: 'Enter stress level:', validate: input => !isNaN(input) },
                    { type: 'input', name: 'duration', message: 'Enter duration (hours):', validate: input => !isNaN(input) },
                    { type: 'input', name: 'frequency', message: 'Enter frequency:', validate: input => !isNaN(input) }
                ]).then(({ level, duration, frequency }) => {
                    const result = stressEstimator(parseInt(level), parseInt(duration), parseInt(frequency));
                    clipboardy.writeSync(result.toString());
                    console.log(`Result: ${result}`);
                    console.log('Result copied to clipboard!');
                });
                break;
            case "workoutPlanGenerator":
                inquirer.prompt([
                    { type: 'input', name: 'daysPerWeek', message: 'Enter days per week:', validate: input => !isNaN(input) },
                    { type: 'input', name: 'duration', message: 'Enter duration per workout:', validate: input => !isNaN(input) },
                    { type: 'input', name: 'type', message: 'Enter type of workout:' }
                ]).then(({ daysPerWeek, duration, type }) => {
                    const result = workoutPlanGenerator(parseInt(daysPerWeek), duration, type);
                    clipboardy.writeSync(result.toString());
                    console.log(`Result: ${result}`);
                    console.log('Result copied to clipboard!');
                });
                break;
            case "vo2MaxEstimation":
                inquirer.prompt([
                    { type: 'input', name: 'runTime', message: 'Enter run time (minutes):', validate: input => !isNaN(input) },
                    { type: 'input', name: 'distance', message: 'Enter distance (km):', validate: input => !isNaN(input) }
                ]).then(({ runTime, distance }) => {
                    const result = vo2MaxEstimation(parseFloat(runTime), parseFloat(distance));
                    clipboardy.writeSync(result.toString());
                    console.log(`Result: ${result}`);
                    console.log('Result copied to clipboard!');
                });
                break;
            case "bodyFatPercentage":
                inquirer.prompt([
                    { type: 'input', name: 'weight', message: 'Enter weight (kg):', validate: input => !isNaN(input) },
                    { type: 'input', name: 'height', message: 'Enter height (cm):', validate: input => !isNaN(input) }
                ]).then(({ weight, height }) => {
                    const result = bodyFatPercentage(parseFloat(weight), parseFloat(height));
                    clipboardy.writeSync(result.toString());
                    console.log(`Result: ${result}`);
                    console.log('Result copied to clipboard!');
                });
                break;
            case "hydrationNeeds":
                inquirer.prompt([
                    { type: 'input', name: 'weight', message: 'Enter weight (kg):', validate: input => !isNaN(input) }
                ]).then(({ weight }) => {
                    const result = hydrationNeeds(parseFloat(weight));
                    clipboardy.writeSync(result.toString());
                    console.log(`Result: ${result}`);
                    console.log('Result copied to clipboard!');
                });
                break;
            case "calorieCalculator":
                inquirer.prompt([
                    { type: 'input', name: 'weight', message: 'Enter weight (kg):', validate: input => !isNaN(input) },
                    { type: 'input', name: 'height', message: 'Enter height (cm):', validate: input => !isNaN(input) }
                ]).then(({ weight, height }) => {
                    const result = calorieCalculator(parseFloat(weight), parseFloat(height));
                    clipboardy.writeSync(result.toString());
                    console.log(`Result: ${result}`);
                    console.log('Result copied to clipboard!');
                });
                break;
            case "heartRateZones":
                inquirer.prompt([
                    { type: 'input', name: 'age', message: 'Enter age:', validate: input => !isNaN(input) }
                ]).then(({ age }) => {
                    const result = heartRateZones(parseInt(age));
                    clipboardy.writeSync(result.toString());
                    console.log(`Result: ${result}`);
                    console.log('Result copied to clipboard!');
                });
                break;
            case "macrosCalculation":
                inquirer.prompt([
                    { type: 'input', name: 'weight', message: 'Enter weight (kg):', validate: input => !isNaN(input) },
                    { type: 'input', name: 'height', message: 'Enter height (cm):', validate: input => !isNaN(input) }
                ]).then(({ weight, height }) => {
                    const result = macrosCalculation(parseFloat(weight), parseFloat(height));
                    clipboardy.writeSync(result.toString());
                    console.log(`Result: ${result}`);
                    console.log('Result copied to clipboard!');
                });
                break;
            case "oneRepMax":
                inquirer.prompt([
                    { type: 'input', name: 'weight', message: 'Enter weight lifted (kg):', validate: input => !isNaN(input) },
                    { type: 'input', name: 'reps', message: 'Enter number of repetitions:', validate: input => !isNaN(input) }
                ]).then(({ weight, reps }) => {
                    const result = oneRepMax(parseFloat(weight), parseInt(reps));
                    clipboardy.writeSync(result.toString());
                    console.log(`Result: ${result}`);
                    console.log('Result copied to clipboard!');
                });
                break;
            default:
                console.log("Invalid function name");
                break;
        }
    });
};

promptUser();

Converting to an Executable

Install pkg Globally:

npm install -g pkg

Build Executables:

pkg script.js -t node14-linux-x64,node14-macos-x64,node14-win-x64

Run the Executable:

./script-linux    # On Linux
./script-macos    # On macOS
./script-win.exe  # On Windows

License

MIT License. See the LICENSE file for details.

This `README.md` provides a comprehensive overview of your project, including features, installation steps, usage instructions, and how to convert the script to an executable.