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

@brewfoo/core

v0.2.0

Published

The aim of this project is to be the **most comprehensive** and **most accurate** and **fully free** collection of core brewing formulae, calculations and conversions written specifically for the web in [TypeScript](https://www.typescriptlang.org/).

Downloads

4

Readme

Brewfoo Core

The aim of this project is to be the most comprehensive and most accurate and fully free collection of core brewing formulae, calculations and conversions written specifically for the web in TypeScript.

Features

  • Basic quantity and unit conversions.
  • Collection of formulae and calculations.
  • Full recipe planning tool.
  • Water profile and treatment calculations.

Please see TypeDoc for API documentation.

Examples

Simple quantities & conversions:

import { Mass, MassUnit, Temperature, TemperatureUnit, Volume, VolumeUnit } from '@brewfoo/core';

const mass = new Mass(MassUnit.Kilogram, 3.5);
mass.convert(MassUnit.Gram); // => 3500
mass.convert(MassUnit.USPound); // => ~7.7
mass.convert(MassUnit.USOunce); // => ~123.5

const vol = new Volume(VolumeUnit.Liter, 20);
vol.convert(VolumeUnit.USGallon); // => 5.3

const temp = new Temperature(TemperatureUnit.Celsius, 19);
temp.convert(TemperatureUnit.Fahrenheit); // => 66.2

Fermentation calculation:

const calc = new FermentationCalc(
  new Gravity(GravityUnit.SG, 1.07),
  new Gravity(GravityUnit.SG, 1.015),
);
calc.AA; // => ~77.6%
calc.RA; // => ~62.7%
calc.ABV; // => ~7.24%
calc.ABW.g(); // => ~5.67
calc.energy.kcal(); // => ~65.07

IBU calculations:

const util = new UtilizationCalc({
  wortGravity: Gravity.points(60),
  batchVolume: Volume.liter(20),
  boilTime: Duration.minutes(50),
  standTime: Duration.minutes(10),
});
util.rager(); // => ~28.9
util.tinseth(); // => ~20.8

const calc = new IBUCalc({
  mass: Mass.kg(0.06),
  alpha: 10.0,
  batchVolume: Volume.liter(20),
  utilization: 10,
});
calc.alphaMass.g(); // => ~6.0
calc.IBU; // => ~30.0

Simple recipe:

const pale = new Fermentable({
  mass: Mass.kg(3.0),
  color: new Color(ColorUnit.Lovibond, 3),
  power: DiastaticPower.lintner(60),
  extraction: ExtractYield.percent(80),
  isGrain: true,
});
const crystal = new Fermentable({
  mass: Mass.kg(0.4),
  color: new Color(ColorUnit.Lovibond, 120),
  extraction: ExtractYield.percent(70),
  isGrain: true,
});

const magnum = new Hop({
  boilTime: Duration.minutes(60),
  mass: new Mass(MassUnit.Gram, 10),
  alpha: 13.8,
  multiplier: 1.1,
});
const simcoe = new Hop({
  boilTime: Duration.minutes(5),
  mass: new Mass(MassUnit.Gram, 30),
  alpha: 11.3,
});
const citra = new Hop({
  mass: new Mass(MassUnit.Gram, 60),
  alpha: 12.0,
});

const recipe = new RecipeCalc({
  attenuation: 78,
  fermentables: [pale, crystal],
  hops: [magnum, simcoe, citra],
});

recipe.BG.SG(); // => ~1.031
recipe.OG.SG(); // => ~1.040
recipe.FG.SG(); // => ~1.009
recipe.beerColor.convert(ColorUnit.SRM); // => ~13.1
recipe.IBU; // => ~29.5
recipe.BUGU; // => ~0.74
recipe.ABV; // => ~4.1
recipe.ABW.g(); // => ~3.2
recipe.energy.kcal(); // => ~37
recipe.DP.lintner(); // => ~52.9

recipe.waterUsage.boilVolume.L(); // => ~25.3
recipe.waterUsage.totalVolume.L(); // => ~29.7
recipe.postBoilAddition = Volume.liter(6);
recipe.waterUsage.boilVolume.L(); // => ~19.1
recipe.waterUsage.totalVolume.L(); // => ~23.5

Water profiles and treatment:

// Create profile
const london = new WaterProfile({
  calcium: 100,
  magnesium: 5,
  sodium: 30,
  sulphate: 50,
  chloride: 50,
  bicarbonate: 245,
  alkalinity: 200,
  pH: 7.7,
});
london.hardness(); // => 270
london.RA(); // => 126
london.ratio(); // => 1.0
london.cation(); // => 6.7
london.anion(); // => 6.5

// Apply treatments
const treated = london.treat(Volume.liter(20), [
  new DilutionTreatment(10),
  new SaltTreatment(Salt.CalciumChloride, new Mass(MassUnit.Gram, 3)),
  new SaltTreatment(Salt.CalciumSulphate, new Mass(MassUnit.Gram, 3)),
  new AcidTreatment(Acid.Lactic, {
    volume: new Volume(VolumeUnit.Milliliter, 2),
    concentration: 88,
  }),
]); // => { alkalinity: 122, bicarbonate: 150, calcium: 166, chloride: 117, magnesium: 5, pH: 7.7, sodium: 27, sulphate: 129 }
treated.RA(); // => ~0.0

Licence

Licensed under LGPLv3