calc-vpd 0.1.1 → 1.0.0

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 (3) hide show
  1. package/index.js +6 -3
  2. package/package.json +10 -11
  3. package/readme.md +7 -20
package/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict'
2
2
 
3
+ const floor8 = n => Math.round(n * 10 ** 9) / 10 ** 9
4
+
3
5
  module.exports = (input /*: { tmp: number, hmd: number } */) => {
4
6
  const { tmp, hmd } = input || {}
5
7
 
@@ -8,11 +10,12 @@ module.exports = (input /*: { tmp: number, hmd: number } */) => {
8
10
  `Expected a { tmp: number, hmd: number }, got ${typeof tmp} ${typeof hmd}`
9
11
  )
10
12
  }
13
+
11
14
  // vaporPressur
12
- const vp = 6.1078 * Math.pow(10, (7.5 * tmp) / (tmp + 237.3))
13
- const swv = (217 * vp) / (tmp + 273.15)
15
+ const vp = floor8(6.1078 * Math.pow(10, (7.5 * tmp) / (tmp + 237.3)))
16
+ const swv = floor8((217 * vp) / (tmp + 273.15))
14
17
  // amount of saturated water vapor
15
- const vpd = ((100 - hmd) * swv) / 100
18
+ const vpd = floor8(((100 - hmd) * swv) / 100)
16
19
 
17
20
  return { vp, swv, vpd }
18
21
  }
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "calc-vpd",
3
- "version": "0.1.1",
3
+ "version": "1.0.0",
4
4
  "description": "VPD (Vapor Pressure Deficit) function",
5
5
  "license": "MIT",
6
6
  "repository": "elzup/calc-vpd",
7
7
  "author": "elzup",
8
8
  "engines": {
9
- "node": ">=8"
9
+ "node": ">=14"
10
10
  },
11
11
  "scripts": {
12
- "add-contributor": "all-contributors add",
13
12
  "precommit": "lint-staged",
14
13
  "fmt": "prettier --write '**/*.{js,json,md}'",
15
14
  "lint": "eslint --ext .js .",
16
15
  "test": "jest",
17
16
  "test:cov": "jest --coverage --ci --runInBand",
18
- "test:ci": "yarn lint && yarn test:cov"
17
+ "test:ci": "yarn lint && yarn test:cov",
18
+ "prepare": "husky install"
19
19
  },
20
20
  "lint-staged": {
21
21
  "*.{js,json,md}": [
@@ -33,12 +33,11 @@
33
33
  ],
34
34
  "dependencies": {},
35
35
  "devDependencies": {
36
- "all-contributors-cli": "6.13.0",
37
- "eslint": "6.8.0",
38
- "eslint-config-nzap": "1.4.6",
39
- "husky": "4.2.1",
40
- "jest": "25.1.0",
41
- "lint-staged": "10.0.7",
42
- "prettier": "1.19.1"
36
+ "eslint": "8.18.0",
37
+ "eslint-config-nzap": "5.3.2",
38
+ "husky": "8.0.1",
39
+ "jest": "28.1.2",
40
+ "lint-staged": "13.0.3",
41
+ "prettier": "2.7.1"
43
42
  }
44
43
  }
package/readme.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # calc-vpd
2
2
 
3
- [![Build Status](https://travis-ci.org/elzup/calc-vpd.svg?branch=master)](https://travis-ci.org/elzup/calc-vpd)
3
+ ![Node.js CI](https://github.com/elzup/calc-vpd/workflows/Node.js%20CI/badge.svg)
4
4
  [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)
5
5
 
6
6
  > VPD (Vapor Pressure Deficit) function
7
7
 
8
- 水蒸気圧 = 6.107810 ^ ((7.5 _ 気温 / (気温 + 237.3)))
9
- 飽和水蒸気量 = 217 _ 水蒸気圧 / (気温 + 273.15)
10
- 飽差 = (100 - 相対湿度) \* 飽和水蒸気量 / 100
8
+ - 水蒸気圧 = 6.1078 \* 10 ^ ((7.5 - 気温 / (気温 + 237.3)))
9
+ - 飽和水蒸気量 = 217 - 水蒸気圧 / (気温 + 273.15)
10
+ - 飽差 = (100 - 相対湿度) \* 飽和水蒸気量 / 100
11
11
 
12
12
  参考: http://bigbearfarm.blog.fc2.com/blog-entry-306.html
13
13
 
@@ -24,9 +24,9 @@ const calcVpd = require('calc-vpd')
24
24
 
25
25
  calcVpd({ tmp: 29.2, hmd: 76.5 })
26
26
  //=> {
27
- // "swv": 29.08025234404583,
28
- // "vp": 40.518038231438965,
29
- // "vpd": 6.83385930085077,
27
+ // "swv": 29.080252344,
28
+ // "vp": 40.518038231,
29
+ // "vpd": 6.833859301,
30
30
  // }
31
31
  ```
32
32
 
@@ -52,16 +52,3 @@ vpd: 飽差
52
52
  ## License
53
53
 
54
54
  MIT © [elzup](https://elzup.com)
55
-
56
- ## Contributors
57
-
58
- Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
59
-
60
- <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
61
- <!-- prettier-ignore -->
62
- | [<img src="https://avatars3.githubusercontent.com/u/2284908?v=4" width="100px;"/><br /><sub><b>elzup</b></sub>](https://elzup.com)<br />[💻](https://github.com/elzup/calc-vpd/commits?author=elzup "Code") |
63
- | :---: |
64
-
65
- <!-- ALL-CONTRIBUTORS-LIST:END -->
66
-
67
- This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!