@shootismoke/aqi
TypeScript icon, indicating that this package has built-in type declarations

0.1.15 • Public • Published

npm (scoped) dependencies Status

@shootismoke/aqi

A library to convert between AQI (US or CN) value and pollutant concentration (µg/m³ or ppm) using the following standards:

  • US AQI: United States Environmental Protection Agency (EPA)
  • CN AQI: China Ministry of Environmental Protection (MEP)

Get Started

Install the package

yarn install @shootismoke/aqi

aqiToRaw(pollutant: Pollutant, aqi: number, aqiType: AqiType = 'US'): number

Converts an AQI value to raw concentration (µg/m³ or ppm).

Arguments:

  • pollutant: Pollutant: One of 'co' | 'h' | 'no2' | 'o3' | 'p' | 'pm10' | 'pm25' | 'so2' | 't' | 'w'
  • aqi: number: The AQI value
  • aqiType: AqiType: One of 'US' | 'CN'
import { aqiToRaw } from '@shootismoke/aqi';

const raw = aqiToRaw('pm25', 57, 'US');
console.log(raw); // 15

aqiToRaw(pollutant: Pollutant, raw: number, aqiType: AqiType = 'US'): number

Converts a raw concentration (µg/m³ or ppm) to AQI value.

Arguments:

  • pollutant: Pollutant: One of 'co' | 'h' | 'no2' | 'o3' | 'p' | 'pm10' | 'pm25' | 'so2' | 't' | 'w'
  • raw: number: The raw concentration
  • aqiType: AqiType: One of 'US' | 'CN'
import { rawToAqi } from '@shootismoke/aqi';

const aqi = aqiToRaw('pm25', 15, 'US');
console.log(aqi); // 57

getUnit(pollutant: Pollutant): Unit

Gets the unit of a pollutant (µg/m³ or ppm).

Arguments:

  • pollutant: Pollutant: One of 'co' | 'h' | 'no2' | 'o3' | 'p' | 'pm10' | 'pm25' | 'so2' | 't' | 'w'
import { getUnit } from '@shootismoke/aqi';

const unit = getUnit('pm25');
console.log(unit); // 'µg/m³'

🙋 Contribute

  1. Fork the repo
  2. Make your changes in your own fork
  3. Create a Pull Request on this repo

🔬 Tests

Look out for *.spec.ts in the codebase.

yarn test

📚 Resources

📰 License

GPL-3.0. See LICENSE file for more information.

Readme

Keywords

none

Package Sidebar

Install

npm i @shootismoke/aqi

Weekly Downloads

0

Version

0.1.15

License

GPL-3.0

Unpacked Size

63.1 kB

Total Files

60

Last publish

Collaborators

  • amaurym