beer-me
Library to (not so) randomly pick beers for you.
Requirements
This library works with a list of beers from the metro online grocery website that you can extract using feed-me.
const metro = const fs = metro
The expected format of a beer object is the following:
For convenience, I added a static version of that list in the
beers
branch.
Usage
const beer = const beers = console
You will get a selection of beers in the same format, but with a number of items that will match the desired number of beers (given as second argument).
Getting actual beers
For some reason, even if you search in the beverages/beer-cider
categories, you get, stuff that is definitely not beer:
beverages/beer-cider/cider
beverages/beer-cider/non-alcoholic-beer
beverages/juices-drinks/sparkling-juices-drinks
beverages/soft-drinks/ginger-ale
beverages/wines-cocktails-coolers/cocktails-other-wines
beverages/wines-cocktails-coolers/sparkling-wine
By calling:
const actualBeers = beers
You get only beers from the following categories:
beverages/beer-cider/artisanal-beer-microbrewery
beverages/beer-cider/classic-beer
beverages/beer-cider/classic-light-beer
beverages/beer-cider/imported-beer
beverages/beer-cider/specialty-flavoured-beer
Parsing beer format
beer // { count: 1, size: 740, type: 'can' }beer // { count: 24, size: 330, type: 'cans' }beer // { count: 1, size: 1180, type: 'bottle' }beer // { count: 12, size: 341, type: 'bottles' }
You can also use the following:
const parsedBeers = beers
After what all the beers will have a format
property with the count
,
size
and type
.
This is especially useful to filter beers:
const packsOfCans = parsedBeersconst packsOfBottles = parsedBeersconst bigPacksOfBottles = packsOfBottles
This is also needed for the beerMe
algorithm.
Real life example
Get packs of between 12 and 24 bottles (less than 500 ml) of beer from a given list of brands, to get a total of 48 bottles:
const beer = const beers = const brands = // An array of brand names to pick. const set = beers const selection = beer