jsthermalcomfort 0.0.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 +9 -0
- package/README.md +9 -0
- package/lib/cjs/index.js +74 -0
- package/lib/cjs/types/index.d.ts +28 -0
- package/lib/cjs/types/index.d.ts.map +1 -0
- package/lib/esm/index.mjs +68 -0
- package/lib/esm/types/index.d.ts +28 -0
- package/lib/esm/types/index.d.ts.map +1 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019-2023, Federico Tartarini
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# jsthermalcomfort
|
|
2
|
+
jsthermalcomfort is a JavaScript package that allows users to calculate thermal comfort indices, including Predicted Mean Vote (PMV), Standard Effective Temperature (SET), and Predicted Heat Strain (PHS).
|
|
3
|
+
|
|
4
|
+
## Installation
|
|
5
|
+
Using npm:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm install jsthermalcomfort
|
|
9
|
+
```
|
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.goodBye = exports.helloWorld = exports.heatIndex = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Calculates the Heat Index (HI). It combines air temperature and relative humidity to determine an apparent temperature.
|
|
6
|
+
*
|
|
7
|
+
* @param tdb Dry bulb air temperature, default in [°C] in [°F] if `units` = 'IP'.
|
|
8
|
+
* @param rh Relative humidity, [%].
|
|
9
|
+
* @param options (Optional) Other parameters.
|
|
10
|
+
* @param options.round If True rounds output value, if False it does not round it.
|
|
11
|
+
* @param options.units Select the SI (International System of Units) or the IP (Imperial Units) system.
|
|
12
|
+
*
|
|
13
|
+
* @returns Heat Index, default in [°C] in [°F] if `units` = 'IP'.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const hi = heatIndex(25, 50); // returns 25.9
|
|
17
|
+
*/
|
|
18
|
+
function heatIndex(tdb, rh, options = {}) {
|
|
19
|
+
const defaultOptions = {
|
|
20
|
+
round: true,
|
|
21
|
+
units: "SI",
|
|
22
|
+
};
|
|
23
|
+
let round, units;
|
|
24
|
+
let heatIndexOptions;
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
heatIndexOptions = { round, units } = Object.assign(defaultOptions, options);
|
|
27
|
+
let hi;
|
|
28
|
+
if (units === "SI") {
|
|
29
|
+
hi =
|
|
30
|
+
-8.784695 +
|
|
31
|
+
1.61139411 * tdb +
|
|
32
|
+
2.338549 * rh -
|
|
33
|
+
0.14611605 * tdb * rh -
|
|
34
|
+
0.012308094 * Math.pow(tdb, 2) -
|
|
35
|
+
0.016424828 * Math.pow(rh, 2) +
|
|
36
|
+
0.002211732 * Math.pow(tdb, 2) * rh +
|
|
37
|
+
0.00072546 * tdb * Math.pow(rh, 2) -
|
|
38
|
+
0.000003582 * Math.pow(tdb, 2) * Math.pow(rh, 2);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
hi =
|
|
42
|
+
-42.379 +
|
|
43
|
+
2.04901523 * tdb +
|
|
44
|
+
10.14333127 * rh -
|
|
45
|
+
0.22475541 * tdb * rh -
|
|
46
|
+
0.00683783 * Math.pow(tdb, 2) -
|
|
47
|
+
0.05481717 * Math.pow(rh, 2) +
|
|
48
|
+
0.00122874 * Math.pow(tdb, 2) * rh +
|
|
49
|
+
0.00085282 * tdb * Math.pow(rh, 2) -
|
|
50
|
+
0.00000199 * Math.pow(tdb, 2) * Math.pow(rh, 2);
|
|
51
|
+
}
|
|
52
|
+
if (round) {
|
|
53
|
+
return Math.round(hi * 10) / 10;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return hi;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.heatIndex = heatIndex;
|
|
60
|
+
function helloWorld() {
|
|
61
|
+
const message = 'Hello World from my example modern npm package!';
|
|
62
|
+
return message;
|
|
63
|
+
}
|
|
64
|
+
exports.helloWorld = helloWorld;
|
|
65
|
+
function goodBye() {
|
|
66
|
+
const message = 'Goodbye from my example modern npm package!';
|
|
67
|
+
return message;
|
|
68
|
+
}
|
|
69
|
+
exports.goodBye = goodBye;
|
|
70
|
+
exports.default = {
|
|
71
|
+
helloWorld,
|
|
72
|
+
heatIndex,
|
|
73
|
+
goodBye,
|
|
74
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface HeatIndexOptions {
|
|
2
|
+
round?: boolean;
|
|
3
|
+
units?: "SI" | "IP";
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Calculates the Heat Index (HI). It combines air temperature and relative humidity to determine an apparent temperature.
|
|
7
|
+
*
|
|
8
|
+
* @param tdb Dry bulb air temperature, default in [°C] in [°F] if `units` = 'IP'.
|
|
9
|
+
* @param rh Relative humidity, [%].
|
|
10
|
+
* @param options (Optional) Other parameters.
|
|
11
|
+
* @param options.round If True rounds output value, if False it does not round it.
|
|
12
|
+
* @param options.units Select the SI (International System of Units) or the IP (Imperial Units) system.
|
|
13
|
+
*
|
|
14
|
+
* @returns Heat Index, default in [°C] in [°F] if `units` = 'IP'.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const hi = heatIndex(25, 50); // returns 25.9
|
|
18
|
+
*/
|
|
19
|
+
export declare function heatIndex(tdb: number, rh: number, options?: HeatIndexOptions): number;
|
|
20
|
+
export declare function helloWorld(): string;
|
|
21
|
+
export declare function goodBye(): string;
|
|
22
|
+
declare const _default: {
|
|
23
|
+
helloWorld: typeof helloWorld;
|
|
24
|
+
heatIndex: typeof heatIndex;
|
|
25
|
+
goodBye: typeof goodBye;
|
|
26
|
+
};
|
|
27
|
+
export default _default;
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAyCzF;AAED,wBAAgB,UAAU,WAGzB;AAED,wBAAgB,OAAO,WAGtB;;;;;;AAED,wBAIE"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the Heat Index (HI). It combines air temperature and relative humidity to determine an apparent temperature.
|
|
3
|
+
*
|
|
4
|
+
* @param tdb Dry bulb air temperature, default in [°C] in [°F] if `units` = 'IP'.
|
|
5
|
+
* @param rh Relative humidity, [%].
|
|
6
|
+
* @param options (Optional) Other parameters.
|
|
7
|
+
* @param options.round If True rounds output value, if False it does not round it.
|
|
8
|
+
* @param options.units Select the SI (International System of Units) or the IP (Imperial Units) system.
|
|
9
|
+
*
|
|
10
|
+
* @returns Heat Index, default in [°C] in [°F] if `units` = 'IP'.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const hi = heatIndex(25, 50); // returns 25.9
|
|
14
|
+
*/
|
|
15
|
+
export function heatIndex(tdb, rh, options = {}) {
|
|
16
|
+
const defaultOptions = {
|
|
17
|
+
round: true,
|
|
18
|
+
units: "SI",
|
|
19
|
+
};
|
|
20
|
+
let round, units;
|
|
21
|
+
let heatIndexOptions;
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
heatIndexOptions = { round, units } = Object.assign(defaultOptions, options);
|
|
24
|
+
let hi;
|
|
25
|
+
if (units === "SI") {
|
|
26
|
+
hi =
|
|
27
|
+
-8.784695 +
|
|
28
|
+
1.61139411 * tdb +
|
|
29
|
+
2.338549 * rh -
|
|
30
|
+
0.14611605 * tdb * rh -
|
|
31
|
+
0.012308094 * Math.pow(tdb, 2) -
|
|
32
|
+
0.016424828 * Math.pow(rh, 2) +
|
|
33
|
+
0.002211732 * Math.pow(tdb, 2) * rh +
|
|
34
|
+
0.00072546 * tdb * Math.pow(rh, 2) -
|
|
35
|
+
0.000003582 * Math.pow(tdb, 2) * Math.pow(rh, 2);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
hi =
|
|
39
|
+
-42.379 +
|
|
40
|
+
2.04901523 * tdb +
|
|
41
|
+
10.14333127 * rh -
|
|
42
|
+
0.22475541 * tdb * rh -
|
|
43
|
+
0.00683783 * Math.pow(tdb, 2) -
|
|
44
|
+
0.05481717 * Math.pow(rh, 2) +
|
|
45
|
+
0.00122874 * Math.pow(tdb, 2) * rh +
|
|
46
|
+
0.00085282 * tdb * Math.pow(rh, 2) -
|
|
47
|
+
0.00000199 * Math.pow(tdb, 2) * Math.pow(rh, 2);
|
|
48
|
+
}
|
|
49
|
+
if (round) {
|
|
50
|
+
return Math.round(hi * 10) / 10;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return hi;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export function helloWorld() {
|
|
57
|
+
const message = 'Hello World from my example modern npm package!';
|
|
58
|
+
return message;
|
|
59
|
+
}
|
|
60
|
+
export function goodBye() {
|
|
61
|
+
const message = 'Goodbye from my example modern npm package!';
|
|
62
|
+
return message;
|
|
63
|
+
}
|
|
64
|
+
export default {
|
|
65
|
+
helloWorld,
|
|
66
|
+
heatIndex,
|
|
67
|
+
goodBye,
|
|
68
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface HeatIndexOptions {
|
|
2
|
+
round?: boolean;
|
|
3
|
+
units?: "SI" | "IP";
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Calculates the Heat Index (HI). It combines air temperature and relative humidity to determine an apparent temperature.
|
|
7
|
+
*
|
|
8
|
+
* @param tdb Dry bulb air temperature, default in [°C] in [°F] if `units` = 'IP'.
|
|
9
|
+
* @param rh Relative humidity, [%].
|
|
10
|
+
* @param options (Optional) Other parameters.
|
|
11
|
+
* @param options.round If True rounds output value, if False it does not round it.
|
|
12
|
+
* @param options.units Select the SI (International System of Units) or the IP (Imperial Units) system.
|
|
13
|
+
*
|
|
14
|
+
* @returns Heat Index, default in [°C] in [°F] if `units` = 'IP'.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const hi = heatIndex(25, 50); // returns 25.9
|
|
18
|
+
*/
|
|
19
|
+
export declare function heatIndex(tdb: number, rh: number, options?: HeatIndexOptions): number;
|
|
20
|
+
export declare function helloWorld(): string;
|
|
21
|
+
export declare function goodBye(): string;
|
|
22
|
+
declare const _default: {
|
|
23
|
+
helloWorld: typeof helloWorld;
|
|
24
|
+
heatIndex: typeof heatIndex;
|
|
25
|
+
goodBye: typeof goodBye;
|
|
26
|
+
};
|
|
27
|
+
export default _default;
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAyCzF;AAED,wBAAgB,UAAU,WAGzB;AAED,wBAAgB,OAAO,WAGtB;;;;;;AAED,wBAIE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jsthermalcomfort",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A JavaScript package to calculate thermal comfort indices (e.g., Predicted Mean Vote, Standard Effective Temperature, Predicted Heat Strain).",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"import": {
|
|
8
|
+
"types": "./lib/esm/types/index.d.ts",
|
|
9
|
+
"default": "./lib/esm/index.mjs"
|
|
10
|
+
},
|
|
11
|
+
"require": {
|
|
12
|
+
"types": "./lib/cjs/types/index.d.ts",
|
|
13
|
+
"default": "./lib/cjs/index.js"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"types": "./lib/cjs/types/index.d.ts",
|
|
18
|
+
"main": "./lib/cjs/index.js",
|
|
19
|
+
"files": [
|
|
20
|
+
"lib/**/*"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"clean": "rm -rf ./lib",
|
|
24
|
+
"build": "npm run clean && npm run build:esm && npm run build:cjs",
|
|
25
|
+
"build:esm": "tsc -p ./configs/tsconfig.esm.json && mv lib/esm/index.js lib/esm/index.mjs",
|
|
26
|
+
"build:cjs": "tsc -p ./configs/tsconfig.cjs.json",
|
|
27
|
+
"test": "mocha",
|
|
28
|
+
"semantic-release": "semantic-release",
|
|
29
|
+
"prepack": "npm run build"
|
|
30
|
+
},
|
|
31
|
+
"release": {
|
|
32
|
+
"branches": [
|
|
33
|
+
"main"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/FedericoTartarini/jsthermalcomfort.git"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"thermal comfort",
|
|
45
|
+
"heat stress",
|
|
46
|
+
"predicted mean vote",
|
|
47
|
+
"human thermophysiological modeling"
|
|
48
|
+
],
|
|
49
|
+
"author": "Federico Tartarini",
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/FedericoTartarini/jsthermalcomfort/issues"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://github.com/FedericoTartarini/jsthermalcomfort#readme",
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/chai": "^4.3.4",
|
|
57
|
+
"@types/mocha": "^10.0.1",
|
|
58
|
+
"chai": "^4.3.7",
|
|
59
|
+
"mocha": "^10.2.0",
|
|
60
|
+
"ts-node": "^10.9.1"
|
|
61
|
+
}
|
|
62
|
+
}
|