SkillAgentSearch skills...

Brauhausjs

A beer recipe calculator for homebrewing on servers and in browsers

Install / Use

/learn @homebrewing/Brauhausjs
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Brauhaus.js

Dependency Status Build Status Coverage Status NPM version

A javascript library for homebrew beer calculations both in the browser and on the server. Features include:

  • Support for multiple Javascript runtimes
    • Node.js 0.6.x, 0.8.x, 0.10.x, 0.11.x
    • Chrome, Firefox, Internet Explorer 9+, Safari, Opera, etc
  • Calculate estimated OG, FG, IBU, ABV, SRM color, calories, and more
  • Tinseth and Rager IBU calculation formula support
    • Pellets vs. whole hops support
    • Late addition boil support
    • Dry hopping support
  • Automatically generated recipe instructions and timeline
  • Estimate monetary recipe cost in USD based on ingredients
  • Grade recipes based on recipe completeness
  • Built-in unit conversions (kg <-> lb/oz, liter <-> gallon, temps, etc)
  • Color in °SRM to name, °EBC, °Lovibond, RGB conversions, CSS color, etc
  • Plugin support to add additional features
  • Lightweight - about 28kb when minified

Plugins provide the following features:

Brauhaus.js was developed with and for Malt.io, a community website for homebrewers to create recipes and share their love of homebrewing beer.

Interactive Examples

Installation

There are two ways to use Brauhaus.js - either in a web browser (client-side) or on e.g. Node.js (server-side).

Web Browser (client-side use)

To use Brauhaus.js in a web browser, simply download the following file and include it as you would any other script:

Plugins:

<script type="text/javascript" src="/scripts/brauhaus.min.js"></script>
<!-- Plugins go here... -->
<script type="text/javascript">
    // Your code goes here!
    // See below for an example...
</script>

Node.js (server-side use)

For Node.js, you can easily install Brauhaus.js and plugins using npm:

npm install brauhaus

Quick Example (CoffeeScript)

Here is an example of how to use the library from CoffeeScript:

# The following line is NOT required for web browser use
Brauhaus = require 'brauhaus'

# Import plugins here, e.g.
require 'brauhaus-beerxml'

# Create a recipe
r = new Brauhaus.Recipe
    name: 'My test brew'
    description: 'A new test beer using Brauhaus.js!'
    batchSize: 20.0
    boilSize: 10.0

# Add ingredients
r.add 'fermentable',
    name: 'Extra pale malt'
    color: 2.5
    weight: 4.2
    yield: 78.0

r.add 'hop',
    name: 'Cascade hops'
    weight: 0.028
    aa: 5.0
    use: 'boil'
    form: 'pellet'

r.add 'yeast'
    name: 'Wyeast 3724 - Belgian Saison'
    type: 'ale'
    form: 'liquid'
    attenuation: 80

# Set up a simple infusion mash
r.mash = new Brauhaus.Mash
    name: 'My mash'
    ph: 5.4

r.mash.addStep
    name: 'Saccharification'
    type: 'Infusion'
    time: 60
    temp: 68
    waterRatio: 2.75

# Calculate values
r.calculate()

# Print out calculated values
console.log "Original Gravity: #{ r.og.toFixed 3 }"
console.log "Final Gravity: #{ r.fg.toFixed 3 }"
console.log "Color: #{ r.color.toFixed 1 }&deg; SRM (#{ r.colorName() })"
console.log "IBU: #{ r.ibu.toFixed 1 }"
console.log "Alcohol: #{ r.abv.toFixed 1 }% by volume"
console.log "Calories: #{ Math.round r.calories } kcal"

Quick Example (Javascript)

Here is an example of how to use the library form Javascript:

// The following line is NOT required for web browser use
var Brauhaus = require('brauhaus');

// Import plugins here, e.g.
require('brauhaus-beerxml');

// Create a recipe
var r = new Brauhaus.Recipe({
    name: 'My test brew',
    description: 'A new test beer using Brauhaus.js!',
    batchSize: 20.0,
    boilSize: 10.0
});

// Add ingredients
r.add('fermentable', {
    name: 'Extra pale malt',
    color: 2.5,
    weight: 4.2,
    yield: 78.0
});

r.add('hop', {
    name: 'Cascade hops',
    weight: 0.028,
    aa: 5.0,
    use: 'boil',
    form: 'pellet'
});

r.add('yeast', {
    name: 'Wyeast 3724 - Belgian Saison',
    type: 'ale',
    form: 'liquid',
    attenuation: 80
});

// Set up a simple infusion mash
r.mash = new Brauhaus.Mash({
    name: 'My mash',
    ph: 5.4
});

