Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

feels

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

feels - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

22

lib/helpers.js
'use strict';
module.exports.isNil = function(variable) {
module.exports.isNil = function (variable) {
return variable == null;

@@ -10,3 +10,3 @@ };

module.exports.unitsFormat = function(_units) {
module.exports.unitsFormat = function (_units) {
var units = {

@@ -44,9 +44,9 @@ temp: 'c',

module.exports.tempConvert = function(temp, from, to) {
module.exports.tempConvert = function (temp, from, to) {
if (!isFinite(temp)) {
throw new Error('Temp must be specified and must be a number');
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 Error('Units must be c, f or k');
throw new RangeError('Units must be c, f or k');
} else if (from === 'c') {

@@ -59,13 +59,13 @@ return (to === 'f') ? (temp * 1000 * (9 / 5) + 32 * 1000) / 1000 : (temp * 1000 + 273.15 * 1000) / 1000;

} else {
throw new Error('Units must be c, f or k');
throw new RangeError('Units must be c, f or k');
}
};
module.exports.speedConvert = function(speed, from, to) {
module.exports.speedConvert = function (speed, from, to) {
if (!isFinite(speed)) {
throw new Error('Speed must be a number');
throw new TypeError('Speed must be a number');
} else if (from === to) {
return speed;
} else if (['mps', 'mph', 'kph'].indexOf(to) === -1) {
throw new Error('Units must be mps, mph or kph');
throw new RangeError('Units must be mps, mph or kph');
} else if (from === 'mps') {

@@ -78,3 +78,3 @@ return (to === 'mph') ? speed / 0.44704 : speed * 3.6;

} else {
throw new Error('Units must be mps, mph or kph');
throw new RangeError('Units must be mps, mph or kph');
}

@@ -89,3 +89,3 @@ };

module.exports.getT = function(temp, humidity, b, c, d) {
module.exports.getT = function (temp, humidity, b, c, d) {
return (c * getG(temp, humidity, b, c, d)) / (b - getG(temp, humidity, b, c, d));

@@ -92,0 +92,0 @@ };

@@ -8,3 +8,2 @@ 'use strict';

var speedConvert = helpers.speedConvert;
var getG = helpers.getG;
var getT = helpers.getT;

@@ -33,3 +32,3 @@ var _methods = helpers.methods;

Feels.prototype.like = function(methods) {
Feels.prototype.like = function (methods) {
var temp = tempConvert(this.temp, this.units.temp, 'c');

@@ -41,17 +40,21 @@ if ((Array.isArray(methods) || typeof methods === 'string') && methods.length) {

} else {
throw new Error('Methods must be one of: HI, HI_CA, AAT, WCI');
throw new RangeError('Methods must be one of: HI, HI_CA, AAT, WCI');
}
} else {
var _this = this;
var like = 0;
var count = 0;
methods.forEach(function(n) {
if (_methods[n.toUpperCase()]) {
like += _this[_methods[n.toUpperCase()].f]();
try {
like += this[_methods[n.toUpperCase()].f]();
count++;
} catch (e) { }
} else {
throw new Error('Methods must be one of: HI, HI_CA, AAT, WCI');
throw new RangeError('Methods must be one of: HI, HI_CA, AAT, WCI');
}
});
}.bind(this));
return like / methods.length;
if (count === 0) throw new Error('No valid methods for these values');
return like / count;
}

@@ -69,3 +72,3 @@ } else {

Feels.prototype.toCelsius = function() {
Feels.prototype.toCelsius = function () {
this._units.temp = 'c';

@@ -77,3 +80,3 @@ return this;

Feels.prototype.toFahrenheit = function() {
Feels.prototype.toFahrenheit = function () {
this._units.temp = 'f';

@@ -85,3 +88,3 @@ return this;

Feels.prototype.toKelvin = function() {
Feels.prototype.toKelvin = function () {
this._units.temp = 'k';

@@ -93,3 +96,3 @@ return this;

Feels.prototype.heatIndex = function(temp, humidity, dewPoint) { //HI
Feels.prototype.heatIndex = function (temp, humidity, dewPoint) { //HI
if (

@@ -100,8 +103,8 @@ (!isNil(temp) || !isNil(this.temp)) &&

!isNil(temp) || (temp = this.temp);
var units = this.units || {temp: 'c'};
var _units = this._units || {temp: 'c'};
var units = this.units || { temp: 'c' };
var _units = this._units || { temp: 'c' };
var _temp = tempConvert(temp, units.temp, 'f');
if (_temp < 68) {
throw new Error('Heat Index temp must be >= (20C, 68F, 293.15K)');
throw new RangeError('Heat Index temp must be >= (20C, 68F, 293.15K)');
}

@@ -115,3 +118,3 @@

if (humidity < 0 || humidity > 100) {
throw new Error('Humidity must be in [0, 100]');
throw new RangeError('Humidity must be in [0, 100]');
}

@@ -125,4 +128,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 0.363445176 + 0.988622465 * temp + 4.777114035 * humidity - 0.114037667 * temp * humidity - 0.000850208 * Math.pow(temp, 2) - 0.020716198 *
Math.pow(humidity, 2) + 0.000687678 * Math.pow(temp, 2) * humidity + 0.000274954 * temp * Math.pow(humidity, 2);*/

@@ -137,3 +138,3 @@ return tempConvert(HI, 'f', _units.temp);

Feels.prototype.AWBGT = function(temp, humidity, dewPoint) { //AWBGT
Feels.prototype.AWBGT = function (temp, humidity, dewPoint) { //AWBGT
if (

@@ -144,8 +145,8 @@ (!isNil(temp) || !isNil(this.temp)) &&

!isNil(temp) || (temp = this.temp);
var units = this.units || {temp: 'c'};
var _units = this._units || {temp: 'c'};
var units = this.units || { temp: 'c' };
var _units = this._units || { temp: 'c' };
var _temp = tempConvert(temp, units.temp, 'c');
if (_temp < 15) {
throw new Error('Heat Index temp must be >= (15C, 59F, 288.15K)');
throw new RangeError('Heat Index temp must be >= (15C, 59F, 288.15K)');
}

@@ -159,3 +160,3 @@

if (humidity < 0 || humidity > 100) {
throw new Error('Humidity must be in [0, 100]');
throw new RangeError('Humidity must be in [0, 100]');
}

@@ -172,3 +173,3 @@ }

Feels.prototype.humidex = function(temp, humidity, dewPoint) { //HI_CA
Feels.prototype.humidex = function (temp, humidity, dewPoint) { //HI_CA
if (

@@ -179,8 +180,8 @@ (!isNil(temp) || !isNil(this.temp)) &&

!isNil(temp) || (temp = this.temp);
var units = this.units || {temp: 'c'};
var _units = this._units || {temp: 'c'};
var units = this.units || { temp: 'c' };
var _units = this._units || { temp: 'c' };
var _temp = tempConvert(temp, units.temp, 'c');
if (_temp <= 0) {
throw new Error('Humidex temp must be > (0C, 32F, 273.15K)');
throw new RangeError('Humidex temp must be > (0C, 32F, 273.15K)');
}

@@ -194,3 +195,3 @@

if (humidity < 0 || humidity > 100) {
throw new Error('Humidity must be in [0, 100]');
throw new RangeError('Humidity must be in [0, 100]');
}

@@ -207,3 +208,3 @@ }

Feels.prototype.AAT = function(temp, speed, humidity, dewPoint) { //AAT
Feels.prototype.AAT = function (temp, speed, humidity, dewPoint) { //AAT
if (

@@ -213,4 +214,4 @@ ((!isNil(temp) && !isNil(speed)) || (!isNil(this.temp) && !isNil(this.speed))) &&

) {
var units = this.units || {temp: 'c', speed: 'mps'};
var _units = this._units || {temp: 'c'};
var units = this.units || { temp: 'c', speed: 'mps' };
var _units = this._units || { temp: 'c' };

@@ -226,3 +227,3 @@ if (isNil(temp) && isNil(speed)) {

if (speed < 0) {
throw new Error('Wind speed must be >= 0');
throw new RangeError('Wind speed must be >= 0');
}

@@ -236,3 +237,3 @@

if (humidity < 0 || humidity > 100) {
throw new Error('Humidity must be in [0, 100]');
throw new RangeError('Humidity must be in [0, 100]');
}

@@ -249,6 +250,6 @@ }

Feels.prototype.windChill = function(temp, speed) { //WCI
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'};
var units = this.units || { temp: 'c', speed: 'mps' };
var _units = this._units || { temp: 'c' };
if (isNil(temp) && isNil(speed)) {

@@ -262,5 +263,5 @@ temp = this.temp;

if (_temp > 0) {
throw new Error('Wind Chill temp must be <= (0C, 32F, 273.15K)');
throw new RangeError('Wind Chill temp must be <= (0C, 32F, 273.15K)');
} else if (speed < 0) {
throw new Error('Wind speed must be >= 0');
throw new RangeError('Wind speed must be >= 0');
}

@@ -281,5 +282,5 @@

Feels.prototype.getWaterVapourPressure = function(humidity, temp) {
Feels.prototype.getWaterVapourPressure = function (humidity, temp) {
if ((!isNil(humidity) && !isNil(temp)) || (!isNil(this.humidity) && !isNil(this.temp))) {
var units = this.units || {temp: 'c'};
var units = this.units || { temp: 'c' };
if (isNil(temp) && isNil(humidity)) {

@@ -301,3 +302,3 @@ temp = this.temp;

Feels.prototype.getWaterVapourPressureByDewPoint = function(dewPoint) {
Feels.prototype.getWaterVapourPressureByDewPoint = function (dewPoint) {
if (!isNil(dewPoint) || !isNil(this.dewPoint)) {

@@ -315,5 +316,5 @@ !isNil(dewPoint) || (dewPoint = this.dewPoint);

Feels.prototype.getAproximateRelativeHumidity = function(temp, dewPoint) {
Feels.prototype.getAproximateRelativeHumidity = function (temp, dewPoint) {
if ((!isNil(temp) && !isNil(dewPoint)) || (!isNil(this.temp) && !isNil(this.dewPoint))) {
var units = this.units || {temp: 'c'};
var units = this.units || { temp: 'c' };
if (isNil(temp) && isNil(dewPoint)) {

@@ -333,7 +334,7 @@ temp = this.temp;

Feels.prototype.getRelativeHumidity = function(temp, WVP, dewPoint) {
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'};
var units = this.units || { temp: 'c' };
!isNil(temp) || (temp = this.temp);

@@ -346,3 +347,3 @@ var _temp = tempConvert(temp, units.temp, 'c');

} else if (typeof WVP !== 'number') {
throw new Error('WVP must be a number');
throw new TypeError('WVP must be a number');
}

@@ -359,5 +360,5 @@

Feels.prototype.getAproximateDewPoint = function(temp, humidity) {
Feels.prototype.getAproximateDewPoint = function (temp, humidity) {
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)) {

@@ -377,8 +378,8 @@ temp = this.temp;

Feels.prototype.getDewPoint = function(temp, humidity) { //dew point for [-40, 50], humidity must be in (0, 100]
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'};
var units = this.units || { temp: 'c' };
var _units = this._units || { temp: 'c' };
if (isNil(temp) && isNil(humidity)) {

@@ -392,5 +393,5 @@ temp = this.temp;

if (_temp < -40 || _temp > 50) {
throw new Error('Dew point temp must be in [-40, 50]');
throw new RangeError('Dew point temp must be in [-40, 50]');
} else if (humidity <= 0 || humidity > 100) {
throw new Error('Humidity must be in (0, 100]');
throw new RangeError('Humidity must be in (0, 100]');
}

@@ -410,6 +411,6 @@

Feels.prototype.getFrostPoint = function(temp, humidity) { //frost point for [-80, 0], humidity must be in (0, 100]
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'};
var units = this.units || { temp: 'c' };
var _units = this._units || { temp: 'c' };
if (isNil(temp) && isNil(humidity)) {

@@ -423,5 +424,5 @@ temp = this.temp;

if (_temp < -80 || _temp > 0) {
throw new Error('Frost point temp must be in [-80, 0]');
throw new RangeError('Frost point temp must be in [-80, 0]');
} else if (humidity <= 0 || humidity > 100) {
throw new Error('Humidity must be in (0, 100]');
throw new RangeError('Humidity must be in (0, 100]');
}

@@ -428,0 +429,0 @@

{
"name": "feels",
"author": "Alexey Bystrov <strikeentco@gmail.com>",
"version": "1.0.0",
"version": "1.0.1",
"description": "Feels allow you to calculate apparent temperature using heat index, approximate wet-bulb globe temperature, humidex, australian apparent temperature and wind chill.",

@@ -37,6 +37,6 @@ "keywords": [

"devDependencies": {
"mocha": "^2.2.5",
"should": "^7.0.4"
"mocha": "^2.5.3",
"should": "^10.0.0"
},
"license": "MIT"
}

@@ -1,10 +0,10 @@

feels
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)
==========
[![Build Status](https://travis-ci.org/strikeentco/feels.svg)](https://travis-ci.org/strikeentco/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) [![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) [![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)
`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).
Combinations of this methods also named as Feels like, Real feel etc.
Combinations of this methods also named as `Feels like`, `Real feel` etc.
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 calculate `relative humidity`, `dew point`, `frost point`, `water vapour pressure` using [class](#class-methods) or [standalone](#standalone-methods) methods.

@@ -14,3 +14,3 @@ # Usage

```sh
npm install feels
$ npm install feels --save
```

@@ -60,3 +60,3 @@

If options aren't provided returns an index is calculated with ['HI', 'HI_CA', 'AAT', 'WCI'].
If options aren't provided returns an index is calculated with `['HI', 'HI_CA', 'AAT', 'WCI']`.

@@ -320,2 +320,2 @@ #### Params:

The MIT License (MIT)<br/>
Copyright (c) 2015 Alexey Bystrov
Copyright (c) 2015-2016 Alexey Bystrov

@@ -232,4 +232,12 @@ 'use strict';

it('should ignore invalid algorithm / value combinations', function() {
should(feels.like(['AAT', 'WCI'])).be.equal(feels.like(['AAT']));
});
it('should throw if no valid method exists', function() {
should(function() {return feels.like(['WCI']);}).throw('No valid methods for these values');
});
it('should throw', function() {
should(function() {return feels.like(['AAT', 'WCI']);}).throw('Wind Chill temp must be <= (0C, 32F, 273.15K)');
should(function() {return feels.like('WCI');}).throw('Wind Chill temp must be <= (0C, 32F, 273.15K)');
});

@@ -236,0 +244,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc