@verifyhash/wbgt-heat-stress 0.1.0 → 0.1.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 (4) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +27 -11
  3. package/index.d.ts +103 -0
  4. package/package.json +4 -2
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 <OWNER-NAME PLACEHOLDER>
3
+ Copyright (c) 2026 verifyhash
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,12 +1,5 @@
1
1
  # wbgt-heat-stress
2
2
 
3
- <!-- publish-prep -->
4
- > **TODO (owner): pick the final npm name/scope before publishing.**
5
- > The npm package name is **not** finalized. `package.json` keeps the working
6
- > slug `wbgt-heat-stress` as a placeholder — replace it (and the install line
7
- > below) with the real published name/scope before any `npm publish`.
8
- > Graduation to npm is a **needs-human** decision, not something this project does.
9
-
10
3
  A tiny, **zero-dependency** Node library for the three most-used heat-stress
11
4
  indices, each returned with a plain-language **risk category**:
12
5
 
@@ -35,11 +28,15 @@ math.
35
28
 
36
29
  ## Install / use
37
30
 
38
- Zero dependencies — vendor the folder or (after the owner finalizes the name)
39
- `npm install <final-name>`.
31
+ ```bash
32
+ npm install @verifyhash/wbgt-heat-stress
33
+ ```
34
+
35
+ Zero runtime dependencies — you can also vendor the folder directly. Source
36
+ lives in the [verifyhash/libs](https://github.com/verifyhash/libs) monorepo.
40
37
 
41
38
  ```js
42
- const { heatIndex, humidex, wbgt, wbgtFlag } = require('wbgt-heat-stress');
39
+ const { heatIndex, humidex, wbgt, wbgtFlag } = require('@verifyhash/wbgt-heat-stress');
43
40
 
44
41
  heatIndex(32.22, 70);
45
42
  // { heatIndexF: 105.9, heatIndexC: 41.1, risk: 'danger' }
@@ -56,6 +53,25 @@ wbgt(30, 50, { solarWm2: 900, windMs: 1.5 });
56
53
  wbgtFlag(31.5); // 'red' — band a WBGT you measured elsewhere
57
54
  ```
58
55
 
56
+ ## API
57
+
58
+ All six exports:
59
+
60
+ - `heatIndex(tempC, relHumidityPct)` → `{ heatIndexF, heatIndexC, risk }` —
61
+ NWS Rothfusz heat index (see formulas below).
62
+ - `humidex(tempC, dewPointC)` → `{ humidex, risk }` — Environment Canada humidex.
63
+ - `wbgt(tempC, relHumidityPct, opts?)` → `{ wbgtC, flag, mode }` — approximate
64
+ WBGT; pass `{ solarWm2, windMs }` for the outdoor estimate.
65
+ - `wbgtFlag(wbgtC)` → `'white' | 'green' | 'yellow' | 'red' | 'black'` — band a
66
+ WBGT value you measured or computed elsewhere (cut-points in the table below).
67
+ - `heatIndexRisk(hiF)` → the NWS band for a heat index **in °F**:
68
+ `'none'` (<80), `'caution'` (80–90), `'extreme caution'` (90–103),
69
+ `'danger'` (103–124), `'extreme danger'` (≥124). Used internally by
70
+ `heatIndex`; exported so you can band a value from another source.
71
+ - `humidexRisk(h)` → the Environment Canada band for a humidex value:
72
+ `'none'` (<30), `'some discomfort'` (30–39), `'great discomfort'` (40–45),
73
+ `'dangerous'` (≥46).
74
+
59
75
  ## Running the tests
60
76
 
61
77
  One command, no framework, no dependencies:
@@ -159,4 +175,4 @@ from a real sensor.
159
175
 
160
176
  ## License
161
177
 
162
- MIT — see `LICENSE`. (Copyright holder is a placeholder pending owner sign-off.)
178
+ MIT — see `LICENSE`.
package/index.d.ts ADDED
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Type declarations for @verifyhash/wbgt-heat-stress — zero-dependency
3
+ * heat-stress indices: NWS heat index, Environment Canada humidex, and a
4
+ * Wet-Bulb Globe Temperature (WBGT) APPROXIMATION with risk flags.
5
+ *
6
+ * All functions are pure; they throw TypeError on non-finite numeric inputs
7
+ * and RangeError on out-of-range values (e.g. RH outside [0, 100]).
8
+ */
9
+
10
+ /** NWS heat-index caution band. */
11
+ export type HeatIndexRisk =
12
+ | 'none'
13
+ | 'caution'
14
+ | 'extreme caution'
15
+ | 'danger'
16
+ | 'extreme danger';
17
+
18
+ /** Environment Canada humidex comfort band. */
19
+ export type HumidexRisk =
20
+ | 'none'
21
+ | 'some discomfort'
22
+ | 'great discomfort'
23
+ | 'dangerous';
24
+
25
+ /** WBGT flag colour (US military / ACSM bands), white (low) … black (highest risk). */
26
+ export type WbgtFlag = 'white' | 'green' | 'yellow' | 'red' | 'black';
27
+
28
+ /** Result of heatIndex(). */
29
+ export interface HeatIndexResult {
30
+ /** Apparent temperature, °C. */
31
+ heatIndexC: number;
32
+ /** Apparent temperature, °F (the regression's native unit). */
33
+ heatIndexF: number;
34
+ /** NWS caution band for the °F value. */
35
+ risk: HeatIndexRisk;
36
+ }
37
+
38
+ /** Result of humidex(). */
39
+ export interface HumidexResult {
40
+ /** Humidex value (unitless comfort index on the Celsius scale), clamped to >= tempC. */
41
+ humidex: number;
42
+ /** Environment Canada comfort band. */
43
+ risk: HumidexRisk;
44
+ }
45
+
46
+ /** Options for wbgt() — providing solarWm2 switches to outdoor mode. */
47
+ export interface WbgtOptions {
48
+ /** Global solar irradiance, W/m² (>= 0). Enables the outdoor solar-load heuristic. */
49
+ solarWm2?: number | null;
50
+ /** 10 m wind speed, m/s (>= 0). Only used in outdoor mode. Default 1. */
51
+ windMs?: number | null;
52
+ }
53
+
54
+ /** Result of wbgt(). */
55
+ export interface WbgtResult {
56
+ /** Approximate Wet-Bulb Globe Temperature, °C. */
57
+ wbgtC: number;
58
+ /** Flag-colour band for the WBGT value. */
59
+ flag: WbgtFlag;
60
+ /** 'outdoor' when opts.solarWm2 was given, else 'indoor'. */
61
+ mode: 'indoor' | 'outdoor';
62
+ }
63
+
64
+ /**
65
+ * Apparent ("feels-like") temperature from air temperature (°C) and relative
66
+ * humidity (%, 0..100), following the US National Weather Service (Rothfusz
67
+ * regression with the documented low-temperature fallback and low/high
68
+ * humidity corrections; accurate to about ±1.3 °F).
69
+ */
70
+ export function heatIndex(tempC: number, relHumidityPct: number): HeatIndexResult;
71
+
72
+ /**
73
+ * Canadian humidex from air temperature and dew point (both °C).
74
+ * Throws RangeError when dewpointC exceeds tempC. Clamped so it is never
75
+ * reported below the air temperature.
76
+ */
77
+ export function humidex(tempC: number, dewpointC: number): HumidexResult;
78
+
79
+ /**
80
+ * Approximate Wet-Bulb Globe Temperature from air temperature (°C) and
81
+ * relative humidity (%, 0..100). Indoor/shaded by default (Australian BoM
82
+ * simplified regression); passing opts.solarWm2 adds a coarse, capped solar
83
+ * load term (a heuristic, NOT a validated outdoor model — measure with a
84
+ * globe sensor for real occupational decisions in the sun).
85
+ */
86
+ export function wbgt(
87
+ tempC: number,
88
+ relHumidityPct: number,
89
+ opts?: WbgtOptions
90
+ ): WbgtResult;
91
+
92
+ /**
93
+ * Classify a WBGT (°C) into the US military / ACSM flag-colour band:
94
+ * white < 27.8 °C · green 27.8–29.3 · yellow 29.4–31.0 · red 31.1–32.1 ·
95
+ * black >= 32.2 °C.
96
+ */
97
+ export function wbgtFlag(wbgtC: number): WbgtFlag;
98
+
99
+ /** Low-level: NWS caution band for a heat index given in °F (exported for testing / advanced use). */
100
+ export function heatIndexRisk(hiF: number): HeatIndexRisk;
101
+
102
+ /** Low-level: Environment Canada comfort band for a humidex value (exported for testing / advanced use). */
103
+ export function humidexRisk(h: number): HumidexRisk;
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@verifyhash/wbgt-heat-stress",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Zero-dependency heat-stress indices: NWS heat index, Environment Canada humidex, and a Wet-Bulb Globe Temperature (WBGT) approximation with risk flags.",
5
5
  "main": "index.js",
6
+ "types": "index.d.ts",
6
7
  "type": "commonjs",
7
8
  "scripts": {
8
9
  "test": "node test/index.test.js"
@@ -23,7 +24,8 @@
23
24
  "license": "MIT",
24
25
  "files": [
25
26
  "index.js",
26
- "README.md"
27
+ "README.md",
28
+ "index.d.ts"
27
29
  ],
28
30
  "publishConfig": {
29
31
  "access": "public"