r.mash.addStep({
    name: 'Saccharification',
    type: 'Infusion',
    time: 60,
    temp: 68,
    waterRatio: 2.75
});

// Calculate values
r.calculate();

// Print out calculated values
console.log('Original Gravity: ' + r.og.toFixed(3));
console.log('Final Gravity: ' + r.fg.toFixed(3));
console.log('Color: ' + r.color.toFixed(1) + '&deg; SRM (' + r.colorName() + ')');
console.log('IBU: ' + r.ibu.toFixed(1));
console.log('Alcohol: ' + r.abv.toFixed(1) + '% by volume');
console.log('Calories: ' + Math.round(r.calories) + ' kcal');

Brauhaus Configuration

The following values may be configured and will apply to all recipes, ingredients, etc.

| Property | Type | Default | Description | | ---------------------- | ------ | ------- | ---------------------------------------------------- | | BURNER_ENERGY | number | 9000 | Heat source output in kilojoules per hour | | COLOR_NAMES | array | ... | An array of color names for °SRM color ranges | | MASH_HEAT_LOSS | number | 5 | Degrees C lost per hour during mash | | RELATIVE_SUGAR_DENSITY | object | ... | Keys are types of sugar, values are relative density | | ROOM_TEMP | number | 23 | Room temperature in degrees C |

Duration Functions

The following functions are available to parse and display durations of time:

Brauhaus.parseDuration (value)

Parse a string value into a duration in minutes. Supports many optional suffixes like w, wk, wks, week, weeks, d, day, days, h, hr, hrs, hour, hours, m, min, mins, minute, minutes, s, sec, second, and seconds.

>>> Brauhaus.parseDuration('2 days')
2880
>>> Brauhaus.parseDuration('1hr 3 minutes')
63
>>> Brauhaus.parseDuration('12')
12

Brauhaus.displayDuration (minutes, [approximate])

Generates a human-friendly display string from a number of minutes. Approximate, if set, determines the maximum number of units to return, rounding the last unit. For example, a setting of 2 would return days and hours; or hours and minutes; but never days, hours, and minutes.

>>> Brauhaus.displayDuration(65)
'1 hour 5 minutes'
>>> Brauhaus.displayDuration(2833)
'1 day 23 hours 13 minutes'
>>> Brauhaus.displayDuration(2833, 2)
'1 day 23 hours'
>>> Brauhaus.displayDuration(2833, 1)
'2 days'

Conversion Functions

The following functions are available to convert between various forms:

Brauhaus.kgToLb (number)

Convert kilograms to pounds.

>>> Brauhaus.kgToLb(2.5)
5.51155

Brauhaus.lbToKg (number)

Convert pounds to kilograms.

>>> Brauhaus.lbToKg(5.51155)
2.5

Brauhaus.kgToLbOz (number)

Convert kilograms to pounds and ounces.

>>> Brauhaus.kgToLbOz(2.5)
{
    lb: 5,
    oz: 8.184799999999996
}

Brauhaus.lbOzToKg (numberLbs, numberOz)

Convert pounds and ounces to kilograms.

>>> Brauhaus.lbOzToKg(5, 8.184799999999996)
2.5

Brauhaus.litersToGallons (number)

Convert liters to gallons.

>>> Brauhaus.litersToGallons(20.0)
5.283440000000001

Brauhaus.gallonsToLiters (number)

Convert gallons to liters.

>>> Brauhaus.gallonsToLiters(5.283440000000001)
20.0

Brauhaus.litersPerKgToQuartsPerLb (number)

Convert l/kg to qt/lb.

>>> Brauhaus.litersPerKgToQuartsPerLb(5.0)
2.3965285450000002

Brauhaus.quartsPerLbToLitersPerKg (number)

Convert qt/lb to l/kg.

>>> Brauhaus.quartsPerLbToLitersPerKg(2.3965285450000002)
5.0

Brauhaus.cToF (number)

Convert a temperature from celcius to fahrenheit.

>>> Brauhaus.cToF(20.0)
68.0

Brauhaus.fToC (number)

Convert a temperature from fahrenheit to celcius.

>>> Brauhaus.fToC(68.0)
20.0

Brauhaus.yieldToPpg (number)

Convert a yield percentage to parts per gallon.

>>> Brauhaus.yieldToPpg(75)
34.6605

Brauhaus.ppgToYield (number)

Convert part

View on GitHub
GitHub Stars135
CategoryDevelopment
Updated1mo ago
Forks30

Languages

CoffeeScript

Security Score

80/100

Audited on Feb 18, 2026

No findings