@verifyhash/koppen-classifier 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 +13 -15
  3. package/index.d.ts +49 -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
  # koppen-classifier
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 `koppen-classifier` 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
  A tiny, **zero-dependency** Node library that assigns a location its
11
4
  **Köppen–Geiger climate class** (e.g. `Cfa`, `BWh`, `Dfb`) from twelve monthly
12
5
  mean temperatures and twelve monthly precipitation totals. Pure function, no
@@ -29,7 +22,7 @@ No install step for local use — it's one file with no dependencies. Copy the
29
22
  folder in, or `require('./koppen-classifier')`.
30
23
 
31
24
  ```js
32
- const { classify } = require('koppen-classifier');
25
+ const { classify } = require('@verifyhash/koppen-classifier');
33
26
 
34
27
  // London, UK — monthly arrays run January → December.
35
28
  const london = classify({
@@ -74,6 +67,13 @@ throws a `TypeError` rather than returning a wrong answer.
74
67
  | `groupLabel` | `string` | `'Temperate'` | Top-level group name (Tropical / Arid / Temperate / Continental / Polar). |
75
68
  | `blurb` | `string` | `'A coldest month …'` | One-sentence plain-language summary. |
76
69
 
70
+ ### Lookup tables
71
+
72
+ - `KOPPEN_NAMES` — map from every Köppen code to its human-readable name,
73
+ e.g. `KOPPEN_NAMES.Cfa === 'humid subtropical'` — 31 codes in total.
74
+ - `GROUP_NAMES` — the five top-level groups:
75
+ `{ A: 'Tropical', B: 'Arid', C: 'Temperate', D: 'Continental', E: 'Polar' }`.
76
+
77
77
  ## What the algorithm actually does
78
78
 
79
79
  It applies the standard Köppen decision tree, tested in this order:
@@ -124,8 +124,9 @@ input validation. Exit code is non-zero on any failure.
124
124
 
125
125
  ## Status
126
126
 
127
- Incubator project an npm-graduation **candidate**, not published. Promotion to
128
- a real package registry is a separate, human-approved step.
127
+ Published to npm as [`@verifyhash/koppen-classifier`](https://www.npmjs.com/package/@verifyhash/koppen-classifier);
128
+ source lives in the [verifyhash/libs](https://github.com/verifyhash/libs) monorepo.
129
+ Version bumps and republishing remain a human-approved step.
129
130
 
130
131
  ## License
131
132
 
@@ -133,15 +134,12 @@ MIT.
133
134
 
134
135
  ## Install
135
136
 
136
- > Placeholder name: the `koppen-classifier` below is the working slug, not a finalized
137
- > npm name — see the owner TODO near the top of this README.
138
-
139
137
  ```sh
140
- npm install koppen-classifier
138
+ npm install @verifyhash/koppen-classifier
141
139
  ```
142
140
 
143
141
  ```js
144
- const { classify } = require('koppen-classifier');
142
+ const { classify } = require('@verifyhash/koppen-classifier');
145
143
 
146
144
  const london = classify({
147
145
  tempsC: [5.2, 5.3, 7.6, 9.6, 12.9, 16.0, 18.1, 17.8, 15.2, 11.4, 7.8, 5.5],
package/index.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Type declarations for @verifyhash/koppen-classifier — zero-dependency
3
+ * Köppen–Geiger climate classifier.
4
+ */
5
+
6
+ /** Options for classify(). Provide either `lat` or `hemisphere` (lat wins). */
7
+ export interface ClassifyOptions {
8
+ /** 12 monthly MEAN temperatures in °C, Jan → Dec. Exactly 12 finite numbers. */
9
+ tempsC: number[];
10
+ /** 12 monthly precipitation totals in mm, Jan → Dec. Exactly 12 finite numbers. */
11
+ precipMm: number[];
12
+ /** Signed latitude (north positive); only its sign is used. */
13
+ lat?: number;
14
+ /** Alternative to lat: 'N'/'S' (or 'north'/'south', case-insensitive). */
15
+ hemisphere?: string;
16
+ }
17
+
18
+ /** Result of classify(). */
19
+ export interface KoppenClassification {
20
+ /** Köppen–Geiger code, e.g. 'Cfa'. */
21
+ code: string;
22
+ /** Human-readable class name, e.g. 'humid subtropical'. */
23
+ label: string;
24
+ /** Top-level letter, e.g. 'C'. */
25
+ group: string;
26
+ /** Top-level name, e.g. 'Temperate'. */
27
+ groupLabel: string;
28
+ /** One-sentence plain-language summary. */
29
+ blurb: string;
30
+ }
31
+
32
+ /**
33
+ * Classify a location's Köppen–Geiger climate from 12 monthly mean
34
+ * temperatures (°C) and 12 monthly precipitation totals (mm). Throws
35
+ * TypeError on malformed input.
36
+ */
37
+ export function classify(opts: ClassifyOptions): KoppenClassification;
38
+
39
+ /** Human-readable names for the Köppen–Geiger codes the classifier can emit. */
40
+ export const KOPPEN_NAMES: Record<string, string>;
41
+
42
+ /** Top-level group letter → short name ('A' → 'Tropical', …). */
43
+ export const GROUP_NAMES: {
44
+ A: string;
45
+ B: string;
46
+ C: string;
47
+ D: string;
48
+ E: string;
49
+ };
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@verifyhash/koppen-classifier",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Zero-dependency Köppen–Geiger climate classifier from 12 monthly mean-temperature and precipitation values (hemisphere-aware).",
5
5
  "main": "index.js",
6
+ "types": "index.d.ts",
6
7
  "type": "commonjs",
7
8
  "scripts": {
8
9
  "test": "node test/koppen.test.js"
@@ -18,7 +19,8 @@
18
19
  "license": "MIT",
19
20
  "files": [
20
21
  "index.js",
21
- "README.md"
22
+ "README.md",
23
+ "index.d.ts"
22
24
  ],
23
25
  "publishConfig": {
24
26
  "access": "public"