Skip to content

Commit ad9d6fa

Browse files
authored
Merge pull request #1 from oyve/dev
Merge dev into main
2 parents 4c92970 + 04ce37c commit ad9d6fa

21 files changed

+4317
-1071
lines changed

.github/workflows/node.js.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,34 @@ on:
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
1615

1716
strategy:
1817
matrix:
19-
node-version: [20.x, 22.x]
18+
node-version: [18.x, 20.x, 22.x]
2019

2120
steps:
22-
- uses: actions/checkout@v2
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
2324
- name: Use Node.js ${{ matrix.node-version }}
24-
uses: actions/setup-node@v1
25+
uses: actions/setup-node@v4
2526
with:
2627
node-version: ${{ matrix.node-version }}
27-
- run: npm ci
28-
- run: npm run build --if-present
29-
- run: npm test
28+
29+
- name: Cache Node.js modules
30+
uses: actions/cache@v3
31+
with:
32+
path: ~/.npm
33+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
34+
restore-keys: |
35+
${{ runner.os }}-node-
36+
37+
- name: Install dependencies
38+
run: npm ci
39+
40+
- name: Build project
41+
run: npm run build
42+
43+
- name: Run tests
44+
run: npm test

.github/workflows/npm-publish.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
22
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
33

4-
name: Node.js Package
4+
name: Publish to npm
55

66
on:
77
release:
@@ -14,20 +14,26 @@ jobs:
1414
- uses: actions/checkout@v4
1515
- uses: actions/setup-node@v4
1616
with:
17-
node-version: 20
17+
node-version: 'lts/*'
1818
- run: npm ci
1919
- run: npm test
2020

2121
publish-npm:
2222
needs: build
2323
runs-on: ubuntu-latest
2424
steps:
25-
- uses: actions/checkout@v4
26-
- uses: actions/setup-node@v4
25+
- name: Checkout code
26+
uses: actions/checkout@v3
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v3
2729
with:
28-
node-version: 20
30+
node-version: 'lts/*'
2931
registry-url: https://registry.npmjs.org/
30-
- run: npm ci
31-
- run: npm publish
32+
- name: install dependencies
33+
run: npm ci
34+
- name: Build project
35+
run: npm run build
36+
- name: Publish to npm
37+
run: npm publish --access public
3238
env:
3339
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

.npmignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Exclude node_modules (npm automatically excludes this)
2+
node_modules
3+
4+
# Exclude TypeScript source files
5+
src
6+
7+
# Exclude test files and directories
8+
tests
9+
*.test.ts
10+
11+
# Exclude build and configuration files
12+
tsconfig.json
13+
jest.config.js
14+
15+
# Exclude environment files
16+
.env
17+
.env.local
18+
19+
# Exclude IDE and editor-specific files
20+
.vscode
21+
.idea
22+
23+
# Exclude Git-related files
24+
.git
25+
.gitignore
26+
27+
# Exclude logs and temporary files
28+
*.log
29+
*.tmp
30+
*.swp
31+
32+
# Exclude other unnecessary files
33+
.DS_Store
34+
Thumbs.db

LICENSE

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
MIT License
1+
GNU GENERAL PUBLIC LICENSE
2+
Version 3, 29 June 2007
23

3-
Copyright (c) 2020 Øyvind
4+
Copyright (C) 2025 Øyvind Hansen <oyve-github@outlook.com>
45

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:
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
1110

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
1415

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.
16+
You should have received a copy of the GNU General Public License
17+
along with this program. If not, see <https://www.gnu.org/licenses/>.

