muscle-checker 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/index.js +33 -31
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -4,63 +4,67 @@ import enquirer from "enquirer";
4
4
 
5
5
  const { prompt } = enquirer;
6
6
 
7
+ const CHOICE_RM = "最大拳上重量(RM値)",
8
+ CHOICE_TRAINING = "適正トレーニング",
9
+ CHOICE_BMI_FFMI = "BMI/FFMI";
10
+
11
+ main();
12
+
7
13
  async function main() {
8
- let process = await decide_process();
14
+ const process = await chooseProcess();
9
15
  switch (process.answer) {
10
- case "最大拳上重量(RM値)":
16
+ case CHOICE_RM:
11
17
  await printRm();
12
18
  break;
13
- case "適正トレーニング":
19
+ case CHOICE_TRAINING:
14
20
  await printRecommendedWeight();
15
21
  break;
16
- case "BMI/FFMI":
22
+ case CHOICE_BMI_FFMI:
17
23
  await printBmi();
18
24
  break;
19
25
  }
20
26
  }
21
27
 
22
- async function decide_process() {
28
+ async function chooseProcess() {
23
29
  const processQuestion = {
24
30
  type: "select",
25
31
  name: "answer",
26
32
  message: "どれにしますか?",
27
- choices: ["最大拳上重量(RM値)", "適正トレーニング", "BMI/FFMI"],
33
+ choices: [CHOICE_RM, CHOICE_TRAINING, CHOICE_BMI_FFMI],
28
34
  };
29
35
  return await prompt(processQuestion);
30
36
  }
31
37
 
32
38
  async function printRm() {
33
39
  console.log("RM測定");
34
- const weight = await askNumber("重量を入力してください。(単位 :kg)");
35
- const times = await selectTimes("回数を入力してください。(数字のみ)");
36
- const rm = await caluculateRm(weight.answer, times.answer);
40
+ const weight = await askNumber("重量を入力してください。(単位:kg)");
41
+ const count = await selectTimes("回数を入力してください。(数字のみ)");
42
+ const rm = await caluculateRm(weight.answer, count.answer);
37
43
  console.log("--結果--");
38
44
  console.log(`重量:${weight.answer}kg`);
39
- console.log(`回数:${times.answer}回`);
45
+ console.log(`回数:${count.answer}回`);
40
46
  console.log(`あなたの最大拳上重量は${rm}kgです。`);
41
47
  }
42
48
 
43
49
  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);
50
+ const rm = await askNumber("最大拳上重量を入力してください。(単位:kg)");
51
+ const count = await selectTimes("希望する回数を入力してください。(数字のみ)");
52
+ const weight = await caluculateWeight(rm.answer, count.answer);
49
53
  console.log("--結果--");
50
54
  console.log(
51
- `${times.answer}レップのトレーニングには${weight}kgの重量が おすすめです。`,
55
+ `${count.answer}レップのトレーニングには${weight}kgの重量がおすすめです。`,
52
56
  );
53
57
  }
54
58
 
55
59
  async function printBmi() {
56
60
  console.log("BMI測定");
57
61
  const height = await askNumber("身長を入力してください。(単位:cm)");
58
- const bodyWeight = await askNumber("体重を入力してください。( 単位:kg)");
62
+ const bodyWeight = await askNumber("体重を入力してください。(単位:kg)");
59
63
  const fatPercent = await askNumber(
60
64
  "体脂肪率は分かりますか?(分からなければEnter)",
61
65
  true,
62
66
  );
63
- const bmiffmi = await caluculateBmi(
67
+ const bmiFfmi = await caluculateBmi(
64
68
  height.answer,
65
69
  bodyWeight.answer,
66
70
  fatPercent.answer,
@@ -68,8 +72,8 @@ async function printBmi() {
68
72
  console.log("--結果--");
69
73
  console.log(`身長:${height.answer}cm`);
70
74
  console.log(`体重:${bodyWeight.answer}kg`);
71
- console.log(`あなたのBMIは${bmiffmi.bmi}です。`);
72
- console.log(`あなたのFFMIは${bmiffmi.ffmi}です。`);
75
+ console.log(`あなたのBMIは${bmiFfmi.bmi}です。`);
76
+ console.log(`あなたのFFMIは${bmiFfmi.ffmi}です。`);
73
77
  }
74
78
 
75
79
  async function askNumber(message, option = null) {
@@ -88,30 +92,30 @@ async function askNumber(message, option = null) {
88
92
  }
89
93
 
90
94
  async function selectTimes(message) {
91
- const timesQuestion = {
95
+ const countQuestion = {
92
96
  type: "select",
93
97
  name: "answer",
94
98
  message,
95
99
  choices: [...Array(10)].map((_, i) => i + 1).map(String),
96
- result(time) {
97
- return Number(time);
100
+ result(count) {
101
+ return Number(count);
98
102
  },
99
103
  };
100
- return await prompt(timesQuestion);
104
+ return await prompt(countQuestion);
101
105
  }
102
106
 
103
- function caluculateRm(weight, times) {
104
- const rm = weight * (times / 40 + 1);
107
+ function caluculateRm(weight, count) {
108
+ const rm = weight * (count / 40 + 1);
105
109
  return roundOff(rm, 100);
106
110
  }
107
111
 
108
- function caluculateWeight(rm, times) {
109
- const weight = rm / (times / 40 + 1);
112
+ function caluculateWeight(rm, count) {
113
+ const weight = rm / (count / 40 + 1);
110
114
  return roundOff(weight, 100);
111
115
  }
112
116
 
113
117
  function caluculateBmi(height, bodyWeight, fatPercent = null) {
114
- var BmiFfmi = {};
118
+ const BmiFfmi = {};
115
119
  const heightSquared = (height * 0.01) ** 2;
116
120
  const bmi = bodyWeight / heightSquared;
117
121
  const lbm = bodyWeight * (1 - fatPercent * 0.01);
@@ -124,5 +128,3 @@ function caluculateBmi(height, bodyWeight, fatPercent = null) {
124
128
  function roundOff(value, base) {
125
129
  return Math.round(value * base) / base;
126
130
  }
127
-
128
- main();
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "bin": {
4
4
  "muscle-checker": "index.js"
5
5
  },
6
- "version": "1.0.0",
6
+ "version": "1.0.1",
7
7
  "type": "module",
8
8
  "description": "A package to check your muscles and body numerically",
9
9
  "main": "index.js",