@gybdev/node-red-e6b 0.0.0-stage → 0.1.4

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gyarmati Balázs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,256 @@
1
- # Temporary Holding Version
1
+ # @gybdev/node-red-e6b
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Deterministic flight-planning calculator nodes for Node-RED, named after the E6B flight computer. They are built
4
+ to be called as tools by an AI agent during small-aircraft pre-flight preparation: every result is computed, never
5
+ guessed, carries the formula it used (`keplet`) and a list of warnings (`figyelmeztetesek`), and keeps the exact
6
+ value next to the rounded one.
7
+
8
+ | Node | Agent tool name | What it does |
9
+ |---|---|---|
10
+ | `e6b-metar` | `metar` | Decodes a raw METAR/SPECI into structured fields and a short Hungarian summary |
11
+ | `e6b-wind` | `wind` | Headwind / crosswind components for a runway, including gusts |
12
+ | `e6b-altitude` | `altitude` | Pressure altitude, ISA temperature and deviation, density altitude |
13
+ | `e6b-weight-balance` | `weight_balance` | Mass and balance against MTOW and the CG envelope |
14
+
15
+ **Not for operational use.** The formulas are standard training approximations; the aircraft data used in tests is
16
+ fictional. Always use the approved flight manual of the actual aircraft.
17
+
18
+ ## Install
19
+
20
+ ```
21
+ npm install @gybdev/node-red-e6b
22
+ ```
23
+
24
+ Requires Node.js >= 20 and Node-RED >= 4. The nodes appear in the **E6B** palette category.
25
+
26
+ ## Conventions
27
+
28
+ - Input: a JSON object in `msg.payload` (a JSON string is also accepted). Output: the result in `msg.payload`.
29
+ - Field names carry their unit: `_kt`, `_ft`, `_kg`, `_mm`, `_c`, `_hpa`, `_deg`.
30
+ - Rounding: wind components up to the next whole knot in absolute value, towards safety (11.2 -> 12, -7.9 -> -8);
31
+ altitude 50 ft, mass 1 kg, CG 1 mm (half away from zero). The `_pontos` ("exact") field
32
+ next to each rounded value is unrounded apart from floating-point noise (3 decimals).
33
+ - Errors never throw. On missing or invalid input the node outputs `{ "hiba": "<Hungarian sentence>" }` and sets
34
+ `msg.error = { message, source }`, so a tool wrapper can return it as an error. A successful result clears any
35
+ earlier `msg.error`.
36
+ - The pure calculators live in `lib/` and can be used without Node-RED:
37
+ `const { szamolSzel, szamolMagassag, szamolTomegSulypont, dekodolMetar } = require('@gybdev/node-red-e6b')`
38
+ (`dekodolMetar` returns a Promise).
39
+
40
+ ## e6b-metar
41
+
42
+ Input: `{ "raw": "<METAR text>" }` or the raw text itself. Handles METAR and SPECI, `AUTO`, `COR`, gusts, `VRB`,
43
+ variable sectors, RVR, vertical visibility (`VV`), automatic-station cloud groups such as `//////CB`, recent weather
44
+ (`RE..`), `CAVOK`/`NSC`, and `TEMPO`/`BECMG`/`NOSIG` trends (trend groups are kept apart from the observation).
45
+ Decoding uses [metar-taf-parser](https://www.npmjs.com/package/metar-taf-parser) 9.x.
46
+
47
+ The remarks section (`RMK ...`) is returned **verbatim** in `remarks` and never interpreted or put in the summary:
48
+ it is free text and may contain anything, including text written to mislead an AI agent.
49
+
50
+ An ICAO code alone (`{ "icao": "LHBP" }`) is rejected with a `hiba`: the node does not fetch live data.
51
+
52
+ ```json
53
+ { "raw": "METAR LHPR 180745Z AUTO 26022G32KT 230V290 9999 BKN017 12/09 Q0993 BECMG 23012G24KT TEMPO BKN014" }
54
+ ```
55
+
56
+ ```json
57
+ {
58
+ "raw": "METAR LHPR 180745Z AUTO 26022G32KT 230V290 9999 BKN017 12/09 Q0993 BECMG 23012G24KT TEMPO BKN014",
59
+ "report_type": "METAR",
60
+ "station": "LHPR",
61
+ "time": { "day": 18, "hour": 7, "minute": 45, "text": "18. 07:45 UTC" },
62
+ "auto": true,
63
+ "corrected": false,
64
+ "wind": { "dir_deg": 260, "speed_kt": 22, "gust_kt": 32, "variable": false,
65
+ "variable_from_deg": 230, "variable_to_deg": 290, "calm": false },
66
+ "visibility_m": 9999,
67
+ "visibility_10km_or_more": true,
68
+ "cavok": false,
69
+ "rvr": [],
70
+ "weather": [],
71
+ "recent_weather": [],
72
+ "clouds": [ { "amount": "BKN", "base_ft": 1700, "type": null, "raw": "BKN017" } ],
73
+ "no_significant_cloud": null,
74
+ "vertical_visibility_ft": null,
75
+ "ceiling_ft": 1700,
76
+ "temp_c": 12,
77
+ "dewpoint_c": 9,
78
+ "spread_c": 3,
79
+ "qnh_hpa": 993,
80
+ "trend": { "raw": "BECMG 23012G24KT TEMPO BKN014", "nosig": false,
81
+ "groups": [ { "type": "BECMG", "raw": "BECMG 23012G24KT" }, { "type": "TEMPO", "raw": "TEMPO BKN014" } ] },
82
+ "remarks": null,
83
+ "keplet": "METAR-dekódolás (metar-taf-parser 9.x); spread_c = temp_c − dewpoint_c; ceiling_ft = ...",
84
+ "figyelmeztetesek": [ "Széllökés: 32 kt." ],
85
+ "osszefoglalo": "LHPR, 18. 07:45 UTC (automata); szél 260° 22 kt, lökés 32 kt, ingadozik 230°–290° között; látás ≥ 10 km; felhőzet tört (5–7/8) 1700 ft; hőmérséklet 12 °C, harmatpont 9 °C; QNH 993 hPa; trend: BECMG 23012G24KT TEMPO BKN014."
86
+ }
87
+ ```
88
+
89
+ Other fields: `weather[]` (`code`, `intensity`, `descriptor`, `phenomena`, Hungarian `leiras`), `rvr[]`
90
+ (`runway`, `min_m`, `max_m`, `indicator`, `trend`), `clouds[].amount`/`base_ft` are `null` when the station
91
+ reported `///`. `ceiling_ft` is the lowest BKN/OVC base or the vertical visibility.
92
+
93
+ ## e6b-wind
94
+
95
+ Input:
96
+
97
+ | Field | Required | Meaning |
98
+ |---|---|---|
99
+ | `szelirany_deg` | yes, unless `valtozo` | wind direction, degrees **true** (as in the METAR); `"VRB"` is accepted |
100
+ | `szelero_kt` | yes | mean wind speed, kt |
101
+ | `lokes_kt` | no | gust speed, kt |
102
+ | `valtozo` | no | `true` for VRB wind |
103
+ | `palya` | one of the two | runway designator, e.g. `"31R"` → 310° magnetic |
104
+ | `palyairany_deg` | one of the two | exact magnetic runway heading (wins over `palya`) |
105
+ | `deklinacio_deg` | no | magnetic declination, east positive; default from the node setting, else 5.8 |
106
+
107
+ Formula: `alfa = (wind_true − declination) − runway_magnetic`, headwind `= V·cos(alfa)` (negative = tailwind),
108
+ crosswind `= V·sin(alfa)` (positive = from the right). With gusts both values are computed. With `VRB` wind the
109
+ components are `null` and `legrosszabb_oldalszel_kt = V`.
110
+
111
+ ```json
112
+ { "szelirany_deg": 340, "szelero_kt": 15, "lokes_kt": 25, "palya": "31R" }
113
+ ```
114
+
115
+ ```json
116
+ {
117
+ "bemenet": { "szelirany_deg": 340, "szelero_kt": 15, "lokes_kt": 25, "valtozo": false,
118
+ "palyairany_mag_deg": 310, "palyairany_forras": "palya", "deklinacio_deg": 5.8 },
119
+ "keplet": "alfa = (szélirány_földrajzi − deklináció) − pályairány_mágneses; ...",
120
+ "szelirany_mag_deg": 334.2,
121
+ "szelszog_deg": 24.2,
122
+ "ellenszel_kt": 14,
123
+ "ellenszel_kt_pontos": 13.682,
124
+ "oldalszel_kt": 6,
125
+ "oldalszel_kt_pontos": 6.149,
126
+ "oldal": "jobbról",
127
+ "hatszel": false,
128
+ "lokes": { "ellenszel_kt": 23, "ellenszel_kt_pontos": 22.803, "oldalszel_kt": 10,
129
+ "oldalszel_kt_pontos": 10.248, "oldal": "jobbról", "hatszel": false },
130
+ "legrosszabb_oldalszel_kt": 10,
131
+ "figyelmeztetesek": [ "Széllökés: 25 kt; lökésben az oldalszél 10 kt, az ellenszél 23 kt." ]
132
+ }
133
+ ```
134
+
135
+ `oldal` is `"jobbról"` (from the right), `"balról"` (from the left) or `"nincs"` (rounds to 0).
136
+
137
+ ## e6b-altitude
138
+
139
+ Input: `{ "reptermagassag_ft": 495, "qnh_hpa": 1000, "homerseklet_c": 9 }` (QNH must be in hPa, 900–1100).
140
+
141
+ Formulas: `PA = elevation + (1013 − QNH)·30`, `ISA = 15 − 2·PA/1000`, `DA = PA + 120·(OAT − ISA)`.
142
+
143
+ ```json
144
+ {
145
+ "bemenet": { "reptermagassag_ft": 495, "qnh_hpa": 1000, "homerseklet_c": 9 },
146
+ "nyomasmagassag_ft": 900,
147
+ "nyomasmagassag_ft_pontos": 892.5,
148
+ "isa_homerseklet_c": 13.2,
149
+ "isa_homerseklet_c_pontos": 13.215,
150
+ "isa_elteres_c": -4.2,
151
+ "isa_elteres_c_pontos": -4.215,
152
+ "surusegmagassag_ft": 400,
153
+ "surusegmagassag_ft_pontos": 386.7,
154
+ "keplet": "PA = reptérmagasság_ft + (1013 − QNH)·30; ISA = 15 − 2·PA/1000 °C; ...",
155
+ "figyelmeztetesek": []
156
+ }
157
+ ```
158
+
159
+ Temperatures are rounded to 0.1 °C.
160
+
161
+ ## e6b-weight-balance
162
+
163
+ Input: `{ "gep": <aircraft data sheet>, "terheles": <load> }`.
164
+
165
+ Aircraft data sheet:
166
+
167
+ ```json
168
+ {
169
+ "lajtstromjel": "HA-TST2",
170
+ "ures_tomeg_kg": 420, "ures_kar_mm": 850, "max_felszallo_tomeg_kg": 680,
171
+ "terhelesi_helyek": [
172
+ { "nev": "pilota", "kar_mm": 1050, "max_kg": 110 },
173
+ { "nev": "utas", "kar_mm": 1050, "max_kg": 110 },
174
+ { "nev": "csomagter", "kar_mm": 1650, "max_kg": 25 }
175
+ ],
176
+ "uzemanyag": { "max_liter": 80, "kar_mm": 1120, "suruseg_kg_per_l": 0.72 },
177
+ "burkologorbe": [
178
+ { "tomeg_kg": 450, "kar_mm": 860 }, { "tomeg_kg": 550, "kar_mm": 860 }, { "tomeg_kg": 680, "kar_mm": 880 },
179
+ { "tomeg_kg": 680, "kar_mm": 980 }, { "tomeg_kg": 450, "kar_mm": 980 }
180
+ ]
181
+ }
182
+ ```
183
+
184
+ Load: `{ "pilota_kg": 80, "utas_kg": 75, "csomagter_kg": 10, "uzemanyag_liter": 60 }`. Keys are station names with
185
+ an optional `_kg` suffix. `pilota`, `utas`, `csomagter` (when the aircraft has them) and `uzemanyag_liter` are
186
+ required; other stations of the aircraft (e.g. `hatso_ules_kg`) default to 0 with a warning. A load on a station
187
+ the aircraft does not have is an error (a 0 there is only a warning). Exceeding a station's `max_kg` or the tank
188
+ capacity is a warning and sets `tullepve`. Fuel density defaults to 0.72 kg/l (AVGAS).
189
+
190
+ Optional sheet fields: `csoportkorlatok` – shared limits over several stations, e.g. a seat row for pilot and
191
+ passenger: `[{ "nev": "elso_ulesek", "helyek": ["pilota", "utas"], "max_kg": 150 }]` (result: `csoportkorlatok`
192
+ with `tullepve`); `max_uzemanyag_nelkuli_tomeg_kg` (MZFW) – the zero-fuel mass is checked against it (result:
193
+ `mzfw_alatt`). Both feed `rendben`. Other fields (e.g. `referenciasik`, `max_leszallo_tomeg_kg`) are ignored.
194
+
195
+ The envelope is a polygon of (arm, mass) corner points; a point on its boundary counts as inside. The forward and
196
+ aft CG limits at the current mass are the outermost crossings of the polygon at that mass (exact for a convex
197
+ envelope).
198
+
199
+ ```json
200
+ {
201
+ "lajtstromjel": "HA-TST2",
202
+ "tetelek": [
203
+ { "nev": "ures_gep", "tomeg_kg": 420, "kar_mm": 850, "nyomatek_kgmm": 357000, "max_kg": null, "tullepve": false },
204
+ { "nev": "pilota", "tomeg_kg": 80, "kar_mm": 1050, "nyomatek_kgmm": 84000, "max_kg": 110, "tullepve": false },
205
+ { "nev": "utas", "tomeg_kg": 75, "kar_mm": 1050, "nyomatek_kgmm": 78750, "max_kg": 110, "tullepve": false },
206
+ { "nev": "csomagter", "tomeg_kg": 10, "kar_mm": 1650, "nyomatek_kgmm": 16500, "max_kg": 25, "tullepve": false },
207
+ { "nev": "uzemanyag", "tomeg_kg": 43.2, "kar_mm": 1120, "nyomatek_kgmm": 48384, "max_kg": null, "tullepve": false,
208
+ "liter": 60, "max_liter": 80, "suruseg_kg_per_l": 0.72 }
209
+ ],
210
+ "ossztomeg_kg": 628,
211
+ "ossztomeg_kg_pontos": 628.2,
212
+ "ossznyomatek_kgmm": 584634,
213
+ "sulypont_mm": 931,
214
+ "sulypont_mm_pontos": 930.649,
215
+ "max_felszallo_tomeg_kg": 680,
216
+ "mtow_alatt": true,
217
+ "mtow_tartalek_kg": 52,
218
+ "mtow_tartalek_kg_pontos": 51.8,
219
+ "burkolon_belul": true,
220
+ "sulypont_hatarok_mm": { "elso_mm": 872.031, "hatso_mm": 980 },
221
+ "tartalek_elso_hatarig_mm": 59,
222
+ "tartalek_hatso_hatarig_mm": 49,
223
+ "legkozelebbi_hatar_mm": 49,
224
+ "helyenkenti_tullepes": false,
225
+ "uzemanyag_nelkul": { "tomeg_kg": 585, "sulypont_mm": 917, "sulypont_mm_pontos": 916.667, "burkolon_belul": true },
226
+ "rendben": true,
227
+ "keplet": "nyomaték = tömeg · kar (kg·mm); súlypont = Σnyomaték / Σtömeg (mm); ...",
228
+ "figyelmeztetesek": []
229
+ }
230
+ ```
231
+
232
+ `burkolon_belul` is the envelope check alone; `rendben` is true only when the CG is inside the envelope, the mass is
233
+ within MTOW and no station limit is exceeded. `uzemanyag_nelkul` repeats the check with empty tanks.
234
+
235
+ ## Tests
236
+
237
+ ```
238
+ npm test
239
+ ```
240
+
241
+ `node --test`, no Node-RED needed. When the package sits in its original workspace, the tests also decode every
242
+ recorded METAR of the shared test set and check that the aircraft fixtures match the shared aircraft files.
243
+
244
+ ## Magyar összefoglaló
245
+
246
+ Determinisztikus repülési számolók Node-RED-hez, amelyeket egy MI-ügynök eszközként hív a repülés előtti
247
+ felkészülésben. Négy csomópont: METAR-dekódolás (`metar`), szélkomponensek (`wind`), nyomás- és sűrűségmagasság
248
+ (`altitude`), tömeg és súlypont (`weight_balance`). A bemenet a `msg.payload` JSON-objektuma, az eredmény ugyanide
249
+ kerül. Minden kimenet tartalmazza a használt képletet (`keplet`), a figyelmeztetéseket (`figyelmeztetesek`), a
250
+ kerekített és a pontos értéket. Hibás vagy hiányzó bemenetnél nincs kivétel: a kimenet `{ "hiba": "..." }`, és a
251
+ `msg.error` is beállul. A METAR `RMK` része szó szerint, értelmezés nélkül kerül vissza. Nem éles használatra: a
252
+ tesztekben szereplő gépadatok kitaláltak.
253
+
254
+ ## License
255
+
256
+ MIT
package/index.js ADDED
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ /** Pure calculators, usable without Node-RED. */
4
+ module.exports = {
5
+ ...require('./lib/metar'),
6
+ ...require('./lib/wind'),
7
+ ...require('./lib/altitude'),
8
+ ...require('./lib/weight-balance'),
9
+ };
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ const { biztonsagos, payloadObjektum, szamMezo, kerekit, pontos } = require('./common');
4
+
5
+ const KEPLET =
6
+ 'PA = reptérmagasság_ft + (1013 − QNH)·30; ISA = 15 − 2·PA/1000 °C; ' +
7
+ 'ISA-eltérés = OAT − ISA; DA = PA + 120·(OAT − ISA)';
8
+
9
+ /**
10
+ * Pressure and density altitude.
11
+ * @param {object|string} payload { reptermagassag_ft, qnh_hpa, homerseklet_c }
12
+ */
13
+ function szamolMagassag(payload) {
14
+ return biztonsagos(() => {
15
+ const p = payloadObjektum(payload);
16
+ const elev = szamMezo(p, 'reptermagassag_ft', { nev: 'reptérmagasság', min: -1500, max: 15000 });
17
+ const qnh = szamMezo(p, 'qnh_hpa', { nev: 'QNH (hPa)', min: 900, max: 1100 });
18
+ const oat = szamMezo(p, 'homerseklet_c', { nev: 'külső hőmérséklet', min: -60, max: 60 });
19
+
20
+ const pa = elev + (1013 - qnh) * 30;
21
+ const isa = 15 - (2 * pa) / 1000;
22
+ const elteres = oat - isa;
23
+ const da = pa + 120 * elteres;
24
+
25
+ const figyelmeztetesek = [];
26
+ if (da - elev >= 1000) {
27
+ figyelmeztetesek.push(
28
+ `A sűrűségmagasság ${kerekit(da - elev, 10)} ft-tal a reptér felett van: csökkent motor- és emelkedőteljesítmény, hosszabb nekifutás.`
29
+ );
30
+ }
31
+
32
+ return {
33
+ bemenet: { reptermagassag_ft: elev, qnh_hpa: qnh, homerseklet_c: oat },
34
+ nyomasmagassag_ft: kerekit(pa, 50),
35
+ nyomasmagassag_ft_pontos: pontos(pa),
36
+ isa_homerseklet_c: kerekit(isa, 0.1),
37
+ isa_homerseklet_c_pontos: pontos(isa),
38
+ isa_elteres_c: kerekit(elteres, 0.1),
39
+ isa_elteres_c_pontos: pontos(elteres),
40
+ surusegmagassag_ft: kerekit(da, 50),
41
+ surusegmagassag_ft_pontos: pontos(da),
42
+ keplet: KEPLET,
43
+ figyelmeztetesek,
44
+ };
45
+ });
46
+ }
47
+
48
+ module.exports = { szamolMagassag, KEPLET };
package/lib/common.js ADDED
@@ -0,0 +1,92 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Shared helpers: input errors, number parsing and rounding.
5
+ * Every calculator returns either a result object or `{ hiba: "<Hungarian sentence>" }`; none throws.
6
+ */
7
+
8
+ class BemenetiHiba extends Error {}
9
+
10
+ /** Throw an input error that the calculator turns into `{ hiba }`. */
11
+ function hiba(uzenet) {
12
+ throw new BemenetiHiba(uzenet);
13
+ }
14
+
15
+ /** Run a calculator body and convert any error into the `{ hiba }` convention. */
16
+ function biztonsagos(fn) {
17
+ try {
18
+ return fn();
19
+ } catch (e) {
20
+ if (e instanceof BemenetiHiba) return { hiba: e.message };
21
+ return { hiba: `Belső hiba a számolás közben: ${e && e.message ? e.message : String(e)}` };
22
+ }
23
+ }
24
+
25
+ /** Accept `msg.payload` as an object or a JSON string; anything else is an input error. */
26
+ function payloadObjektum(payload) {
27
+ let p = payload;
28
+ if (typeof p === 'string') {
29
+ try {
30
+ p = JSON.parse(p);
31
+ } catch (_) {
32
+ hiba('A bemenet nem érvényes JSON-objektum.');
33
+ }
34
+ }
35
+ if (p === null || typeof p !== 'object' || Array.isArray(p)) {
36
+ hiba('A bemenetnek JSON-objektumnak kell lennie (msg.payload).');
37
+ }
38
+ return p;
39
+ }
40
+
41
+ function vanErtek(v) {
42
+ return v !== undefined && v !== null && !(typeof v === 'string' && v.trim() === '');
43
+ }
44
+
45
+ /** Parse a number given as a number or numeric string (decimal comma accepted). NaN if not numeric. */
46
+ function szamma(v) {
47
+ if (typeof v === 'number') return v;
48
+ if (typeof v === 'string' && /^\s*[+-]?\d+(?:[.,]\d+)?\s*$/.test(v)) return Number(v.trim().replace(',', '.'));
49
+ return NaN;
50
+ }
51
+
52
+ /**
53
+ * Required finite number with optional range check.
54
+ * @param {object} obj source object
55
+ * @param {string} kulcs field name
56
+ * @param {{min?:number,max?:number,nev?:string,kotelezo?:boolean}} opts
57
+ */
58
+ function szamMezo(obj, kulcs, opts = {}) {
59
+ const nev = opts.nev || kulcs;
60
+ const v = obj[kulcs];
61
+ if (!vanErtek(v)) {
62
+ if (opts.kotelezo === false) return undefined;
63
+ hiba(`Hiányzó bemenet: ${nev} (${kulcs}).`);
64
+ }
65
+ const n = szamma(v);
66
+ if (!Number.isFinite(n)) hiba(`A(z) ${kulcs} mező nem szám: ${JSON.stringify(v)}.`);
67
+ if (opts.min !== undefined && n < opts.min) hiba(`A(z) ${kulcs} értéke (${n}) kisebb a megengedettnél (${opts.min}).`);
68
+ if (opts.max !== undefined && n > opts.max) hiba(`A(z) ${kulcs} értéke (${n}) nagyobb a megengedettnél (${opts.max}).`);
69
+ return n;
70
+ }
71
+
72
+ function nullaNelkul(x) {
73
+ return Object.is(x, -0) ? 0 : x;
74
+ }
75
+
76
+ /** Round half away from zero to a step (1 kt, 50 ft, 1 kg, 1 mm). */
77
+ function kerekit(x, lepes = 1) {
78
+ if (x === null || x === undefined || !Number.isFinite(x)) return null;
79
+ const r = Math.sign(x) * Math.round(Math.abs(x) / lepes) * lepes;
80
+ return nullaNelkul(Number(r.toFixed(6)));
81
+ }
82
+
83
+ /**
84
+ * The "exact" (unrounded) value for the output: only floating-point noise is removed
85
+ * (3 decimals, far below every tolerance in the shared interface).
86
+ */
87
+ function pontos(x) {
88
+ if (x === null || x === undefined || !Number.isFinite(x)) return null;
89
+ return nullaNelkul(Number(x.toFixed(3)));
90
+ }
91
+
92
+ module.exports = { BemenetiHiba, hiba, biztonsagos, payloadObjektum, vanErtek, szamma, szamMezo, kerekit, pontos };