README.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
![Node.js CI](https://github.com/oyve/weather-formulas/workflows/Node.js%20CI/badge.svg?branch=main)
1+
![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg) ![Node.js CI](https://github.com/oyve/weather-formulas/workflows/Node.js%20CI/badge.svg?branch=main)
22
# weather-formulas
33
A library of atmospheric and weather related calculations.
44

5-
* Test code for all code/algorithms
6-
* Supports custom valuation sets where needed
5+
* Test code for all formulas
6+
* Supports custom valuation sets where supported
77

88
## Features
99

@@ -26,6 +26,7 @@ A library of atmospheric and weather related calculations.
2626
### Pressure
2727
- [Pressure Altitude](https://en.wikipedia.org/wiki/Pressure_altitude)
2828
- [Density Altitude](https://en.wikipedia.org/wiki/Density_altitude)
29+
- [Adjust Pressure To Sea Level](https://en.wikipedia.org/wiki/Atmospheric_pressure)
2930

3031
## Install
3132
```
@@ -34,37 +35,39 @@ $ npm install weather-formulas
3435

3536
## How to use
3637
```
37-
const WF = require('weather-formulas');
38+
//Option #1 - accessing all
39+
const wf = require('weather-formulas');
40+
wf.temperature, wf.humidity, wf.pressure
3841
39-
const TEMPERATURE = 300, HUMIDITY = 60, WINDSPEED = 10; //300 Kelvin, 60% Relative Humidity, 10 M/S
40-
41-
let dewPointMF = WF.dewPointMagnusFormula(TEMPERATURE, HUMIDITY);
42-
let dewPointAF = WF.dewPointArdenBuckEquation(TEMPERATURE, HUMIDITY);
43-
let windChill = WF.windChillIndex(TEMPERATURE, WINDSPEED);
44-
let apparentTemperature = WF.australianAapparentTemperature(TEMPERATURE, HUMIDITY, WINDSPEED);
45-
let heatIndex = WF.heatIndex(TEMPERATURE, HUMIDITY);
46-
let heatIndexText = WF.heatIndexText(heatIndex); //output heat index threshold and warning text
42+
//Option #2 - accessing directly
43+
import { temperature, humidity, pressure } from 'weather-formulas'
44+
```
45+
```
46+
//With Option #1
47+
let RH = wf.humidity.relativeHumidity(TEMPERATURE, DEW_POINT);
48+
...
4749
48-
let humidex = WF.humidex(TEMPERATURE, HUMIDITY);
49-
let humidexText = WF.humidexText(humidex); //output humidex threshold and warning text
50+
//With Option #2
51+
let RH = humidity.relativeHumidity(TEMPERATURE, DEW_POINT);
52+
...
5053
5154
```
5255

5356
**Advanced examples**
5457

5558
Use a provided valuation set
5659
```
57-
const valuationSet = temperature.DEW_POINT_VALUATIONS.DAVID_BOLTON;
58-
const actual = temperature.dewPointMagnusFormula(TEMPERATURE, HUMIDITY, valuationSet);
60+
const valuationSet = wf.temperature.DEW_POINT_VALUATIONS.DAVID_BOLTON;
61+
const actual = wf.temperature.dewPointMagnusFormula(TEMPERATURE, HUMIDITY, valuationSet);
5962
```
6063
Use a custom valuation set
6164
```
62-
const valuationSet = { a: 6, b: 17, c: 250, d: 234.5 }; //these values are made up for the sake of example
63-
const actual = temperature.dewPointArdenBuckEquation(TEMPERATURE, HUMIDITY, valuationSet);
65+
const valuationSet = { a: 6, b: 17, c: 250, d: 234.5 };
66+
const actual = wf.temperature.dewPointArdenBuckEquation(TEMPERATURE, HUMIDITY, valuationSet);
6467
```
6568

6669
## Contribute
67-
Please feel free to contribute by creating a Pull Request with test code.
70+
Please feel free to contribute by creating a Pull Request including test code.
6871

6972
## Disclaimer
7073
Always verify calculations before using in production as edge cases due to floating point errors may exists for large numbers, and that are not covered by tests today. Please report!

humidity.js

Lines changed: 0 additions & 62 deletions
This file was deleted.

jest.config.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export default {
2+
preset: 'ts-jest',
3+
transform: {
4+
'^.+\\.ts$': [
5+
'ts-jest', // Transformer for TypeScript files
6+
{
7+
useESM: true, // Enable ES Modules support for TypeScript
8+
},
9+
],
10+
},
11+
extensionsToTreatAsEsm: ['.ts'], // Treat .ts files as ES modules
12+
moduleFileExtensions: ['ts', 'js'], // Include both .ts and .js extensions for Jest
13+
testMatch: ['**/*.test.ts'], // Ensure Jest picks up .test.ts files for tests
14+
};

0 commit comments

Comments
 (0)