npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@shootismoke/convert

v0.10.0

Published

Easily convert between AQIs (US, CN...) and raw values (ug/m3, ppm)

Downloads

40

Readme

npm (scoped) dependencies Status Maintainability Test Coverage

@shootismoke/convert

A library to convert between various Air Quality Indexes (US, CN...) and their equivalent in pollutant concentration (µg/m³, ppm, ppb).

Supported Air Quality Indexes

| AQI | AQI Code1 | Pollutants | Resources | | -------- | -------------------- | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | | AQI (US) | usaEpa | co, no2, o3, pm10, pm25, so2 | US Environmental Protection Agency (EPA) [link] | | AQI (CN) | chnMep | co, no2, o3, pm10, pm25, so2 | China Ministry of Environmental Protection (MEP) [link] |

We also plan to support other AQIs in the future, see issue #15 if you want to help.

1: We use the same AQI code as Breezometer, the only difference is that the code here is camelCase, because JavaScript likes camelCase.

⚡ Get Started

Install the package:

yarn install @shootismoke/convert

The package mainly exports the convert function.

convert(pollutant, from, to, value)

The function can convert, for any pollutant:

  • from a raw concentration to a supported AQI
  • from a supported AQI to a raw concentration
  • from a supported AQI to another AQI

Arguments:

  • pollutant: Pollutant: One of the supported pollutants, see them.
  • from: AqiCode | 'raw': An AQI code or the 'raw' string
  • to: AqiCode | 'raw': An AQI code or the 'raw' string
  • value: number: The value to convert
import { convert, getPollutantMeta } from '@shootismoke/convert';

// Convert PM2.5 from usaEpa AQI to raw concentration
const raw = convert('pm25', 'usaEpa', 'raw', 57);
console.log(raw); // 15

console.log(getPollutantMeta('pm25').preferredUnit); // "µg/m³", which is the unit of the value 15 above

// Convert PM2.5 from raw concentration to usaEPA AQI
const aqi = convert('pm25', 'raw', 'usaEpa', 15);
console.log(aqi); // 57

Supported Pollutants

The pollutants the AQIs apply to are: 'bc' | 'co' | 'c6h6' | 'ox' | 'nh3' | 'nmhc' | 'no' | 'nox' | 'no2' | 'o3' | 'pm10' | 'pm25' | 'so2' | 'trs'. Check this file to see the metadata for each pollutant (full name, unit...).

Full Documentation

See the API reference documentation.

:raising_hand: Contribute

  1. Fork the repo
  2. Make your changes in your own fork
  3. Make sure yarn lint and yarn test pass
  4. Create a Pull Request on this repo

Tests

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

yarn test

:newspaper: License

GPL-3.0. See LICENSE file for more information.