muscle-checker 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # muscle_checker
2
+
3
+ 筋トレの成果を最大限にするために、トレーニング指標となるRM値や適性トレーニング、体の変化を数値化したBMI(ボディマス指数)/FFMI(徐脂肪量指数)を計算してくれるパッケージ
4
+
5
+ <img width="366" height="100" alt="スクリーンショット 2025-12-23 095759" src="https://github.com/user-attachments/assets/e9613b67-4764-4148-99fc-3cac59b9b310" />
6
+
7
+ # インストール
8
+
9
+ ```
10
+ npm install muscle_checker
11
+ ```
12
+
13
+ # 使用方法
14
+
15
+ ## 起動方法
16
+
17
+ 以下のコマンドで起動できます。
18
+
19
+ ```
20
+ muscle_checker
21
+ ```
22
+
23
+ ## 最大挙上重量
24
+
25
+ <img width="385" height="179" alt="スクリーンショット 2025-12-23 101009" src="https://github.com/user-attachments/assets/6b8bf571-29cd-4b16-8ca1-67e70ff07cc8" />
26
+
27
+ ### 操作手順
28
+
29
+ 1. 持ち上げる重量を入力する。
30
+ 2. 持ち上げられる回数を1~10から選択する。
31
+ 3. 結果として、重量・回数・最大拳上重量が出力される。
32
+
33
+ ## 適正トレーニング
34
+
35
+ <img width="488" height="126" alt="スクリーンショット 2025-12-23 101445" src="https://github.com/user-attachments/assets/fc91a37e-41ee-4e22-9c56-6f29062fef75" />
36
+
37
+ ### 操作手順
38
+
39
+ 1. 最大拳上重量を入力する。
40
+ 2. 希望する回数を1~10から選択する。
41
+ 3. 結果として、トレーニング回数(レップ)と適正な重量が出力される。
42
+
43
+ ## BMI//FFMI
44
+
45
+ ### 体脂肪率が分からない場合
46
+
47
+ <img width="442" height="214" alt="スクリーンショット 2025-12-23 101844" src="https://github.com/user-attachments/assets/bfea112e-830b-4cb8-9870-b37282fa656a" />
48
+
49
+ ### 体脂肪率が分かる場合
50
+
51
+ <img width="483" height="218" alt="スクリーンショット 2025-12-23 101923" src="https://github.com/user-attachments/assets/8457fe43-fc58-41fc-a23c-0991bae25058" />
52
+
53
+ ### 操作手順
54
+
55
+ 1. 身長を入力する。
56
+ 2. 体重を入力する。
57
+ 3. 体脂肪率が分かれば入力する。分からなければEnter。
58
+ 4. 結果として、BMIとFFMI(体脂肪率が分かる場合)が出力される。
@@ -0,0 +1,9 @@
1
+ import globals from "globals";
2
+ import pluginJs from "@eslint/js";
3
+ import eslintConfigPrettier from "eslint-config-prettier";
4
+
5
+ export default [
6
+ { languageOptions: { globals: globals.nodeBuiltin } },
7
+ pluginJs.configs.recommended,
8
+ eslintConfigPrettier,
9
+ ];
package/index.js ADDED
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/env node
2
+
3
+ import enquirer from "enquirer";
4
+
5
+ const { prompt } = enquirer;
6
+
7
+ async function main() {
8
+ let process = await decide_process();
9
+ switch (process.answer) {
10
+ case "最大拳上重量(RM値)":
11
+ await printRm();
12
+ break;
13
+ case "適正トレーニング":
14
+ await printRecommendedWeight();
15
+ break;
16
+ case "BMI/FFMI":
17
+ await printBmi();
18
+ break;
19
+ }
20
+ }
21
+
22
+ async function decide_process() {
23
+ const processQuestion = {
24
+ type: "select",
25
+ name: "answer",
26
+ message: "どれにしますか?",
27
+ choices: ["最大拳上重量(RM値)", "適正トレーニング", "BMI/FFMI"],
28
+ };
29
+ return await prompt(processQuestion);
30
+ }
31
+
32
+ async function printRm() {
33
+ console.log("RM測定");
34
+ const weight = await askNumber("重量を入力してください。(単位 :kg)");
35
+ const times = await selectTimes("回数を入力してください。(数字のみ)");
36
+ const rm = await caluculateRm(weight.answer, times.answer);
37
+ console.log("--結果--");
38
+ console.log(`重量:${weight.answer}kg`);
39
+ console.log(`回数:${times.answer}回`);
40
+ console.log(`あなたの最大拳上重量は${rm}kgです。`);
41
+ }
42
+
43
+ async function printRecommendedWeight() {
44
+ const rm = await askNumber("最大拳上重量を入力してください。( 単位:kg)");
45
+ const times = await selectTimes(
46
+ "希望する回数を入力してくださ い。(数字のみ)",
47
+ );
48
+ const weight = await caluculateWeight(rm.answer, times.answer);
49
+ console.log("--結果--");
50
+ console.log(
51
+ `${times.answer}レップのトレーニングには${weight}kgの重量が おすすめです。`,
52
+ );
53
+ }
54
+
55
+ async function printBmi() {
56
+ console.log("BMI測定");
57
+ const height = await askNumber("身長を入力してください。(単位:cm)");
58
+ const bodyWeight = await askNumber("体重を入力してください。( 単位:kg)");
59
+ const fatPercent = await askNumber(
60
+ "体脂肪率は分かりますか?(分からなければEnter)",
61
+ true,
62
+ );
63
+ const bmiffmi = await caluculateBmi(
64
+ height.answer,
65
+ bodyWeight.answer,
66
+ fatPercent.answer,
67
+ );
68
+ console.log("--結果--");
69
+ console.log(`身長:${height.answer}cm`);
70
+ console.log(`体重:${bodyWeight.answer}kg`);
71
+ console.log(`あなたのBMIは${bmiffmi.bmi}です。`);
72
+ console.log(`あなたのFFMIは${bmiffmi.ffmi}です。`);
73
+ }
74
+
75
+ async function askNumber(message, option = null) {
76
+ const quetion = {
77
+ type: "input",
78
+ name: "answer",
79
+ message,
80
+ validate: (value) => {
81
+ if (option && !value) return true;
82
+ if (isNaN(value) || value <= 0)
83
+ return "正の数字を半角入力してください!!";
84
+ return true;
85
+ },
86
+ };
87
+ return await prompt(quetion);
88
+ }
89
+
90
+ async function selectTimes(message) {
91
+ const timesQuestion = {
92
+ type: "select",
93
+ name: "answer",
94
+ message,
95
+ choices: [...Array(10)].map((_, i) => i + 1).map(String),
96
+ result(time) {
97
+ return Number(time);
98
+ },
99
+ };
100
+ return await prompt(timesQuestion);
101
+ }
102
+
103
+ function caluculateRm(weight, times) {
104
+ const rm = weight * (times / 40 + 1);
105
+ return roundOff(rm, 100);
106
+ }
107
+
108
+ function caluculateWeight(rm, times) {
109
+ const weight = rm / (times / 40 + 1);
110
+ return roundOff(weight, 100);
111
+ }
112
+
113
+ function caluculateBmi(height, bodyWeight, fatPercent = null) {
114
+ var BmiFfmi = {};
115
+ const heightSquared = (height * 0.01) ** 2;
116
+ const bmi = bodyWeight / heightSquared;
117
+ const lbm = bodyWeight * (1 - fatPercent * 0.01);
118
+ const ffmi = lbm / heightSquared;
119
+ BmiFfmi.bmi = roundOff(bmi, 10);
120
+ BmiFfmi.ffmi = fatPercent ? roundOff(ffmi, 10) : "測定不能";
121
+ return BmiFfmi;
122
+ }
123
+
124
+ function roundOff(value, base) {
125
+ return Math.round(value * base) / base;
126
+ }
127
+
128
+ main();
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "muscle-checker",
3
+ "bin": {
4
+ "muscle-checker": "index.js"
5
+ },
6
+ "version": "1.0.0",
7
+ "type": "module",
8
+ "description": "A package to check your muscles and body numerically",
9
+ "main": "index.js",
10
+ "scripts": {
11
+ "test": "echo \"Error: no test specified\" && exit 1",
12
+ "fix": "prettier --write . && eslint --fix .",
13
+ "lint": "prettier --check . && eslint ."
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/y-kawahara-gs/muscle-checker.git"
18
+ },
19
+ "keywords": [
20
+ "muscle"
21
+ ],
22
+ "author": "Yukichi Kawahara",
23
+ "license": "ISC",
24
+ "bugs": {
25
+ "url": "https://github.com/y-kawahara-gs/muscle-checker/issues"
26
+ },
27
+ "homepage": "https://github.com/y-kawahara-gs/muscle-checker#readme",
28
+ "dependencies": {
29
+ "enquirer": "^2.4.1",
30
+ "eslint": "^9.39.2",
31
+ "eslint-config-prettier": "^10.1.8",
32
+ "prettier": "^3.7.4"
33
+ }
34
+ }