SkillAgentSearch skills...

Feels

:cyclone: Calculate apparent temperature using heat index, approximate wet-bulb globe temperature, humidex, australian apparent temperature and wind chill.

Install / Use

/learn @strikeentco/Feels

README

feels License npm

Build Status node Test Coverage bitHound Score

Feels allow you to calculate apparent temperature using heat index, approximate wet-bulb globe temperature, humidex, australian apparent temperature and wind chill.

Combinations of this methods also named as Feels like, Real feel etc.

You can also convert temperature, speed and calculate relative humidity, dew point, frost point, water vapour pressure using class or standalone methods.

Usage

$ npm install feels --save
const Feels = require('feels');

const config = {
  temp: 20,
  humidity: 85,
  speed: 20,
  units: {
    temp: 'c',
    speed: 'mps'
  }
};

new Feels(config).like();

Quick navigation

API

Class methods

Most of the class methods also available as 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.
    • round (Boolean|Function) - The function that will be used to round the result. If true, rounds the result using Math.round.
    • units (Object) - Units type:
      • temp (String) - c, f, k (by default c).
      • speed (String) - mps, mph, kph (by default mps).
const Feels = require('feels');

new Feels({ temp: 20, humidity: 80.9 }).toF().humidex();

.setOptions(options)

Sets the options.

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.
    • round (Boolean|Function) - The function that will be used to round the result. If true, rounds the result using Math.round.
    • units (Object) - Units type:
      • temp (String) - c, f, k (by default c).
      • speed (String) - mps, mph, kph (by default mps).
const Feels = require('feels');
const feels = new Feels();
const config = {
  temp: 20,
  humidity: 85,
  speed: 20,
  units: {
    temp: 'c',
    speed: 'mps'
  }
};

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:

  • [methods] (String|Array) - String or array with one of the apparent temperature acronyms.

Acronyms

If you want to convert temperature from one to other temperature scale, you can place .toC(), .toF() or .toK() before target method.

new Feels(config).toF().like(['AAT', 'HI_CA']);

.addMethod(name, method)

Adds new method, which can be used by itself or in .like().

Params:

  • name (String) - Method name.
  • method (Function) - The method itself.
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(), by inheriting the base class.

Params:

  • methods (Array) - Method names.
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)

.AWBGT()

Params:

  • options (Object) - Constructor options:
    • temp (Float)
    • humidity|dewPoint (Float)

.humidex()

Params:

  • options (Object) - Constructor options:
    • temp (Float)
    • humidity|dewPoint (Float)

.AAT()

Params:

  • options (Object) - Constructor options:
    • temp (Float)
    • speed (Float)
    • humidity|dewPoint (Float)

.windChill()

Params:

  • options (Object) - Constructor options:
    • temp (Float)
    • speed (Float)

.getWVP()

Params:

  • options (Object) - Constructor options:
    • humidity (Float)
    • temp (Float)

.getWVPbyDP()

Params:

  • options (Object) - Constructor options:
    • dewPoint (Float)

.getARH()

Params:

  • options (Object) - Constructor options:
    • temp (Float)
    • dewPoint (Float)

.getRH()

Params:

  • options (Object) - Constructor options:
    • temp (Float)
    • wvp|dewPoint (Float)

.getADP()

Params:

  • options (Object) - Constructor options:
    • temp (Float)
    • humidity (Float)

.getDP()

Params:

  • options (Object) - Constructor options:
    • temp (Float)
    • humidity (Float)

.getFP()

Params:

  • options (Object) - Constructor options:
    • temp (Float)
    • humidity (Float)

Aliases

  • toC() - toCelsius()
  • toF() - toFahrenheit()
  • toK() - toKelvin()
  • getWVP() - getWaterVapourPressure()
  • getWVPbyDP() - getWaterVapourPressureByDewPoint()
  • getARH() - getAproximateRelativeHumidity()
  • getRH() - getRelativeHumidity()
  • getADP() - getAproximateDewPoint()
  • getDP() - getDewPoint()
  • getFP() - getFrostPoint()

Standalone methods

All standalone methods use temperature in Celsius, humidity in percent and wind speed in meters per second.

const Feels = require('feels');

Feels.humidex(20, 80.9);

Temperature convert

Feels.tempConvert(temp, from, to, round)

Params:

  • temp (Float) - Temperature.
  • from (String) - c - Celsius, f - Fahrenheit, k - Kelvin.
  • to (String) - c - Celsius, f - Fahrenheit, k - Kelvin.
  • round (Boolean|Function) - The function that will be used to round the result. If true, rounds the result using Math.round.
const Feels = require('feels');
const humidex = Feels.humidex(20, 80.9);

Feels.tempConvert(humidex, 'c', 'f');

Speed convert

Feels.speedConvert(speed, from, to,

View on GitHub
GitHub Stars31
CategoryDevelopment
Updated1y ago
Forks9

Languages

JavaScript

Security Score

80/100

Audited on Dec 23, 2024

No findings