@verifyhash/wind-scale 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.
- package/LICENSE +1 -1
- package/README.md +10 -12
- package/index.d.ts +71 -0
- package/package.json +4 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
# wind-scale
|
|
2
2
|
|
|
3
|
-
<!-- publish-prep -->
|
|
4
|
-
> **TODO (owner): pick the final npm name/scope before publishing.**
|
|
5
|
-
> The npm package name is **not** finalized by this project. Convention used here:
|
|
6
|
-
> `package.json` keeps the working slug `wind-scale` as a placeholder — replace it
|
|
7
|
-
> (and the `npm install` line below) with the real published name/scope before
|
|
8
|
-
> running `npm publish`.
|
|
9
|
-
|
|
10
3
|
Zero-dependency, pure-JavaScript wind utilities: convert speeds between the five
|
|
11
4
|
units meteorologists actually use, and classify a wind on the three scales the
|
|
12
5
|
public sees on forecasts — the Beaufort force scale, the Saffir-Simpson
|
|
@@ -153,6 +146,14 @@ windChill(20, 2); // 20 (V <= 3 mph -> out of range, returns tempF)
|
|
|
153
146
|
Throws `TypeError` if either argument is not a finite number, and `RangeError`
|
|
154
147
|
for negative wind speed.
|
|
155
148
|
|
|
149
|
+
### Constants (exported tables)
|
|
150
|
+
|
|
151
|
+
- `UNITS` — the five supported unit codes: `['ms', 'kmh', 'mph', 'kn', 'fts']`.
|
|
152
|
+
- `FACTORS` — units-per-one-m/s conversion factors keyed by unit code
|
|
153
|
+
(e.g. `FACTORS.kmh === 3.6`); `convert()` is built on this table.
|
|
154
|
+
- `BEAUFORT` — the 13-row Beaufort table of `{ force, minMs, description }`
|
|
155
|
+
(force 0 "Calm" through force 12 "Hurricane force") used by `beaufort()`.
|
|
156
|
+
|
|
156
157
|
## Running the tests
|
|
157
158
|
|
|
158
159
|
One command, no install step (uses only `node:assert`):
|
|
@@ -183,15 +184,12 @@ MIT.
|
|
|
183
184
|
|
|
184
185
|
## Install
|
|
185
186
|
|
|
186
|
-
> Placeholder name: the `wind-scale` below is the working slug, not a finalized
|
|
187
|
-
> npm name — see the owner TODO near the top of this README.
|
|
188
|
-
|
|
189
187
|
```sh
|
|
190
|
-
npm install wind-scale
|
|
188
|
+
npm install @verifyhash/wind-scale
|
|
191
189
|
```
|
|
192
190
|
|
|
193
191
|
```js
|
|
194
|
-
const { convert, beaufort, saffirSimpson, windChill } = require('wind-scale');
|
|
192
|
+
const { convert, beaufort, saffirSimpson, windChill } = require('@verifyhash/wind-scale');
|
|
195
193
|
|
|
196
194
|
convert(10, 'ms', 'kmh'); // 36
|
|
197
195
|
beaufort(9.0); // { force: 5, description: 'Fresh breeze', minMs: 8, maxMs: 10.8 }
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for @verifyhash/wind-scale — zero-dependency wind speed
|
|
3
|
+
* conversions plus Beaufort, Saffir-Simpson, and the official 2001 NWS
|
|
4
|
+
* wind-chill formula.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** Supported wind-speed units: m/s, km/h, mph, knots, ft/s. */
|
|
8
|
+
export type WindUnit = 'ms' | 'kmh' | 'mph' | 'kn' | 'fts';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Convert a wind speed between any two supported units. Throws TypeError for
|
|
12
|
+
* a non-finite value and RangeError for an unknown unit.
|
|
13
|
+
*
|
|
14
|
+
* @example convert(10, 'ms', 'kmh') // => 36
|
|
15
|
+
*/
|
|
16
|
+
export function convert(value: number, fromUnit: WindUnit, toUnit: WindUnit): number;
|
|
17
|
+
|
|
18
|
+
/** Result of beaufort(): the force band containing the given speed. */
|
|
19
|
+
export interface BeaufortResult {
|
|
20
|
+
/** Beaufort force, 0..12. */
|
|
21
|
+
force: number;
|
|
22
|
+
/** Standard WMO description, e.g. 'Fresh breeze'. */
|
|
23
|
+
description: string;
|
|
24
|
+
/** Inclusive lower bound of the band, m/s. */
|
|
25
|
+
minMs: number;
|
|
26
|
+
/** Exclusive upper bound of the band, m/s (Infinity for Force 12). */
|
|
27
|
+
maxMs: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Classify a wind speed (m/s, finite, >= 0) on the Beaufort scale. Force 0 is
|
|
32
|
+
* below 0.5 m/s; Force 12 (hurricane force) begins at 32.7 m/s.
|
|
33
|
+
*/
|
|
34
|
+
export function beaufort(speedMs: number): BeaufortResult;
|
|
35
|
+
|
|
36
|
+
/** Saffir-Simpson category: NHC sub-hurricane designations or category 1-5. */
|
|
37
|
+
export type SaffirSimpsonCategory = 'TD' | 'TS' | 1 | 2 | 3 | 4 | 5;
|
|
38
|
+
|
|
39
|
+
/** Result of saffirSimpson(). */
|
|
40
|
+
export interface SaffirSimpsonResult {
|
|
41
|
+
category: SaffirSimpsonCategory;
|
|
42
|
+
/** e.g. 'Tropical Storm' or 'Category 3 Hurricane'. */
|
|
43
|
+
label: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Classify a tropical cyclone by its 1-minute sustained wind in mph (finite,
|
|
48
|
+
* >= 0): TD < 39, TS 39-73, Cat 1 74-95, Cat 2 96-110, Cat 3 111-129,
|
|
49
|
+
* Cat 4 130-156, Cat 5 >= 157.
|
|
50
|
+
*/
|
|
51
|
+
export function saffirSimpson(sustainedMph: number): SaffirSimpsonResult;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 2001 NWS/Environment Canada wind chill, °F, from air temperature (°F) and
|
|
55
|
+
* wind speed (mph). Outside the NWS validity domain (tempF > 50 or
|
|
56
|
+
* windMph <= 3) returns tempF unchanged. Result is not rounded.
|
|
57
|
+
*/
|
|
58
|
+
export function windChill(tempF: number, windMph: number): number;
|
|
59
|
+
|
|
60
|
+
/** Conversion factors: how many of each unit equal 1 m/s (frozen). */
|
|
61
|
+
export const FACTORS: Readonly<Record<WindUnit, number>>;
|
|
62
|
+
|
|
63
|
+
/** The Beaufort force table (frozen): inclusive lower bounds in m/s. */
|
|
64
|
+
export const BEAUFORT: ReadonlyArray<{
|
|
65
|
+
force: number;
|
|
66
|
+
minMs: number;
|
|
67
|
+
description: string;
|
|
68
|
+
}>;
|
|
69
|
+
|
|
70
|
+
/** The supported unit names, in FACTORS order. */
|
|
71
|
+
export const UNITS: readonly string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verifyhash/wind-scale",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Zero-dependency wind speed conversions plus Beaufort, Saffir-Simpson, and the official 2001 NWS wind-chill formula.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wind",
|
|
@@ -13,13 +13,15 @@
|
|
|
13
13
|
"conversion"
|
|
14
14
|
],
|
|
15
15
|
"main": "src/wind-scale.js",
|
|
16
|
+
"types": "index.d.ts",
|
|
16
17
|
"scripts": {
|
|
17
18
|
"test": "node test/wind-scale.test.js"
|
|
18
19
|
},
|
|
19
20
|
"license": "MIT",
|
|
20
21
|
"files": [
|
|
21
22
|
"src/wind-scale.js",
|
|
22
|
-
"README.md"
|
|
23
|
+
"README.md",
|
|
24
|
+
"index.d.ts"
|
|
23
25
|
],
|
|
24
26
|
"publishConfig": {
|
|
25
27
|
"access": "public"
|