건강 계산기: JavaScript 라이브러리
건강 계산기: BMI, 이상 체중, 체지방, 칼로리, 심박 구간, WHO 아동 성장, 임신 등과 식단 기록, 체중 일지. 순수 함수이며 네트워크를 쓰지 않습니다.
@openlibsdev/health-calculator- v1.0.0
- ES module
- MIT
설치
번들러 또는 Node 방식 가져오기로:
npm install @openlibsdev/health-calculatorimport HealthCalculator from "@openlibsdev/health-calculator";또는 빌드 없이 페이지에서 바로(jsDelivr가 의존성을 해결합니다):
<script type="module">
import HealthCalculator from "https://cdn.jsdelivr.net/npm/@openlibsdev/health-calculator@1.0.0/+esm";
</script>사용법
import HealthCalculator from "@openlibsdev/health-calculator";
const profile = { sex: "female", age: 34, height: 168, weight: 61 }; // cm, kg
const r = HealthCalculator.compute("bmi", profile, {});
console.log(r.hero.value.n); // 21.6
console.log(HealthCalculator.bmrMifflin(profile));API
HealthCalculator.compute(id, profile, values)
id로 계산기를 실행해 프로필과 입력값에 대한 표시용 결과(주요 값, 배지, 눈금, 메모, 타일, 표, 차트)를 반환합니다.
HealthCalculator.CALCS
모든 계산기와 그 입력값.
HealthCalculator.GROUPS
계산기 그룹.
HealthCalculator.inputDefaults(id)
계산기의 기본 입력값.
HealthCalculator.normalizeProfile(p)
프로필을 검사하고 빠진 필드를 채웁니다.
HealthCalculator.bmiOf(p)
체질량지수.
HealthCalculator.bmrMifflin(p)
기초대사량(Mifflin–St Jeor).
HealthCalculator.lbmBoer(p)
제지방량(Boer).
HealthCalculator.maxHrTanaka(age)
최대 심박수(Tanaka).
HealthCalculator.whoLMS(sex, months)
성별과 개월 수에 따른 WHO 성장 기준 매개변수.
HealthCalculator.whoZ(x, L, M, S)
LMS 방법에 따른 Z 점수.
HealthCalculator.FOODS
100 g당 영양소가 있는 식품표.
HealthCalculator.mealTotals(items)
한 끼 영양소 합계.
HealthCalculator.addDiaryEntry(entries, entry)
체중 일지에 기록을 추가합니다.
HealthCalculator.diaryStats(entries, heightCm)
체중 일지 통계.
HealthCalculator.diaryCsv(entries)
CSV로 된 체중 일지.
HealthCalculator.parseDiaryCsv(text)
CSV에서 체중 일지를 읽습니다.
HealthCalculator.APP
라이브러리의 이름, 버전, 출시일: {name, version, created}.
HealthCalculator.COLOR
결과 색: 좋음, 경고, 나쁨 등.
HealthCalculator.MEALS
식단 기록의 끼니: 아침, 점심, 저녁, 간식.
HealthCalculator.MET_LIST
소모 칼로리 계산을 위한 MET 값이 있는 활동.
HealthCalculator.UNITS
단위 변환: 인치 ↔ cm, 파운드 ↔ kg.
HealthCalculator.WHO_BMI
WHO 2007 연령별 BMI 기준(5–19세): 성별에 따른 매월의 L, M, S.
HealthCalculator.WORK_DEFAULTS
작업 전체의 기본 상태: 계산기, 단위, 프로필, 입력, 식단 기록, 직접 추가한 음식, 체중 기록.
HealthCalculator.addDays(d, n)
날짜에 일 수를 더한 값.
HealthCalculator.daysBetween(a, b)
두 날짜 사이의 일 수.
HealthCalculator.findFood(id, custom)
id로 찾은 음식: 기본 제공 음식 또는 직접 추가한 음식.
HealthCalculator.findNamedColor(text, lang)
지정한 언어의 색 이름으로 이름 있는 색을 찾습니다(“진한 파랑” → #00008b).
HealthCalculator.foodLogCsv(log, custom)
CSV로 된 식단 기록: 날짜, 끼니, 음식, 그램, kcal, 단백질, 지방, 탄수화물.
HealthCalculator.healthCard(profile)
인쇄용 건강 카드에 쓸 프로필의 주요 수치. 프로필이 불완전하면 null.
HealthCalculator.isoDate(d)
"YYYY-MM-DD" 형식의 현지 날짜(없으면 오늘).
HealthCalculator.itemsTotals(items, custom)
{food, grams} 목록의 영양소 합계. 알 수 없는 음식은 건너뜁니다.
HealthCalculator.listNamedColors(lang)
이름 있는 색을 지정한 언어의 이름과 함께 나열합니다.
HealthCalculator.lmsValue(L, M, S, z)
WHO의 L, M, S 매개변수로 구한 z 점수에 해당하는 값.
HealthCalculator.makeCustomFood(o)
100 g당 {name, k, p, f, c}로 직접 추가한 음식을 만듭니다. 데이터가 틀리면 null.
HealthCalculator.namedColorTexts(lang)
지정한 언어의 색상 필드 라벨(색 선택기의 텍스트). 해당 언어가 없으면 영어.
HealthCalculator.normCDF(z)
표준 정규 분포: 값이 z보다 작을 확률.
HealthCalculator.normalizeWork(w)
저장된 작업(프로젝트 또는 자동 저장)을 확인하고 빠진 부분을 채웁니다.
HealthCalculator.parseDate(s)
"YYYY-MM-DD" → 현지 날짜, 또는 null.
HealthCalculator.round(n, d)
숫자를 지정한 소수 자릿수로 반올림합니다(기본 1).
HealthCalculator.sortDiary(entries)
체중 기록의 유효한 항목(날짜순).
HealthCalculator.textFontData
텍스트와 글꼴 블록의 데이터: 글꼴 목록, 스타일 불러오기, 글꼴 파일 추가, 언어별 블록 라벨, 기본값.
의존성
라이브러리가 불러오는 것과 그 라이선스(모두 라이선스 페이지에 있습니다).
| 이름 | 버전 | 라이선스 | 파일 |
|---|---|---|---|
| @openlibsdev/font-forge | 1.0.0 | MIT | GitHub |
| @openlibsdev/image-forge | 1.0.0 | MIT | GitHub |
| @imagemagick/magick-wasm | 0.0.35 | Apache-2.0 | 라이선스 · 소스 코드 |
| @imagemagick/magick-wasm | 0.0.35 | Apache-2.0 | 라이선스 · 소스 코드 |
| @simonwep/pickr | 1.10.2 | MIT | 라이선스 · 소스 코드 |
| @simonwep/pickr | 1.10.2 | MIT | 라이선스 · 소스 코드 |
| chart.js | 4.4.1 | MIT | 라이선스 · 소스 코드 |
| chart.js | 4.4.1 | MIT | 라이선스 · 소스 코드 |
| dejavu-fonts-ttf | 2.37.3 | Bitstream Vera Fonts License (free, redistributable); DejaVu changes are public domain | 라이선스 · 소스 코드 |
| imagetracerjs | 1.2.6 | Unlicense | 라이선스 · 소스 코드 |