Comparing version 1.0.1 to 2.0.0
'use strict'; | ||
module.exports.isNil = function (variable) { | ||
return variable == null; | ||
}; | ||
const isNumber = module.exports.isNumber = Number.isFinite; | ||
var isFinite = Number.isFinite; | ||
module.exports.isFinite = isFinite; | ||
module.exports.isCorrect = data => !(data == null) && isNumber(data); | ||
module.exports.unitsFormat = function (_units) { | ||
var units = { | ||
temp: 'c', | ||
speed: 'mps' | ||
}; | ||
if (_units) { | ||
if (_units.temp) { | ||
var temp = _units.temp.toLowerCase(); | ||
if (temp === 'f' || temp === 'fahrenheit') { | ||
units.temp = 'f'; | ||
} else if (temp === 'k' || temp === 'kelvin') { | ||
units.temp = 'k'; | ||
} else { | ||
units.temp = 'c'; | ||
} | ||
} | ||
if (_units.speed) { | ||
var speed = _units.speed.toLowerCase(); | ||
if (speed === 'mph' || speed === 'mi/h') { | ||
units.speed = 'mph'; | ||
} else if (speed === 'kmh' || speed === 'kph' || speed === 'kmph' || speed === 'km/h') { | ||
units.speed = 'kph'; | ||
} else { | ||
units.speed = 'mps'; | ||
} | ||
} | ||
const tempFormat = temp => { | ||
if (temp === 'f' || temp === 'fahrenheit') { | ||
return 'f'; | ||
} else if (temp === 'k' || temp === 'kelvin') { | ||
return 'k'; | ||
} | ||
return units; | ||
return 'c'; | ||
}; | ||
module.exports.tempConvert = function (temp, from, to) { | ||
if (!isFinite(temp)) { | ||
throw new TypeError('Temp must be specified and must be a number'); | ||
} else if (from === to) { | ||
return temp; | ||
} else if (['c', 'f', 'k'].indexOf(to) === -1) { | ||
throw new RangeError('Units must be c, f or k'); | ||
} else if (from === 'c') { | ||
return (to === 'f') ? (temp * 1000 * (9 / 5) + 32 * 1000) / 1000 : (temp * 1000 + 273.15 * 1000) / 1000; | ||
} else if (from === 'f') { | ||
return (to === 'c') ? ((temp - 32) * 1000 * (5 / 9)) / 1000 : ((temp + 459.67) * 1000 * (5 / 9)) / 1000; | ||
} else if (from === 'k') { | ||
return (to === 'c') ? (temp * 1000 - 273.15 * 1000) / 1000 : (temp * 1000 * (9 / 5) - 459.67 * 1000) / 1000; | ||
} else { | ||
throw new RangeError('Units must be c, f or k'); | ||
const speedFormat = speed => { | ||
if (speed === 'mph' || speed === 'mi/h') { | ||
return 'mph'; | ||
} else if (['kmh', 'kph', 'kmph', 'km/h'].indexOf(speed) !== -1) { | ||
return 'kph'; | ||
} | ||
return 'mps'; | ||
}; | ||
module.exports.speedConvert = function (speed, from, to) { | ||
if (!isFinite(speed)) { | ||
throw new TypeError('Speed must be a number'); | ||
} else if (from === to) { | ||
return speed; | ||
} else if (['mps', 'mph', 'kph'].indexOf(to) === -1) { | ||
throw new RangeError('Units must be mps, mph or kph'); | ||
} else if (from === 'mps') { | ||
return (to === 'mph') ? speed / 0.44704 : speed * 3.6; | ||
} else if (from === 'mph') { | ||
return (to === 'mps') ? speed * 0.44704 : speed * 1.609344; | ||
} else if (from === 'kph') { | ||
return (to === 'mps') ? speed / 3.6 : speed / 1.609344; | ||
} else { | ||
throw new RangeError('Units must be mps, mph or kph'); | ||
module.exports.unitsFormat = units => { | ||
if (!units) { | ||
return { | ||
temp: 'c', | ||
speed: 'mps' | ||
}; | ||
} | ||
}; | ||
function getG(temp, humidity, b, c, d) { | ||
return Math.log(humidity / 100 * Math.exp((b - temp / d) * (temp / (c + temp)))); | ||
}; | ||
const temp = (units.temp) ? units.temp.toLowerCase() : 'c'; | ||
const speed = (units.speed) ? units.speed.toLowerCase() : 'mps'; | ||
module.exports.getG = getG; | ||
module.exports.getT = function (temp, humidity, b, c, d) { | ||
return (c * getG(temp, humidity, b, c, d)) / (b - getG(temp, humidity, b, c, d)); | ||
return { temp: tempFormat(temp), speed: speedFormat(speed) }; | ||
}; | ||
module.exports.methods = { | ||
HI: { | ||
f: 'heatIndex', | ||
h: 1 | ||
}, | ||
AWBGT: { | ||
f: 'AWBGT', | ||
h: 1 | ||
}, | ||
HI_CA: { | ||
f: 'humidex', | ||
h: 1 | ||
}, | ||
AAT: { | ||
f: 'AAT', | ||
h: -1 | ||
}, | ||
WCI: { | ||
f: 'windChill', | ||
h: 0 | ||
} | ||
}; |
527
main.js
'use strict'; | ||
var helpers = require('./lib/helpers'); | ||
var isNil = helpers.isNil; | ||
var unitsFormat = helpers.unitsFormat; | ||
var tempConvert = helpers.tempConvert; | ||
var speedConvert = helpers.speedConvert; | ||
var getT = helpers.getT; | ||
var _methods = helpers.methods; | ||
const h = require('./lib/helpers'); | ||
function feelsLike(opts) { | ||
opts || (opts = {}); | ||
opts.units = unitsFormat(opts.units); | ||
return new Feels(opts); | ||
} | ||
const isCorrect = h.isCorrect; | ||
const unitsFormat = h.unitsFormat; | ||
module.exports = feelsLike; | ||
const BaseFeels = require('./lib/base'); | ||
function Feels(opts) { | ||
this.units = opts.units; | ||
this.temp = opts.temp; | ||
this.speed = opts.speed || 0; | ||
this.humidity = opts.humidity; | ||
this.dewPoint = opts.dewPoint; | ||
this._units = { | ||
temp: opts.units.temp, | ||
speed: opts.units.speed | ||
}; | ||
} | ||
function apparentTemp(tempConvert, func) { | ||
if (isCorrect(this.temp) && (isCorrect(this.humidity) || isCorrect(this.dewPoint))) { | ||
const units = this.units.temp; | ||
const u = this._units.temp; | ||
const temp = tempConvert(this.temp, units, 'c'); | ||
Feels.prototype.like = function (methods) { | ||
var temp = tempConvert(this.temp, this.units.temp, 'c'); | ||
if ((Array.isArray(methods) || typeof methods === 'string') && methods.length) { | ||
if (typeof methods === 'string') { | ||
if (_methods[methods.toUpperCase()]) { | ||
return this[_methods[methods.toUpperCase()].f](); | ||
} else { | ||
throw new RangeError('Methods must be one of: HI, HI_CA, AAT, WCI'); | ||
} | ||
} else { | ||
var like = 0; | ||
var count = 0; | ||
const index = (isCorrect(this.dewPoint) && !isCorrect(this.humidity)) ? | ||
func(temp, tempConvert(this.dewPoint, units, 'c'), true) : | ||
func(temp, this.humidity); | ||
methods.forEach(function(n) { | ||
if (_methods[n.toUpperCase()]) { | ||
try { | ||
like += this[_methods[n.toUpperCase()].f](); | ||
count++; | ||
} catch (e) { } | ||
} else { | ||
throw new RangeError('Methods must be one of: HI, HI_CA, AAT, WCI'); | ||
} | ||
}.bind(this)); | ||
return tempConvert(index, 'c', u); | ||
} | ||
throw new Error('One of the required arguments are not specified'); | ||
} | ||
if (count === 0) throw new Error('No valid methods for these values'); | ||
return like / count; | ||
} | ||
} else { | ||
if (temp <= 0) { | ||
return (this.windChill() + this.AAT()) / 2; | ||
} else if (temp >= 20) { | ||
return (this.heatIndex() + this.humidex() + this.AAT()) / 3; | ||
} else { | ||
return (this.humidex() + this.AAT()) / 2; | ||
} | ||
class Feels extends BaseFeels { | ||
constructor(opts) { | ||
super(); | ||
this.setOptions(opts); | ||
this._methods = { | ||
HI: 'heatIndex', | ||
AWBGT: 'AWBGT', | ||
HI_CA: 'humidex', | ||
AAT: 'AAT', | ||
WCI: 'windChill' | ||
}; | ||
} | ||
}; | ||
Feels.prototype.toCelsius = function () { | ||
this._units.temp = 'c'; | ||
return this; | ||
}; | ||
setOptions(opts) { | ||
opts = opts || {}; | ||
this.units = unitsFormat(opts.units); | ||
this.temp = opts.temp; | ||
this.speed = opts.speed || 0; | ||
this.humidity = opts.humidity; | ||
this.dewPoint = opts.dewPoint; | ||
this.wvp = opts.wvp; | ||
this._units = { | ||
temp: this.units.temp, | ||
speed: this.units.speed | ||
}; | ||
return this; | ||
} | ||
Feels.prototype.toC = Feels.prototype.toCelsius; | ||
Feels.prototype.toFahrenheit = function () { | ||
this._units.temp = 'f'; | ||
return this; | ||
}; | ||
Feels.prototype.toF = Feels.prototype.toFahrenheit; | ||
Feels.prototype.toKelvin = function () { | ||
this._units.temp = 'k'; | ||
return this; | ||
}; | ||
Feels.prototype.toK = Feels.prototype.toKelvin; | ||
Feels.prototype.heatIndex = function (temp, humidity, dewPoint) { //HI | ||
if ( | ||
(!isNil(temp) || !isNil(this.temp)) && | ||
(!isNil(humidity) || !isNil(this.humidity) || !isNil(this.dewPoint)) | ||
) { | ||
!isNil(temp) || (temp = this.temp); | ||
var units = this.units || { temp: 'c' }; | ||
var _units = this._units || { temp: 'c' }; | ||
var _temp = tempConvert(temp, units.temp, 'f'); | ||
if (_temp < 68) { | ||
throw new RangeError('Heat Index temp must be >= (20C, 68F, 293.15K)'); | ||
registerMethod(method) { | ||
if (this[method]) { | ||
this._methods[method.toUpperCase()] = method; | ||
return this; | ||
} | ||
throw new Error(`${method} doesn't exists`); | ||
} | ||
if (dewPoint || !isNil(this.dewPoint)) { | ||
!isNil(humidity) || (humidity = this.dewPoint); | ||
humidity = this.getRH(temp, humidity, true); | ||
} else { | ||
!isNil(humidity) || (humidity = this.humidity); | ||
if (humidity < 0 || humidity > 100) { | ||
throw new RangeError('Humidity must be in [0, 100]'); | ||
registerMethods(methods) { | ||
if (Array.isArray(methods)) { | ||
for (const method of methods) { | ||
this.registerMethod(method); | ||
} | ||
return this; | ||
} | ||
var HI = 16.923 + 0.185212 * _temp + 5.37941 * humidity - 0.100254 * _temp * humidity + 9.41695 * Math.pow(10, -3) * Math.pow(_temp, 2) + 7.28898 * Math.pow(10, -3) * | ||
Math.pow(humidity, 2) + 3.45372 * Math.pow(10, -4) * Math.pow(_temp, 2) * humidity - 8.14971 * Math.pow(10, -4) * _temp * Math.pow(humidity, 2) + 1.02102 * Math.pow(10, -5) * | ||
Math.pow(_temp, 2) * Math.pow(humidity, 2) - 3.8646 * Math.pow(10, -5) * Math.pow(_temp, 3) + 2.91583 * Math.pow(10, -5) * Math.pow(humidity, 3) + 1.42721 * Math.pow(10, -6) * | ||
Math.pow(_temp, 3) * humidity + 1.97483 * Math.pow(10, -7) * _temp * Math.pow(humidity, 3) - 2.18429 * Math.pow(10, -8) * Math.pow(_temp, 3) * Math.pow(humidity, 2) + | ||
8.43296 * Math.pow(10, -10) * Math.pow(_temp, 2) * Math.pow(humidity, 3) - 4.81975 * Math.pow(10, -11) * Math.pow(_temp, 3) * Math.pow(humidity, 3); | ||
return tempConvert(HI, 'f', _units.temp); | ||
} else { | ||
throw new Error('One of the required arguments are not specified'); | ||
throw new TypeError('Methods must be an array'); | ||
} | ||
}; | ||
module.exports.heatIndex = Feels.prototype.heatIndex.bind(module.exports); | ||
Feels.prototype.AWBGT = function (temp, humidity, dewPoint) { //AWBGT | ||
if ( | ||
(!isNil(temp) || !isNil(this.temp)) && | ||
(!isNil(humidity) || !isNil(this.humidity) || !isNil(this.dewPoint)) | ||
) { | ||
!isNil(temp) || (temp = this.temp); | ||
var units = this.units || { temp: 'c' }; | ||
var _units = this._units || { temp: 'c' }; | ||
var _temp = tempConvert(temp, units.temp, 'c'); | ||
if (_temp < 15) { | ||
throw new RangeError('Heat Index temp must be >= (15C, 59F, 288.15K)'); | ||
addMethod(method, func) { | ||
if (typeof func === 'function') { | ||
this[method] = func.bind(this); | ||
this.registerMethod(method); | ||
return this; | ||
} | ||
throw new TypeError(`${method} must be a function`); | ||
} | ||
if (dewPoint || !isNil(this.dewPoint)) { | ||
!isNil(humidity) || (humidity = this.dewPoint); | ||
dewPoint = true; | ||
} else { | ||
!isNil(humidity) || (humidity = this.humidity); | ||
if (humidity < 0 || humidity > 100) { | ||
throw new RangeError('Humidity must be in [0, 100]'); | ||
} | ||
} | ||
toCelsius() { | ||
this._units.temp = 'c'; | ||
return this; | ||
} | ||
return tempConvert(0.567 * _temp + 0.393 * ((dewPoint) ? this.getWVPbyDP(humidity) : this.getWVP(humidity, temp)) + 3.94, 'c', _units.temp); | ||
} else { | ||
throw new Error('One of the required arguments are not specified'); | ||
toFahrenheit() { | ||
this._units.temp = 'f'; | ||
return this; | ||
} | ||
}; | ||
module.exports.AWBGT = Feels.prototype.AWBGT.bind(module.exports); | ||
toKelvin() { | ||
this._units.temp = 'k'; | ||
return this; | ||
} | ||
Feels.prototype.humidex = function (temp, humidity, dewPoint) { //HI_CA | ||
if ( | ||
(!isNil(temp) || !isNil(this.temp)) && | ||
(!isNil(humidity) || !isNil(this.humidity) || !isNil(this.dewPoint)) | ||
) { | ||
!isNil(temp) || (temp = this.temp); | ||
var units = this.units || { temp: 'c' }; | ||
var _units = this._units || { temp: 'c' }; | ||
var _temp = tempConvert(temp, units.temp, 'c'); | ||
like(methods) { | ||
if (methods) { | ||
let count = methods.length; | ||
if (typeof methods === 'string') { | ||
const method = this._methods[methods.toUpperCase()]; | ||
if (method) { | ||
return this[method](); | ||
} | ||
throw new RangeError(`Methods must be one of: ${Object.keys(this._methods).join(', ')}`); | ||
} else if (Array.isArray(methods)) { | ||
let like = 0; | ||
for (const m of methods) { | ||
const method = this._methods[m.toUpperCase()]; | ||
if (method) { | ||
try { | ||
like += this[method](); | ||
} catch (e) { | ||
count--; | ||
} | ||
} else { | ||
// eslint-disable-next-line max-len | ||
throw new RangeError(`Methods must be one of: ${Object.keys(this._methods).join(', ')}`); | ||
} | ||
} | ||
if (_temp <= 0) { | ||
throw new RangeError('Humidex temp must be > (0C, 32F, 273.15K)'); | ||
} | ||
if (dewPoint || !isNil(this.dewPoint)) { | ||
!isNil(humidity) || (humidity = this.dewPoint); | ||
dewPoint = true; | ||
} else { | ||
!isNil(humidity) || (humidity = this.humidity); | ||
if (humidity < 0 || humidity > 100) { | ||
throw new RangeError('Humidity must be in [0, 100]'); | ||
if (!count) { | ||
throw new Error('No valid methods for these values'); | ||
} | ||
return like / count; | ||
} | ||
} | ||
return this.like(['HI', 'HI_CA', 'AAT', 'WCI']); | ||
} | ||
return tempConvert(_temp + 0.5555 * (((dewPoint) ? this.getWVPbyDP(humidity) : this.getWVP(humidity, temp)) - 10.0), 'c', _units.temp); | ||
} else { | ||
throw new Error('One of the required arguments are not specified'); | ||
heatIndex() { // HI | ||
return apparentTemp.call(this, Feels.tempConvert, Feels.heatIndex); | ||
} | ||
}; | ||
module.exports.humidex = Feels.prototype.humidex.bind(module.exports); | ||
AWBGT() { // AWBGT | ||
return apparentTemp.call(this, Feels.tempConvert, Feels.AWBGT); | ||
} | ||
Feels.prototype.AAT = function (temp, speed, humidity, dewPoint) { //AAT | ||
if ( | ||
((!isNil(temp) && !isNil(speed)) || (!isNil(this.temp) && !isNil(this.speed))) && | ||
(!isNil(humidity) || !isNil(this.humidity) || !isNil(this.dewPoint)) | ||
) { | ||
var units = this.units || { temp: 'c', speed: 'mps' }; | ||
var _units = this._units || { temp: 'c' }; | ||
humidex() { // HI_CA | ||
return apparentTemp.call(this, Feels.tempConvert, Feels.humidex); | ||
} | ||
if (isNil(temp) && isNil(speed)) { | ||
temp = this.temp; | ||
speed = this.speed; | ||
} | ||
AAT() { // AAT | ||
if ( | ||
isCorrect(this.temp) && isCorrect(this.speed) && | ||
(isCorrect(this.humidity) || isCorrect(this.dewPoint)) | ||
) { | ||
const units = this.units; | ||
const u = this._units.temp; | ||
const temp = Feels.tempConvert(this.temp, units.temp, 'c'); | ||
const speed = Feels.speedConvert(this.speed, units.speed, 'mps'); | ||
var _temp = tempConvert(temp, units.temp, 'c'); | ||
speed = speedConvert(speed, units.speed, 'mps'); | ||
const index = (isCorrect(this.dewPoint) && !isCorrect(this.humidity)) ? | ||
Feels.AAT(temp, speed, Feels.tempConvert(this.dewPoint, units.temp, 'c'), true) : | ||
Feels.AAT(temp, speed, this.humidity); | ||
if (speed < 0) { | ||
throw new RangeError('Wind speed must be >= 0'); | ||
return Feels.tempConvert(index, 'c', u); | ||
} | ||
if (dewPoint || !isNil(this.dewPoint)) { | ||
!isNil(humidity) || (humidity = this.dewPoint); | ||
dewPoint = true; | ||
} else { | ||
!isNil(humidity) || (humidity = this.humidity); | ||
if (humidity < 0 || humidity > 100) { | ||
throw new RangeError('Humidity must be in [0, 100]'); | ||
} | ||
} | ||
return tempConvert(_temp + 0.33 * ((dewPoint) ? this.getWVPbyDP(humidity) : this.getWVP(humidity, temp)) - 0.70 * speed - 4.00, 'c', _units.temp); | ||
} else { | ||
throw new Error('One of the required arguments are not specified'); | ||
} | ||
}; | ||
module.exports.AAT = Feels.prototype.AAT.bind(module.exports); | ||
windChill() { // WCI | ||
if (isCorrect(this.temp) && isCorrect(this.speed)) { | ||
const units = this.units; | ||
const u = this._units.temp; | ||
const temp = Feels.tempConvert(this.temp, units.temp, 'c'); | ||
const speed = Feels.speedConvert(this.speed, units.speed, 'mps'); | ||
Feels.prototype.windChill = function (temp, speed) { //WCI | ||
if ((!isNil(temp) && !isNil(speed)) || (!isNil(this.temp) && !isNil(this.speed))) { | ||
var units = this.units || { temp: 'c', speed: 'mps' }; | ||
var _units = this._units || { temp: 'c' }; | ||
if (isNil(temp) && isNil(speed)) { | ||
temp = this.temp; | ||
speed = this.speed; | ||
return Feels.tempConvert(Feels.windChill(temp, speed), 'c', u); | ||
} | ||
var _temp = tempConvert(temp, units.temp, 'c'); | ||
if (_temp > 0) { | ||
throw new RangeError('Wind Chill temp must be <= (0C, 32F, 273.15K)'); | ||
} else if (speed < 0) { | ||
throw new RangeError('Wind speed must be >= 0'); | ||
} | ||
speed = speedConvert(speed, units.speed, 'kph'); | ||
if (speed >= 5) { | ||
return tempConvert(13.12 + 0.6215 * _temp - 11.37 * Math.pow(speed, 0.16) + 0.3965 * _temp * Math.pow(speed, 0.16), 'c', _units.temp); | ||
} else { | ||
return tempConvert(_temp + ((-1.59 + 0.1345 * _temp) / 5) * speed, 'c', _units.temp); | ||
} | ||
} else { | ||
throw new Error('One of the required arguments are not specified'); | ||
} | ||
}; | ||
module.exports.windChill = Feels.prototype.windChill.bind(module.exports); | ||
getWaterVapourPressure() { | ||
if (isCorrect(this.wvp)) { | ||
return this.wvp; | ||
} else if (isCorrect(this.humidity) && isCorrect(this.temp)) { | ||
const units = this.units.temp; | ||
const temp = Feels.tempConvert(this.temp, units, 'c'); | ||
Feels.prototype.getWaterVapourPressure = function (humidity, temp) { | ||
if ((!isNil(humidity) && !isNil(temp)) || (!isNil(this.humidity) && !isNil(this.temp))) { | ||
var units = this.units || { temp: 'c' }; | ||
if (isNil(temp) && isNil(humidity)) { | ||
temp = this.temp; | ||
humidity = this.humidity; | ||
return Feels.getWVP(temp, this.humidity); | ||
} | ||
var _temp = tempConvert(temp, units.temp, 'c'); | ||
return (humidity < 0 || humidity > 100) ? 0 : (humidity / 100) * 6.105 * Math.exp((17.27 * _temp) / (237.7 + _temp)); | ||
} else { | ||
throw new Error('One of the required arguments are not specified'); | ||
} | ||
}; | ||
Feels.prototype.getWVP = Feels.prototype.getWaterVapourPressure; | ||
module.exports.getWVP = Feels.prototype.getWVP.bind(module.exports); | ||
getWaterVapourPressureByDewPoint() { | ||
if (isCorrect(this.wvp)) { | ||
return this.wvp; | ||
} else if (isCorrect(this.dewPoint)) { | ||
const units = this.units.temp; | ||
const dewPoint = Feels.tempConvert(this.dewPoint, units, 'c'); | ||
Feels.prototype.getWaterVapourPressureByDewPoint = function (dewPoint) { | ||
if (!isNil(dewPoint) || !isNil(this.dewPoint)) { | ||
!isNil(dewPoint) || (dewPoint = this.dewPoint); | ||
return 6.11 * Math.exp(5417.7530 * (1 / 273.16 - 1 / (tempConvert(dewPoint, (this.units) ? this.units.temp : 'c', 'c') + 273.15))); | ||
} else { | ||
return Feels.getWVPbyDP(dewPoint); | ||
} | ||
throw new Error('Dew point is not specified'); | ||
} | ||
}; | ||
Feels.prototype.getWVPbyDP = Feels.prototype.getWaterVapourPressureByDewPoint; | ||
module.exports.getWVPbyDP = Feels.prototype.getWVPbyDP.bind(module.exports); | ||
getAproximateRelativeHumidity() { | ||
if (isCorrect(this.humidity)) { | ||
return this.humidity; | ||
} else if (isCorrect(this.temp) && isCorrect(this.dewPoint)) { | ||
const units = this.units.temp; | ||
const temp = Feels.tempConvert(this.temp, units, 'c'); | ||
const dewPoint = Feels.tempConvert(this.dewPoint, units, 'c'); | ||
Feels.prototype.getAproximateRelativeHumidity = function (temp, dewPoint) { | ||
if ((!isNil(temp) && !isNil(dewPoint)) || (!isNil(this.temp) && !isNil(this.dewPoint))) { | ||
var units = this.units || { temp: 'c' }; | ||
if (isNil(temp) && isNil(dewPoint)) { | ||
temp = this.temp; | ||
dewPoint = this.dewPoint; | ||
return Feels.getARH(temp, dewPoint); | ||
} | ||
return 100 - 5 * (tempConvert(temp, units.temp, 'c') - tempConvert(dewPoint, units.temp, 'c')); | ||
} else { | ||
throw new Error('One of the required arguments are not specified'); | ||
} | ||
}; | ||
Feels.prototype.getARH = Feels.prototype.getAproximateRelativeHumidity; | ||
module.exports.getARH = Feels.prototype.getARH.bind(module.exports); | ||
getRelativeHumidity() { | ||
if (isCorrect(this.humidity)) { | ||
return this.humidity; | ||
} else if (isCorrect(this.temp) && (isCorrect(this.wvp) || isCorrect(this.dewPoint))) { | ||
const units = this.units.temp; | ||
const temp = Feels.tempConvert(this.temp, units, 'c'); | ||
Feels.prototype.getRelativeHumidity = function (temp, WVP, dewPoint) { | ||
if (this.humidity) { | ||
return this.humidity; | ||
} else if ((!isNil(temp) || !isNil(this.temp)) && (!isNil(WVP) || !isNil(this.dewPoint))) { | ||
var units = this.units || { temp: 'c' }; | ||
!isNil(temp) || (temp = this.temp); | ||
var _temp = tempConvert(temp, units.temp, 'c'); | ||
if (dewPoint || !isNil(this.dewPoint)) { | ||
!isNil(WVP) || (WVP = this.dewPoint); | ||
dewPoint = true; | ||
} else if (typeof WVP !== 'number') { | ||
throw new TypeError('WVP must be a number'); | ||
return (isCorrect(this.dewPoint) && !isCorrect(this.wvp)) ? | ||
Feels.getRH(temp, Feels.tempConvert(this.dewPoint, units, 'c'), true) : | ||
Feels.getRH(temp, this.wvp); | ||
} | ||
return (((dewPoint) ? this.getWVPbyDP(WVP) : WVP) / (6.105 * Math.exp((17.27 * _temp) / (237.7 + _temp)))) * 100; | ||
} else { | ||
throw new Error('One of the required arguments are not specified'); | ||
} | ||
}; | ||
Feels.prototype.getRH = Feels.prototype.getRelativeHumidity; | ||
module.exports.getRH = Feels.prototype.getRH.bind(module.exports); | ||
getAproximateDewPoint() { | ||
if (isCorrect(this.dewPoint)) { | ||
return this.dewPoint; | ||
} else if (isCorrect(this.temp) && isCorrect(this.humidity)) { | ||
const units = this.units.temp; | ||
const u = this._units.temp; | ||
const temp = Feels.tempConvert(this.temp, units, 'c'); | ||
Feels.prototype.getAproximateDewPoint = function (temp, humidity) { | ||
if ((!isNil(temp) && !isNil(humidity)) || (!isNil(this.temp) && !isNil(this.humidity))) { | ||
var units = this.units || { temp: 'c' }; | ||
if (isNil(temp) && isNil(humidity)) { | ||
temp = this.temp; | ||
humidity = this.humidity; | ||
return Feels.tempConvert(Feels.getADP(temp, this.humidity), 'c', u); | ||
} | ||
return (humidity >= 100 || humidity < 0) ? tempConvert(temp, units.temp, 'c') : tempConvert(temp, units.temp, 'c') - ((100 - humidity) / 5); | ||
} else { | ||
throw new Error('One of the required arguments are not specified'); | ||
} | ||
}; | ||
Feels.prototype.getADP = Feels.prototype.getAproximateDewPoint; | ||
module.exports.getADP = Feels.prototype.getADP.bind(module.exports); | ||
getDewPoint() { // dew point for [-40, 50], humidity must be in (0, 100] | ||
if (isCorrect(this.dewPoint)) { | ||
return this.dewPoint; | ||
} else if (isCorrect(this.temp) && isCorrect(this.humidity)) { | ||
const units = this.units.temp; | ||
const u = this._units.temp; | ||
const temp = Feels.tempConvert(this.temp, units, 'c'); | ||
Feels.prototype.getDewPoint = function (temp, humidity) { //dew point for [-40, 50], humidity must be in (0, 100] | ||
if (this.dewPoint) { | ||
return this.dewPoint; | ||
} else if ((!isNil(temp) && !isNil(humidity)) || (!isNil(this.temp) && !isNil(this.humidity))) { | ||
var units = this.units || { temp: 'c' }; | ||
var _units = this._units || { temp: 'c' }; | ||
if (isNil(temp) && isNil(humidity)) { | ||
temp = this.temp; | ||
humidity = this.humidity; | ||
return Feels.tempConvert(Feels.getDP(temp, this.humidity), 'c', u); | ||
} | ||
var _temp = tempConvert(temp, units.temp, 'c'); | ||
if (_temp < -40 || _temp > 50) { | ||
throw new RangeError('Dew point temp must be in [-40, 50]'); | ||
} else if (humidity <= 0 || humidity > 100) { | ||
throw new RangeError('Humidity must be in (0, 100]'); | ||
} | ||
var b = 18.729; | ||
var c = 257.87; | ||
var d = 273.3; | ||
return tempConvert(getT(_temp, humidity, b, c, d), 'c', _units.temp); | ||
} else { | ||
throw new Error('One of the required arguments are not specified'); | ||
} | ||
}; | ||
Feels.prototype.getDP = Feels.prototype.getDewPoint; | ||
module.exports.getDP = Feels.prototype.getDP.bind(module.exports); | ||
getFrostPoint() { // frost point for [-80, 0], humidity must be in (0, 100] | ||
if (isCorrect(this.temp) && isCorrect(this.humidity)) { | ||
const units = this.units.temp; | ||
const u = this._units.temp; | ||
const temp = Feels.tempConvert(this.temp, units, 'c'); | ||
Feels.prototype.getFrostPoint = function (temp, humidity) { //frost point for [-80, 0], humidity must be in (0, 100] | ||
if ((!isNil(temp) && !isNil(humidity)) || (!isNil(this.temp) && !isNil(this.humidity))) { | ||
var units = this.units || { temp: 'c' }; | ||
var _units = this._units || { temp: 'c' }; | ||
if (isNil(temp) && isNil(humidity)) { | ||
temp = this.temp; | ||
humidity = this.humidity; | ||
return Feels.tempConvert(Feels.getFP(temp, this.humidity), 'c', u); | ||
} | ||
var _temp = tempConvert(temp, units.temp, 'c'); | ||
if (_temp < -80 || _temp > 0) { | ||
throw new RangeError('Frost point temp must be in [-80, 0]'); | ||
} else if (humidity <= 0 || humidity > 100) { | ||
throw new RangeError('Humidity must be in (0, 100]'); | ||
} | ||
var b = 23.036; | ||
var c = 279.82; | ||
var d = 333.7; | ||
return tempConvert(getT(_temp, humidity, b, c, d), 'c', _units.temp); | ||
} else { | ||
throw new Error('One of the required arguments are not specified'); | ||
} | ||
}; | ||
} | ||
Feels.prototype.toC = Feels.prototype.toCelsius; | ||
Feels.prototype.toF = Feels.prototype.toFahrenheit; | ||
Feels.prototype.toK = Feels.prototype.toKelvin; | ||
Feels.prototype.getWVP = Feels.prototype.getWaterVapourPressure; | ||
Feels.prototype.getWVPbyDP = Feels.prototype.getWaterVapourPressureByDewPoint; | ||
Feels.prototype.getARH = Feels.prototype.getAproximateRelativeHumidity; | ||
Feels.prototype.getRH = Feels.prototype.getRelativeHumidity; | ||
Feels.prototype.getADP = Feels.prototype.getAproximateDewPoint; | ||
Feels.prototype.getDP = Feels.prototype.getDewPoint; | ||
Feels.prototype.getFP = Feels.prototype.getFrostPoint; | ||
module.exports.getFP = Feels.prototype.getFP.bind(module.exports); | ||
module.exports = Feels; |
{ | ||
"name": "feels", | ||
"author": "Alexey Bystrov <strikeentco@gmail.com>", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "Feels allow you to calculate apparent temperature using heat index, approximate wet-bulb globe temperature, humidex, australian apparent temperature and wind chill.", | ||
"engines": { | ||
"node": ">=4.0.0" | ||
}, | ||
"keywords": [ | ||
@@ -17,4 +20,7 @@ "humidex", | ||
"feels like", | ||
"real feel", | ||
"comfort", | ||
"temperature", | ||
"speed", | ||
"convert", | ||
"apparent", | ||
@@ -26,4 +32,11 @@ "humidity", | ||
"main": "./main.js", | ||
"files": [ | ||
"lib", | ||
"main.js" | ||
], | ||
"scripts": { | ||
"test": "mocha test", | ||
"lint": "eslint main.js lib/**", | ||
"check": "npm run lint && npm run test", | ||
"cover": "istanbul cover ./node_modules/mocha/bin/_mocha", | ||
"test-on-travis": "istanbul cover --report lcovonly ./node_modules/mocha/bin/_mocha" | ||
@@ -39,3 +52,8 @@ }, | ||
"devDependencies": { | ||
"mocha": "^2.5.3", | ||
"eslint": "^2.13.0", | ||
"eslint-config-airbnb": "^9.0.1", | ||
"eslint-plugin-import": "^1.11.0", | ||
"eslint-plugin-jsx-a11y": "^1.2.0", | ||
"eslint-plugin-react": "^5.1.1", | ||
"mocha": "^3.0.1", | ||
"should": "^10.0.0" | ||
@@ -42,0 +60,0 @@ }, |
302
README.md
@@ -1,4 +0,4 @@ | ||
feels [![License](https://img.shields.io/github/license/strikeentco/feels.svg?style=flat)](https://github.com/strikeentco/feels/blob/master/LICENSE) [![npm](https://img.shields.io/npm/v/feels.svg?style=flat)](https://www.npmjs.com/package/feels) | ||
feels [![License](https://img.shields.io/npm/l/feels.svg)](https://github.com/strikeentco/feels/blob/master/LICENSE) [![npm](https://img.shields.io/npm/v/feels.svg)](https://www.npmjs.com/package/feels) | ||
========== | ||
[![Build Status](https://travis-ci.org/strikeentco/feels.svg)](https://travis-ci.org/strikeentco/feels) [![Test Coverage](https://codeclimate.com/github/strikeentco/feels/badges/coverage.svg)](https://codeclimate.com/github/strikeentco/feels/coverage) [![bitHound Score](https://www.bithound.io/github/strikeentco/feels/badges/score.svg)](https://www.bithound.io/github/strikeentco/feels) | ||
[![Build Status](https://travis-ci.org/strikeentco/feels.svg)](https://travis-ci.org/strikeentco/feels) [![node](https://img.shields.io/node/v/feels.svg)](https://www.npmjs.com/package/feels) [![Test Coverage](https://codeclimate.com/github/strikeentco/feels/badges/coverage.svg)](https://codeclimate.com/github/strikeentco/feels/coverage) [![bitHound Score](https://www.bithound.io/github/strikeentco/feels/badges/score.svg)](https://www.bithound.io/github/strikeentco/feels) | ||
@@ -9,3 +9,3 @@ `Feels` allow you to calculate [apparent temperature](https://en.wikipedia.org/wiki/Apparent_temperature) using [heat index](https://en.wikipedia.org/wiki/Heat_index), approximate [wet-bulb globe temperature](https://en.wikipedia.org/wiki/Wet-bulb_globe_temperature), [humidex](https://en.wikipedia.org/wiki/Humidex), [australian apparent temperature](https://en.wikipedia.org/wiki/Wind_chill#Australian_Apparent_Temperature) and [wind chill](https://en.wikipedia.org/wiki/Wind_chill). | ||
You can also calculate `relative humidity`, `dew point`, `frost point`, `water vapour pressure` using [class](#class-methods) or [standalone](#standalone-methods) methods. | ||
You can also convert temperature, speed and calculate `relative humidity`, `dew point`, `frost point`, `water vapour pressure` using [class](#class-methods) or [standalone](#standalone-methods) methods. | ||
@@ -19,5 +19,5 @@ # Usage | ||
```javascript | ||
var Feels = require('feels'); | ||
const Feels = require('feels'); | ||
var config = { | ||
const config = { | ||
temp: 20, | ||
@@ -31,26 +31,78 @@ humidity: 85, | ||
}; | ||
console.log(Feels(config).like()); | ||
new Feels(config).like(); | ||
``` | ||
## Quick navigation | ||
* [Class methods](#class-methods) | ||
* [.setOptions(options)](#setoptionsoptions) | ||
* [.like([methods])](#likemethods) | ||
* [.addMethod(name, method)](#addmethodname-method) | ||
* [.registerMethod(method)](#registermethodmethod) | ||
* [.registerMethods(methods)](#registermethodsmethods) | ||
* [.heatIndex()](#heatindex) | ||
* [.AWBGT()](#awbgt) | ||
* [.humidex()](#humidex) | ||
* [.AAT()](#aat) | ||
* [.windChill()](#windchill) | ||
* [.getWVP()](#getwvp) | ||
* [.getWVPbyDP()](#getwvpbydp) | ||
* [.getARH()](#getarh) | ||
* [.getRH()](#getrh) | ||
* [.getADP()](#getadp) | ||
* [.getDP()](#getdp) | ||
* [.getFP()](#getfp) | ||
* [Standalone methods](#standalone-methods) | ||
* [Temperature convert](#temperature-convert) | ||
* [Speed convert](#speed-convert) | ||
* [Heat index](#heat-index) | ||
* [Approximate WBGT](#approximate-wbgt) | ||
* [Humidex](#humidex-1) | ||
* [Australian Apparent Temperature](#australian-apparent-temperature) | ||
* [Wind chill](#wind-chill) | ||
* [Water vapour pressure](#water-vapour-pressure) | ||
* [Approximate relative humidity](#approximate-relative-humidity) | ||
* [Relative humidity](#relative-humidity) | ||
* [Approximate dew point](#approximate-dew-point) | ||
* [Dew point](#dew-point) | ||
* [Frost point](#frost-point) | ||
# API | ||
## Class methods | ||
# Class methods | ||
Most of the class methods also available as [standalone methods](#standalone-methods). | ||
### new Feels(options) | ||
Constructor. | ||
#### Params: | ||
* **options** (*Object*) - Feels options: | ||
* **temp** (*Float*) - Temperature in `Celsius`, `Fahrenheit` or `Kelvin`, depends on units type. | ||
* **humidity** (*Float*) - Relative humidity in percent. | ||
* **speed** (*Float*) - Wind speed in meters per second, miles per hour or kilometers per hour, depends on units type. | ||
* **dewPoint** (*Float*) - Dew point in `Celsius`, `Fahrenheit`, `Kelvin` depends on units type. | ||
* **wvp** (*Float*) - Water vapour pressure in `hPa`. | ||
* **units** (*Object*) - Units type: | ||
* **temp** (*String*) - `c`, `f`, `k` (by default `c`). | ||
* **speed** (*String*) - `mps`, `mph`, `kph` (by default `mps`). | ||
```javascript | ||
var Feels = require('feels'); | ||
const Feels = require('feels'); | ||
console.log(Feels({temp: 20, humidity: 80.9}).toF().humidex()); | ||
new Feels({ temp: 20, humidity: 80.9 }).toF().humidex(); | ||
``` | ||
### Feels(options) | ||
### .setOptions(options) | ||
Sets the options. | ||
#### Params: | ||
* **options** (*Object*) - Feels options: | ||
* **temp** (*Float*) - Temperature in Celsius, Fahrenheit or Kelvin, depends on units type. | ||
* **temp** (*Float*) - Temperature in `Celsius`, `Fahrenheit` or `Kelvin`, depends on units type. | ||
* **humidity** (*Float*) - Relative humidity in percent. | ||
* **speed** (*Float*) - Wind speed in meters per second, miles per hour or kilometers per hour, depends on units type. | ||
* **dewPoint** (*Float*) - Dew point in Celsius, Fahrenheit, Kelvin depends on units type. | ||
* **dewPoint** (*Float*) - Dew point in `Celsius`, `Fahrenheit`, `Kelvin` depends on units type. | ||
* **wvp** (*Float*) - Water vapour pressure in `hPa`. | ||
* **units** (*Object*) - Units type: | ||
@@ -60,39 +112,113 @@ * **temp** (*String*) - `c`, `f`, `k` (by default `c`). | ||
### Feels().like([options]) | ||
```javascript | ||
const Feels = require('feels'); | ||
const feels = new Feels(); | ||
const config = { | ||
temp: 20, | ||
humidity: 85, | ||
speed: 20, | ||
units: { | ||
temp: 'c', | ||
speed: 'mps' | ||
} | ||
}; | ||
If options aren't provided returns an index is calculated with `['HI', 'HI_CA', 'AAT', 'WCI']`. | ||
feels.setOptions(config); | ||
feels.AAT(); | ||
``` | ||
### .like([methods]) | ||
Calculates apparent temperature using specified methods. | ||
If methods aren't provided returns an index which is calculated with `['HI', 'HI_CA', 'AAT', 'WCI']`. | ||
#### Params: | ||
* **options** (*String|Array*) - String or array with one of the apparent temperature [acronyms](#acronyms). | ||
* **[methods]** (*String|Array*) - String or array with one of the apparent temperature [acronyms](#acronyms). | ||
### Acronyms | ||
* **HI** - Heat index ([Feels().heatIndex()](#feelsoptionsheatindex) or [heatIndex()](#heat-index)). | ||
* **AWBGT** - Approximate wet-bulb globe temperature ([Feels().AWBGT()](#feelsoptionsawbgt) or [AWBGT()](#approximate-wbgt)). | ||
* **HI_CA** - Humidex ([Feels().humidex()](#feelsoptionshumidex) or [humidex()](#humidex)). | ||
* **AAT** - Australian apparent temperature ([Feels().AAT()](#feelsoptionsaat) or [AAT()](#australian-apparent-temperature)). | ||
* **WCI** - Wind chill ([Feels().windChill()](#feelsoptionswindchill) or [windChill()](#wind-chill)). | ||
* **HI** - Heat index ([Feels().heatIndex()](#heatindex) or [heatIndex()](#heat-index)). | ||
* **AWBGT** - Approximate wet-bulb globe temperature ([Feels().AWBGT()](#awbgt) or [AWBGT()](#approximate-wbgt)). | ||
* **HI_CA** - Humidex ([Feels().humidex()](#humidex) or [humidex()](#humidex-1)). | ||
* **AAT** - Australian apparent temperature ([Feels().AAT()](#aat) or [AAT()](#australian-apparent-temperature)). | ||
* **WCI** - Wind chill ([Feels().windChill()](#windchill) or [windChill()](#wind-chill)). | ||
If you want to convert temperature from one to other temperature scale, you can place `.toC()`, `.toF()` or `.toK()` before target method. | ||
### Feels(options).heatIndex() | ||
```javascript | ||
new Feels(config).toF().like(['AAT', 'HI_CA']); | ||
``` | ||
### .addMethod(name, method) | ||
Adds new method, which can be used by itself or in [`.like()`](#likemethods). | ||
#### Params: | ||
* **options** (*Object*) - Options: | ||
* **name** (*String*) - Method name. | ||
* **method** (*Function*) - The method itself. | ||
```javascript | ||
const feels = new Feels(); | ||
feels.addMethod('newbie', () => (feels.heatIndex() + feels.humidex()) / 2); | ||
feels.addMethod('newbie2', function () { | ||
return (this.heatIndex() + this.humidex()) / 2; | ||
}); | ||
feels.setOptions({ temp: 20, dewPoint: 18 }); | ||
feels.newbie(); | ||
feels.like(['AAT', 'newbie2']); | ||
``` | ||
### .registerMethod(method) | ||
#### Params: | ||
* **method** (*String*) - Method name. | ||
### .registerMethods(methods) | ||
Allows you to create your own methods which can be used in [`.like()`](#likemethods), by inheriting the base class. | ||
#### Params: | ||
* **methods** (*Array*) - Method names. | ||
```javascript | ||
class NewFeels extends Feels { | ||
constructor(opts) { | ||
super(opts); | ||
this.registerMethods(['newbie', 'newbie2']); | ||
} | ||
newbie() { | ||
return (this.heatIndex() + this.humidex()) / 2; | ||
} | ||
newbie2() { | ||
return (this.heatIndex() + this.humidex()) / 2; | ||
} | ||
} | ||
const feels = new NewFeels({ temp: 20, dewPoint: 18 }); | ||
feels.newbie(); | ||
feels.like(['AAT', 'newbie2']); | ||
``` | ||
### .heatIndex() | ||
#### Params: | ||
* **options** (*Object*) - Constructor options: | ||
* **temp** (*Float*) | ||
* **humidity|dewPoint** (*Float*) | ||
### Feels(options).AWBGT() | ||
### .AWBGT() | ||
#### Params: | ||
* **options** (*Object*) - Options: | ||
* **options** (*Object*) - Constructor options: | ||
* **temp** (*Float*) | ||
* **humidity|dewPoint** (*Float*) | ||
### Feels(options).humidex() | ||
### .humidex() | ||
#### Params: | ||
* **options** (*Object*) - Options: | ||
* **options** (*Object*) - Constructor options: | ||
* **temp** (*Float*) | ||
* **humidity|dewPoint** (*Float*) | ||
### Feels(options).AAT() | ||
### .AAT() | ||
#### Params: | ||
* **options** (*Object*) - Options: | ||
* **options** (*Object*) - Constructor options: | ||
* **temp** (*Float*) | ||
@@ -102,46 +228,46 @@ * **speed** (*Float*) | ||
### Feels(options).windChill() | ||
### .windChill() | ||
#### Params: | ||
* **options** (*Object*) - Options: | ||
* **options** (*Object*) - Constructor options: | ||
* **temp** (*Float*) | ||
* **speed** (*Float*) | ||
### Feels(options).getWVP() | ||
### .getWVP() | ||
#### Params: | ||
* **options** (*Object*) - Options: | ||
* **options** (*Object*) - Constructor options: | ||
* **humidity** (*Float*) | ||
* **temp** (*Float*) | ||
### Feels(options).getWVPbyDP() | ||
### .getWVPbyDP() | ||
#### Params: | ||
* **options** (*Object*) - Options: | ||
* **options** (*Object*) - Constructor options: | ||
* **dewPoint** (*Float*) | ||
### Feels(options).getARH() | ||
### .getARH() | ||
#### Params: | ||
* **options** (*Object*) - Options: | ||
* **options** (*Object*) - Constructor options: | ||
* **temp** (*Float*) | ||
* **dewPoint** (*Float*) | ||
### Feels(options).getRH() | ||
### .getRH() | ||
#### Params: | ||
* **options** (*Object*) - Options: | ||
* **options** (*Object*) - Constructor options: | ||
* **temp** (*Float*) | ||
* **dewPoint** (*Float*) | ||
* **wvp|dewPoint** (*Float*) | ||
### Feels(options).getADP() | ||
### .getADP() | ||
#### Params: | ||
* **options** (*Object*) - Options: | ||
* **options** (*Object*) - Constructor options: | ||
* **temp** (*Float*) | ||
* **humidity** (*Float*) | ||
### Feels(options).getDP() | ||
### .getDP() | ||
#### Params: | ||
* **options** (*Object*) - Options: | ||
* **options** (*Object*) - Constructor options: | ||
* **temp** (*Float*) | ||
* **humidity** (*Float*) | ||
### Feels(options).getFP() | ||
### .getFP() | ||
#### Params: | ||
* **options** (*Object*) - Options: | ||
* **options** (*Object*) - Constructor options: | ||
* **temp** (*Float*) | ||
@@ -167,7 +293,39 @@ * **humidity** (*Float*) | ||
```javascript | ||
var humidex = require('feels').humidex; | ||
const Feels = require('feels'); | ||
console.log(humidex(20, 80.9)); | ||
Feels.humidex(20, 80.9); | ||
``` | ||
## Temperature convert | ||
### Feels.tempConvert(temp, from, to) | ||
#### Params: | ||
* **temp** (*Float*) - Temperature. | ||
* **from** (*String*) - `c` - Celsius, `f` - Fahrenheit, `k` - Kelvin. | ||
* **to** (*String*) - `c` - Celsius, `f` - Fahrenheit, `k` - Kelvin. | ||
```javascript | ||
const Feels = require('feels'); | ||
const humidex = Feels.humidex(20, 80.9); | ||
Feels.tempConvert(humidex, 'c', 'f'); | ||
``` | ||
## Speed convert | ||
### Feels.speedConvert(speed, from, to) | ||
#### Params: | ||
* **speed** (*Float*) - Speed. | ||
* **from** (*String*) - `mps` - Metre per second, `mph` - Miles per hour, `kph` - Kilometre per hour. | ||
* **to** (*String*) - `mps` - Metre per second, `mph` - Miles per hour, `kph` - Kilometre per hour. | ||
```javascript | ||
const Feels = require('feels'); | ||
const speed = Feels.speedConvert(36, 'kph', 'mps'); | ||
Feels.AAT(20, speed, 89); | ||
``` | ||
## Heat index | ||
@@ -179,9 +337,9 @@ | ||
### heatIndex(temp, humidity) | ||
### Feels.heatIndex(temp, humidity) | ||
#### Params: | ||
* **temp** (*Float*) - Temperature in Celsius. | ||
* **humidity** (*Integer*) - Humidity in percent (from 0 to 100). | ||
* **humidity** (*Integer*) - Humidity in percent (0 > humidity <= 100). | ||
### heatIndex(temp, dewPoint, true) | ||
### Feels.heatIndex(temp, dewPoint, true) | ||
@@ -199,9 +357,9 @@ #### Params: | ||
### AWBGT(temp, humidity) | ||
### Feels.AWBGT(temp, humidity) | ||
#### Params: | ||
* **temp** (*Float*) - Temperature in Celsius. | ||
* **humidity** (*Integer*) - Humidity in percent (from 0 to 100). | ||
* **humidity** (*Integer*) - Humidity in percent (0 > humidity <= 100). | ||
### AWBGT(temp, dewPoint, true) | ||
### Feels.AWBGT(temp, dewPoint, true) | ||
@@ -219,9 +377,9 @@ #### Params: | ||
### humidex(temp, humidity) | ||
### Feels.humidex(temp, humidity) | ||
#### Params: | ||
* **temp** (*Float*) - Temperature in Celsius. | ||
* **humidity** (*Integer*) - Humidity in percent (from 0 to 100). | ||
* **humidity** (*Integer*) - Humidity in percent (0 > humidity <= 100). | ||
### humidex(temp, dewPoint, true) | ||
### Feels.humidex(temp, dewPoint, true) | ||
@@ -237,3 +395,3 @@ #### Params: | ||
### AAT(temp, speed, humidity) | ||
### Feels.AAT(temp, speed, humidity) | ||
@@ -243,5 +401,5 @@ #### Params: | ||
* **speed** (*Float*) - Speed in meters per second. | ||
* **humidity** (*Integer*) - Humidity in percent (from 0 to 100). | ||
* **humidity** (*Integer*) - Humidity in percent (0 > humidity <= 100). | ||
### AAT(temp, speed, dewPoint, true) | ||
### Feels.AAT(temp, speed, dewPoint, true) | ||
@@ -260,3 +418,3 @@ #### Params: | ||
### windChill(temp, speed) | ||
### Feels.windChill(temp, speed) | ||
@@ -269,9 +427,9 @@ #### Params: | ||
### getWVP(humidity, temp) | ||
### Feels.getWVP(temp, humidity) | ||
#### Params: | ||
* **humidity** (*Integer*) - Humidity in percent (from 0 to 100). | ||
* **temp** (*Float*) - Temperature in Celsius. | ||
* **humidity** (*Integer*) - Humidity in percent (0 > humidity <= 100). | ||
### getWVPbyDP(dewPoint) | ||
### Feels.getWVPbyDP(dewPoint) | ||
@@ -283,3 +441,3 @@ #### Params: | ||
### getARH(temp, dewPoint) | ||
### Feels.getARH(temp, dewPoint) | ||
@@ -292,3 +450,3 @@ #### Params: | ||
### getRH(temp, WVP) | ||
### Feels.getRH(temp, WVP) | ||
@@ -299,3 +457,3 @@ #### Params: | ||
### getRH(temp, dewPoint, true) | ||
### Feels.getRH(temp, dewPoint, true) | ||
@@ -309,23 +467,23 @@ #### Params: | ||
### getADP(temp, humidity) | ||
### Feels.getADP(temp, humidity) | ||
#### Params: | ||
* **temp** (*Float*) - Temperature in Celsius. | ||
* **humidity** (*Integer*) - Humidity in percent (from 0 to 100). | ||
* **humidity** (*Integer*) - Humidity in percent (0 > humidity <= 100). | ||
## Dew point | ||
### getDP(temp, humidity) | ||
### Feels.getDP(temp, humidity) | ||
#### Params: | ||
* **temp** (*Float*) - Temperature in Celsius. | ||
* **humidity** (*Integer*) - Humidity in percent (from 0 to 100, except 0). | ||
* **humidity** (*Integer*) - Humidity in percent (0 > humidity <= 100). | ||
## Frost point | ||
### getFP(temp, humidity) | ||
### Feels.getFP(temp, humidity) | ||
#### Params: | ||
* **temp** (*Float*) - Temperature in Celsius. | ||
* **humidity** (*Integer*) - Humidity in percent (from 0 to 100, except 0). | ||
* **humidity** (*Integer*) - Humidity in percent (0 > humidity <= 100). | ||
@@ -332,0 +490,0 @@ ## License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
477
35384
7
7
487
1