New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@tsmx/weather-tools

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tsmx/weather-tools

Toolset for calculating wind chill, dew point, heat index and more.

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

@tsmx/weather-tools

License: MIT npm (scoped) node-current (scoped) Build Status Coverage Status

Toolset for weather data calculations and conversions.

Provides the following functionalities:

  • Wind chill calculation (Celsius and Fahrenheit)
  • Dew point calculation (Celsius)
  • Heat index calculation (Celsius and Fahrenheit)
  • Degree to compass direction conversion
  • Fahrenheit <> Celsius conversion
  • MPH <> KMH conversion
  • Inch <> Millimeter conversion

Usage

Example: calculating the dew point in Celsius from given humidity hum and temperature in Fahrenheit tempF.

const wt = require('@tsmx/weather-tools');

const tempC = wt.fahrenheitToCelsius(tempF);
const dewPoint = wt.dewPoint(tempC, hum);

For details look the API descriptions for:

API

Wind chill functions

windchillCelsius(temp, speed)

Calculates the wind chill temperature in degrees Celsius.

Note: Wind chill calculation is only feasible for low temperatures <= 10 degrees Celsius and a minimum wind speed > 4.8 km/h.

Returns:

  • NaN if temp is greater than 10.0 degress Celsius
  • temp if speed is less than or equal to 4.8 km/h
  • the calculated wind chill otherwise
temp

Type: number

The current temperature in degrees Celsius.

speed

Type: number

The current wind speed in km/h.

windchillFahrenheit(temp, speed)

Calculates the wind chill temperature in degrees Fahrenheit.

Note: Wind chill calculation is only feasible for low temperatures <= 50 degrees Fahrenheit and a minimum wind speed > 3.0 mph.

Returns:

  • NaN if temp is greater than 50.0 degress Fahrenheit
  • temp if speed is less than or equal to 3.0 mph
  • the calculated wind chill otherwise
temp

Type: number

The current temperature in degrees Fahrenheit.

speed

Type: number

The current wind speed in mph.

Dew point functions

dewPoint(temp, humidity)

Calculates the dew point in degrees Celsius.

temp

Type: number

The current temperature in degrees Celsius.

humidity

Type: number

The current humidity in percent (0.0 - 100.0).

Heat index functions

heatIndexCelsius(temp, humidity)

Calculates the heat index in degrees Celsius.

Note: Heat index calculation is only feasible for high temperatures >= 27 degrees Celsius and a minimum humidity >= 40%.

Returns:

  • NaN if temp is lower than 27.0 degress Celsius or humidity is lower than 40.0
  • the calculated heat index otherwise
temp

Type: number

The current temperature in degrees Celsius.

humidity

Type: number

The current humidity in percent (0.0 - 100.0).

heatIndexFahrenheit(temp, humidity)

Calculates the heat index in degrees Fahrenheit.

Note: Heat index calculation is only feasible for high temperatures >= 80 degrees Fahrenheit and a minimum humidity >= 40%.

Returns:

  • NaN if temp is lower than 80.0 degress Fahrenheit or humidity is lower than 40.0
  • the calculated heat index otherwise
temp

Type: number

The current temperature in degrees Fahrenheit.

humidity

Type: number

The current humidity in percent (0.0 - 100.0).

Conversion functions

degreesToDirection(deg)

Converts degrees to the closest matching compass direction, e.g. 0 to N, 35 to NE, 301 to WNW and so on.

A 32-point compass rose is used for the conversion.

DegreeDirection / returned value
0.0N
22.5NNE
45.0NE
67.5ENE
90.0E
112.5ESE
135.0SE
157.5SSE
180.0S
202.5SSW
225.0SW
247.5WSW
270.0W
292.5WNW
315.0NW
337.5NNW
deg

Type: number

Number of degrees to be converted

fahrenheitToCelsius(fahrenheit)

Converts Fahrenheit to Celsius.

fahrenheit

Type: number

The value to be converted in degrees Fahrenheit

celsiusToFahrenheit(celsius)

Converts Celsius to Fahrenheit.

ceslsius

Type: number

The value to be converted in degrees Celsius

mphToKmh(mph)

Converts MPH to KMH.

mph

Type: number

The value to be converted in MPH.

kmhToMph(kmh)

Converts KMH to MPH.

kmh

Type: number

The value to be converted in KMH.

inchToMillimeter(inch)

Converts inches to millimeters.

inch

Type: number

The value to be converted in millimeters.

millimeterToInch(millimeter)

Converts millimeters to inches.

millimeter

Type: number

The value to be converted in inches.

References

The implementations in this library are based on the following references.

Wind chill formulas

Dew point formulas

Heat index formulas

Wind/compass direction algorithm

Keywords

FAQs

Package last updated on 18 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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