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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@vim-crouwel/cfpc

v1.0.1

Published

TypeScript library for calculating CO2 emissions from food, energy, and transportation

Downloads

12

Readme

Carbon Footprint Calculator

A TypeScript library for calculating CO2 emissions from food, energy, and transportation.

Data Sources

The library uses emission factors from:

  • Food: CO2 emissions per kg for various food items
  • Energy: CO2 emissions per kWh and AC usage calculations
  • Transportation: CO2 emissions per km for different transport modes

Installation

npm install @vim-crouwel/cfpc

Usage

Food Emissions

import { co2PerKg, getFoodCategories, getFoodItems } from '@vim-crouwel/cfpc/calculators/food'

// Calculate CO2 for 0.5kg of beef
const beefEmissions = co2PerKg('meat', 'beef', 0.5)
console.log(`Beef emissions: ${beefEmissions} kg CO2`)

// List available categories and items
const categories = getFoodCategories()
const meatItems = getFoodItems('meat')

Energy Emissions

import { co2PerKwh, acCo2Emissions, acUsage } from '@vim-crouwel/cfpc/calculators/energy'

// Calculate CO2 for 100 kWh energy consumption (50 kg CO2)
const energyEmissions = co2PerKwh(100)

// Calculate kWh needed for AC in 50m² room for 8 hours (60 kWh)
const kwh = acUsage(50, 8)

// Calculate AC emissions for 50m² room running 8 hours (30 kg CO2)
const acEmissions = acCo2Emissions(50, 8)

Transportation Emissions

import { co2PerKm, getTransportationModes } from '@vim-crouwel/cfpc/calculators/transportation'

// Calculate CO2 for 25km car trip
const carEmissions = co2PerKm('car', 25)

// List available transportation modes
const modes = getTransportationModes()

Complete Example

import { co2PerKg } from '@vim-crouwel/cfpc/calculators/food'
import { co2PerKwh } from '@vim-crouwel/cfpc/calculators/energy'
import { co2PerKm } from '@vim-crouwel/cfpc/calculators/transportation'

// Daily carbon footprint calculation
const dailyFood = co2PerKg('meat', 'chicken', 0.2) + co2PerKg('dairy', 'milk', 0.3)
const dailyEnergy = co2PerKwh(8)
const dailyTransport = co2PerKm('car', 30)

const totalDaily = dailyFood + dailyEnergy + dailyTransport
console.log(`Daily CO2 emissions: ${totalDaily.toFixed(2)} kg`)

Development

bun install
bun run index.ts

API Reference

All functions include JSDoc documentation with parameter descriptions and return types.